This file contains hidden or 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 MyScrollView<Content: View>: UIViewRepresentable { | |
let axis: Axis | |
@ViewBuilder let content: () -> Content | |
class Coordinator: NSObject, UIScrollViewDelegate { | |
var hostingController: UIHostingController<Content>? | |
} | |
func makeCoordinator() -> Coordinator { | |
Coordinator() |
This file contains hidden or 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 | |
// ... | |
SomeView() | |
.background(UIViewControllerLifecycleView( | |
onViewWillAppear: { | |
}, onViewDidAppear: { | |
}, onViewWillDisappear: { | |
}, onViewDidDisappear: { | |
}) |
This file contains hidden or 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 isShrinked = false | |
@State var response: CGFloat = 1 | |
@State var dampingFraction: CGFloat = 0.5 | |
@State var blendDuration: CGFloat = 0 | |
var body: some View { | |
VStack { |
This file contains hidden or 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 size: CGSize = .zero | |
var body: some View { | |
VStack { | |
Text(size.debugDescription) | |
ChildView() | |
} |
This file contains hidden or 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
func fetchData(url: URL) async throws -> Data { | |
let cancellables = NSMutableSet() | |
return try await withTaskCancellationHandler { | |
try await withCheckedThrowingContinuation { continuation in | |
let cancellable = APIClient() | |
.request(url: url) | |
.sink { completion in | |
switch completion { | |
case .failure(let error): | |
continuation.resume(throwing: error) |
This file contains hidden or 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 | |
protocol AppearanceProtocol { | |
var text: String { get } | |
} | |
struct MyView<Appearance: AppearanceProtocol>: View { | |
let appearance: Appearance | |
var body: some View { |
This file contains hidden or 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 ContainerView<Content: View>: View { | |
@ViewBuilder let content: Content | |
var body: some View { | |
content | |
} | |
} |
This file contains hidden or 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 { | |
LazyVGrid(columns: [.init(.flexible()), .init(.flexible())]) { | |
ForEach((0...79), id: \.self) { | |
let codepoint = $0 + 0x1f600 | |
let emoji = String(Character(UnicodeScalar(codepoint)!)) | |
Text("\(emoji)") |
This file contains hidden or 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
let appearance = UITabBarAppearance() | |
appearance.configureWithTransparentBackground() | |
appearance.backgroundColor = backgroundColor | |
appearance.backgroundImage = backgroundImage | |
[appearance.stackedLayoutAppearance, | |
appearance.compactInlineLayoutAppearance, | |
appearance.inlineLayoutAppearance] | |
.forEach { | |
$0.selected.iconColor = selectedColor |
NewerOlder