티스토리 뷰

TextEditor에는 PlaceHolder를 설정할 수 없다.

그래서 ZStack을 이용해서 TextEditor의 텍스트가 빈문자열인 경우, PlaceHolder로 사용할 Text를 보이게 하면 된다.

ZStack(alignment: .topLeading) {
    if content.isEmpty {
        Text("content")
            .padding(7)
            .foregroundColor(Color(uiColor: .placeholderText))
    } else {
        EmptyView()
    }
    
    TextEditor(text: $content)
}
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
글 보관함