[Swift | iOS] SwiftUI Annotations

문다연·2022년 3월 18일
0

ios.moon

목록 보기
14/26
post-thumbnail
// UploadPostView.Swift
Button.sheet(isPresented, onDismiss, content)

Method to present modal view. This method waiting until @State variable for isPresented is changed. If modal was dismissed, execute the method for onDismiss.
Then the @State var is no longer nil, hit the else block, and we upwrap the selected image.


@State, @Binding

// UploadPost/UploadPostView.swift
@State private car selectedImage: UIImage?

Create a state variable in the parent view

// Utils/ImagePicker.swift
@Binding var image: UIImage?

Create a binding variable in the view that doing another stuff.


@EnvironmentObject

It's shared data that every view can read if they want to.

유저의 로그인 정보를 유지


ObservedOject


Published


escaping

profile
ios-moon.tistory.com 이전했어요 🚛

0개의 댓글