Reading time: 1 min
This recipe shows how to change TextEditor background color in SwiftUI.
The end result looks like this:
This feature is available starting in SwiftUI 4 (iOS 16, macOS 12.4).
The trick is to do the same thing we did for changing List background color: set scrollContentBackground
to hidden
:
TextEditor(text: $text)
.scrollContentBackground(.hidden) // HERE
.background(.green)
Search our recipes
Related Posts
- 100 SwiftUI Text with HTML via NSAttributedString
- 100 Introducing SwiftUI Recipes Companion!
- 100 Easy data pagination with SwiftPaging
- 100 SwiftUI View to Image With ImageRenderer (Any Version)
- 100 SwiftUI Share - ShareLink for All Versions
Check out the companion apps!
Our free companion app and XCode Extension brings 100+ SwiftUI recipes right at your fingertips! Get a preview of it in the Online Companion.
Have a recipe for us?
Get in touch and let's grow the cookbook together!