Swift/SwiftUI
-
[SwiftUI] GlobalSpinnerSwift/SwiftUI 2023. 12. 5. 05:08
public class Spinner { private var scene: UIWindowScene? { UIApplication .shared .connectedScenes .first as? UIWindowScene } private var root: UIViewController? { scene? .keyWindow? .rootViewController } private var activityIndicator: UIActivityIndicatorView? @MainActor public func start( _ style: UIActivityIndicatorView.Style = .medium, color: UIColor = .gray ) { if self.activityIndicator == ni..
-
[SwiftUI] NavigationStackSwift/SwiftUI 2023. 11. 26. 12:28
import SwiftUI struct ContentView: View { @State var destination: Destination? var body: some View { NavigationStack { Button("Append") { destination = .detail } .navigationDestination(item: $destination, destination: { destination in switch destination { case .detail: Color.green case .setting: Color.red } }) } } } enum Destination { case detail case setting } #Preview { ContentView() }
-
[SwiftUI] Pro Max landscape NavigationView bugSwift/SwiftUI 2023. 7. 13. 20:37
https://developer.apple.com/forums/thread/119691 NavigationView broken in landscape | Apple Developer Forums Still broken in beta 6.5 for me. The views don't even show up in the view debugger. Was hoping it, being one of the required working features, would be working 3 days before this innovation only event. Of course it's probably something you have to do that developer.apple.com .navigationVi..
-
[SwiftUI] iPad, iPhone 대응하기Swift/SwiftUI 2023. 7. 9. 20:43
extension UIDevice { static var idiom: UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom } } struct ContentView: View { var body: some View { Group { if UIDevice.idiom == .phone { iPhone() } else if UIDevice.idiom == .pad { iPad() } } } }
-
StoreKit2 ReferencesSwift/SwiftUI 2023. 7. 9. 20:39
https://developer.apple.com/storekit/ StoreKit - Apple Developer StoreKit provides a simple and secure way for users to purchase digital goods or services in your apps across all Apple platforms. developer.apple.com https://developer.apple.com/videos/play/wwdc2023/10013/ Meet StoreKit for SwiftUI - WWDC23 - Videos - Apple Developer Discover how you can use App Store product metadata and Xcode Pr..
-
[SwiftUI] GeometryReader 란?Swift/SwiftUI 2023. 6. 3. 10:23
좌표랑 크기등을 알수 있다 struct ContentView: View { var body: some View { VStack { Spacer() .frame(height: 200) GeometryReader { proxy in Text("Hello") .onAppear { print(proxy.size) print(proxy.frame(in: .global)) print(proxy.frame(in: .local)) print(proxy.safeAreaInsets) } } .background(Color.gray) .padding(.horizontal) Spacer() .frame(height: 200) } } } // 출력 (343.0, 247.0) // GeometryReader 의 사이즈 (넓이, ..
-
[SwiftUI] Data 로 Lottie 보여주기Swift/SwiftUI 2023. 5. 18. 01:03
struct LottieView: UIViewRepresentable { let data: Data func updateUIView(_ uiView: UIViewType, context: Context) { } func makeUIView(context: Context) -> Lottie.CompatibleAnimationView { let animationView = CompatibleAnimationView(data: data) animationView.contentMode = .scaleAspectFit animationView.play() animationView.loopAnimationCount = .infinity return animationView } }