티스토리 뷰
[ TextEditor ]
TextEditor 는 iOS 14+ 인데, iOS 26 부터 쓸 수 있는 이니셜라이저가 추가되었다.

AttributedString 는 iOS 15+ 이고 Text 의 이니셜라이저에서 먼저 사용되고 있었는데 (iOS 15+)
이제 뷰어 뿐만아니라 에디터에서도 사용할 수 있게 된 것이다. 🥹
TextEditor 에 AttributedString 을 받는 이니셜라이저를 사용하면
String 을 받는 이니셜라이저와 달리 Format 이라는 메뉴가 뜨고


기본으로 제공되는 rich text editing 을 지원할 수 있다.

맥 OS 는 이렇게 나옴

대부분의 attribute, paragraph style 이 지원되는 듯 보인다.

다만 한국어는 아직 불안정한데 ;;;
스페이스바나 엔터치면 이렇게 됨 ;;;; ;;

[ Attributed String ]


NEW (iOS 26+)
(일부만 적음. 전체는 문서 참고)
텍스트 스타일
- AttributedString.TextAlignment
텍스트 Selection
Bidirectional text 를 지원한다고 함

텍스트 변경

[ TextEditor > Custom Control ]
TextEditor 에 Custom Control 을 연결할 수도 있음
Suggestion 해주는 Control 을 추가하는 코드


[ TextEditor > Custom Text Format ]
AttributedTextFormattingDefinition 를 채택해서 커스텀 텍스트 포맷을 미리 정의해두고

TextEditor 에 적용할 수도 있음

AttributedTextValueConstraint 사용해서 특정 attribute 의 value 를 원하는 대로 지정할 수도 있음
아래는 forgregoundColor attribute 에 대한 예제

[ 참고 ]
- WWDC 25 > Code-along: Cook up a rich text experience in SwiftUI with AttributedString
- Building rich SwiftUI text experiences
'🍏 > SwiftUI + Combine' 카테고리의 다른 글
| [SwiftUI] @Previewable, PreviewModifier (2) | 2024.10.20 |
|---|---|
| [SwiftUI] Layout 을 이용한 SizeLogger (2) | 2024.08.12 |
| [SwiftUI] scrollClipDisabled (0) | 2024.08.12 |
| [Combine] ConnectablePublisher (0) | 2024.08.04 |
| [SwiftUI] Preferences (0) | 2024.05.23 |
- Total
- Today
- Yesterday
- Sketch 누끼
- PencilKit
- flutter dynamic link
- Flutter Text Gradient
- Django Heroku Scheduler
- Watch App for iOS App vs Watch App
- Python Type Hint
- github actions
- Flutter 로딩
- drf custom error
- flutter 앱 출시
- 플러터 얼럿
- flutter build mode
- METAL
- 플러터 싱글톤
- Flutter Clipboard
- flutter deep link
- Flutter Spacer
- ribs
- cocoapod
- Flutter getter setter
- ipad multitasking
- DRF APIException
- 장고 URL querystring
- SerializerMethodField
- Django Firebase Cloud Messaging
- Django FCM
- 장고 Custom Management Command
- Dart Factory
- 구글 Geocoding API
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |