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
// The SwiftUI Lab | |
// Website: https://swiftui-lab.com | |
// Article: https://swiftui-lab.com/alignment-guides | |
import SwiftUI | |
struct ContentView: View { | |
@State private var alignment: HorizontalAlignment = .leading | |
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
// Authoer: The SwiftUI Lab | |
// Full article: https://swiftui-lab.com/scrollview-pull-to-refresh/ | |
import SwiftUI | |
import Combine | |
struct Dog: Identifiable { | |
let id = UUID() | |
let name:String | |
let picture: String |
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
struct ContentView: View { | |
@State private var flag = false | |
var body: some View { | |
GeometryReader { proxy in | |
ZStack(alignment: .topLeading) { | |
// Draw the Infinity Shape | |
InfinityShape().stroke(Color.purple, style: StrokeStyle(lineWidth: 5, lineCap: .round, lineJoin: .miter, miterLimit: 0, dash: [7, 7], dashPhase: 0)) | |
.foregroundColor(.blue) |
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
// The SwiftUI Lab: https://swiftui-lab.com | |
import SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
Text("hello world!") | |
.padding(20) | |
.addBorder(Color.blue, width: 3.0, cornerRadius: 80) | |
} | |
} |
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
// The SwiftUI Lab: https://swiftui-lab.com | |
// Article: Inspecting the View Tree – Part 2 | |
// https://swiftui-lab.com/communicating-with-the-view-tree-part-2/ | |
import SwiftUI | |
struct MyTextPreferenceData { | |
let viewIdx: Int | |
var topLeading: Anchor<CGPoint>? = nil | |
var bottomTrailing: Anchor<CGPoint>? = nil |
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
// The SwiftUI Lab: https://swiftui-lab.com | |
// Article: Inspecting the View Tree – Part 2 | |
// https://swiftui-lab.com/communicating-with-the-view-tree-part-2/ | |
import SwiftUI | |
struct MyTextPreferenceData { | |
let viewIdx: Int | |
let bounds: Anchor<CGRect> | |
} |
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
// The SwiftUI Lab: https://swiftui-lab.com | |
// Article: Inspecting the View Tree – Part 1 | |
// https://swiftui-lab.com/communicating-with-the-view-tree-part-1/ | |
import SwiftUI | |
struct MyTextPreferenceKey: PreferenceKey { | |
typealias Value = [MyTextPreferenceData] | |
static var defaultValue: [MyTextPreferenceData] = [] |
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
// The SwiftUI Lab: https://swiftui-lab.com | |
// Article: Inspecting the View Tree – Part 1 | |
// https://swiftui-lab.com/communicating-with-the-view-tree-part-1/ | |
import SwiftUI | |
struct EasyExample : View { | |
@State private var activeIdx: Int = 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
// Advanced SwiftUI Transitions | |
// https://swiftui-lab.com | |
// https://swiftui-lab.com/advanced-transitions | |
import SwiftUI | |
struct GeometryEffectTransitionsDemo: View { | |
@State private var show = false | |
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
// Safely Modifying The View State (SwiftUI) | |
// https://swiftui-lab.com | |
// https://swiftui-lab.com/state-changes | |
import SwiftUI | |
struct CustomView: View { | |
var body: some View { | |
NavigationView { |
OlderNewer