Linked Questions

4 votes
2 answers
6k views

Make the TextField Multiline - SwiftUI [duplicate]

I start learning SwiftUI and I'm trying to make the TextField multiline but it didn't work, also when I click on the return button it dismisses the keyboard. TextField("Description", text: $...
Adel Bassiony's user avatar
574 votes
24 answers
237k views

How to lose margin/padding in UITextView

I have a UITextView in my iOS application, which displays a large amount of text. I am then paging this text by using the offset margin parameter of the UITextView. My problem is that the padding of ...
sniurkst's user avatar
  • 7,302
123 votes
16 answers
47k views

Change background color of TextEditor in SwiftUI

TextEditor seems to have a default white background. So the following is not working and it displayed as white instead of defined red: var body: some View { TextEditor(text: .constant("...
Lorenzo Fiamingo's user avatar
70 votes
23 answers
42k views

How to add placeholder text to TextEditor in SwiftUI?

When using SwiftUI's new TextEditor, you can modify its content directly using a @State. However, I haven't see a way to add a placeholder text to it. Is it doable right now? I added an example that ...
Legolas Wang's user avatar
  • 2,715
86 votes
5 answers
35k views

How do I allow text selection on a Text label in SwiftUI?

When I create a text view: Text("Hello World") I can't allow the user to select text when they long press. I've looked at using a TextField but that doesn't seem to allow for turning off text ...
mralexhay's user avatar
  • 1,324
17 votes
1 answer
14k views

What is the equivalent of textarea in swiftui?

What is the equivalent of textarea in SwiftUI? Where I could have multiple lines of text input. And specify size of this area? HTML example is here: https://www.w3schools.com/tags/tryit.asp?filename=...
mallow's user avatar
  • 2,906
4 votes
4 answers
8k views

SwiftUI - How can a TextField increase dynamically its height based on its content?

I am trying to build a "chat" view using SwiftUI and I would like to know how can I do in order to increase the height dynamically of a TextField where the users should write their messages. I have ...
Andoni Da Silva's user avatar
12 votes
5 answers
5k views

How to use .onSubmit() with vertical TextField in SwiftUI?

I'm trying to have a vertically growing TextField in `SwiftUI but also have the software keyboard have a custom submission method. This uses the new functionality of iOS 16's TextFields being able to ...
Android KitKat's user avatar
8 votes
1 answer
7k views

How to get dynamic height for UITextView in SwiftUI

I'm getting really close to implementing dynamic height for a UITextView in SwiftUI. Please help me work out these kinks: The UITextView has the correct height when it appears but does not adjust ...
atdonsm's user avatar
  • 305
9 votes
1 answer
7k views

Rich TextView in SwiftUI

I'm trying to do a simple notes app in SwiftUI and I'd like to know if there's any library for having a simple rich text view that allows users to write in bold, italics, strikethrough, underline, etc....
amodrono's user avatar
  • 2,038
6 votes
1 answer
3k views

textFieldDidChangeSelection: Modifying state during view update, this will cause undefined behavior

Here is my code: struct CustomTextField: UIViewRepresentable { var placeholder: String @Binding var text: String func makeUIView(context: UIViewRepresentableContext<CustomTextField>...
stardust4891's user avatar
  • 2,580
3 votes
1 answer
3k views

SwiftUI - How can I get multiline text to wrap in a UITextView without scrolling?

I am using the UIViewRepresentable wrapper to create a bindable multiline UITextVIew since there is still no multiline support for the native SwiftUI TextField. It all works fine as long as ...
codewithfeeling's user avatar
5 votes
2 answers
6k views

How to auto-expand height of NSTextView in SwiftUI?

How do I properly implement NSView constraints on the NSTextView below so it interacts with SwiftUI .frame()? Goal An NSTextView that, upon new lines, expands its frame vertically to force a SwiftUI ...
Beginner's user avatar
  • 535
3 votes
2 answers
3k views

How do I create a Multi Line Text Field in SwiftUI for MacOS?

I am writing my first MacOS app using Swift. I need to create a simple editable text box which allows multiple paragraphs. In HTML, this would be a textarea. I gather that iOS 14 will include ...
Manngo's user avatar
  • 16.9k
8 votes
2 answers
6k views

How to render multiline text in SwiftUI List with correct height?

I would like to have a SwiftUI view that shows many lines of text, with the following requirements: Works on both macOS and iOS. Shows a large number of strings (each string is backed by a separate ...
Jaanus's user avatar
  • 17.9k

15 30 50 per page