This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
@StateObject private var viewModel = RectsViewModel() | |
var body: some View { | |
GeometryReader { geometry in | |
TimelineView(.animation) { timeline in | |
Canvas {context, size in | |
let rects = viewModel.rects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
@State private var date = ISO8601DateFormatter().date(from: "2025-01-01T00:00:00+09:00")! | |
@State private var code: LanguageCode = .japanese | |
@State private var timeZoneID: TimeZoneID = .jst | |
@State private var calendarName: CalendarName = .gregorian | |
var body: some View { | |
NavigationStack { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import UIKit | |
extension UIDatePicker.Mode { | |
static var fallbackYearAndMonth: Self { | |
if #available(iOS 17.4, *) { | |
.yearAndMonth | |
} else { | |
.init(rawValue: 4269) ?? .date | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
#Preview { | |
@Previewable @State var value: Double = 3.0 | |
VStack { | |
SampleView() | |
.environment(\.dynamicTypeSize, .allCases[Int(value)]) | |
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .trailing) | |
.contentTransition(.numericText()) | |
Text("\(DynamicTypeSize.allCases[Int(value)])") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
@State var value: Double = 4.0 | |
let text = Text("Hello") | |
var body: some View { | |
VStack { | |
Grid(alignment: .leading) { | |
GridRow { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
@State var isDark = false | |
@State var currenct = ColorScheme.light | |
@Environment(\.colorScheme) var environment | |
var body: some View { | |
NavigationStack { | |
Form { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import SwiftUI | |
class SampleViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let traits = [UITraitPreferredContentSizeCategory.self] | |
registerForTraitChanges(traits) { (self: Self, _) in | |
self.view.invalidateIntrinsicContentSize() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
// Xcode: 16.0 | |
// Swift: 6.0 | |
struct EnumPicker<Enum>: View where Enum: CaseIterable & Hashable, Enum == Enum.AllCases.Element, Enum.AllCases: RandomAccessCollection { | |
@Binding var selection: Enum | |
var body: some View { | |
Picker(String(describing: Enum.self), selection: $selection) { | |
ForEach(Enum.allCases, id: \.self) { value in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
@State var ratio: Double = 0 | |
var body: some View { | |
ZStack { | |
Color(hue: 1, saturation: 0.3, brightness: 1) | |
.hueRotation(.degrees(360 * ratio)) | |
.ignoresSafeArea() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
@ViewBuilder | |
private func leftHandSide() -> some View { | |
HelloWorld() | |
.clipShape(Rectangle()) | |
HelloWorld() | |
.clipShape(RoundedRectangle(cornerRadius: 20)) | |
HelloWorld() |
NewerOlder