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 { | |
var body: some View { | |
ScrollView(.vertical) { | |
ForEach(0..<1000) { i in | |
RoundedRectangle(cornerRadius: 24) | |
.fill(.blue) | |
.frame(height: 100) | |
.padding(.horizontal) |
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 { | |
var body: some View { | |
ScrollView(.vertical) { | |
ForEach(0..<1000) { i in | |
RoundedRectangle(cornerRadius: 24) | |
.fill(.purple) | |
.frame(height: 100) | |
.padding(.horizontal) |
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 rating: Double = 0 | |
var body: some View { | |
HStack(spacing: 18) { | |
Button( | |
action: { withAnimation { rating -= 1 } }, | |
label: { Image(systemName: "minus.circle") } |
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 FlowLayoutSampleView: View { | |
@State var width: CGFloat = 180 | |
let tags: [String] = [ | |
"Objective-C", | |
"Swift", | |
// "SwiftSwiftSwiftSwiftSwiftSwiftSwiftSwift", | |
// "SwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwift", |
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 | |
enum CustomGridItem: LayoutValueKey, Hashable { | |
enum Bar: Hashable { | |
case vertical | |
case horizontal | |
} | |
case cell | |
case bar(Bar) | |
static var defaultValue: Self = .cell |
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 | |
@main | |
struct App: SwiftUI.App { | |
var body: some Scene { | |
WindowGroup { | |
ContentView() | |
} | |
} | |
} |
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 containerFrame: CGRect = .zero | |
private var colors = [[Color]](repeating: .rainbow(count: 50), count: 300) | |
.flatMap { $0 } | |
.enumerated() | |
.map { $0 } | |
var body: some View { |
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 | |
extension [Color] { | |
static func rainbow(hue: Double = 0, count: Int) -> Self { | |
(0..<count).map { i in | |
var value = hue + Double(i) / Double(count) | |
value -= floor(value) | |
return Color(hue: value, saturation: 1/4, brightness: 1) | |
} | |
} |
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 mode = EditMode.inactive | |
var body: some View { | |
NavigationStack { | |
VStack { | |
ForEach(1..<12) { offset in | |
FooView(count: 12, offset: offset) |
NewerOlder