[SwiftUI] 특정 속성의 값에 따라 뷰 표시 분기

RudinP·약 18시간 전
0

Study

목록 보기
288/292
  • 특정 속성이 nil이 아니라면 View에 내용을 표시해야 할 때 사용한다.
  • 내용이 바뀌어야할 뷰에 .onAppear 모디파이어를 추가하면 된다.
struct ComposeView: View {
	var memo: Memo? = nil
    
    var body: some View{
    	...
        TextEditor(text: $content)
        .onAppear {
        	if let memo = memo {
            	content = memo.content
            }
        }
    }
}
profile
iOS 개발자가 되기 위한 스터디룸...

0개의 댓글