Questions tagged [swiftui-text]

60 questions
0
votes
1 answer

How to use layoutPriority on 1 component while using maxWidth / minWidth on deprioritized component

I am trying to create a UI component where we have a horizontal cell containing a title / subtitle on the leading side. Then at the trailing end of the component, there's an optional text (actionText), like so: This is what I want to…
0
votes
0 answers

SwiftUI The truncate behavior of the text with a link property and a /n is strange

I want to implement text that can detect links and click. Everything was perfect, but I found one strange thing. When the Text with linelimit() and long string and the latter part is omitted, if there is a newLine before that, ellipsis…
wilybear
  • 1
  • 1
0
votes
1 answer

How to shorten long reusable modifiers like font style, foreground styles, etc

I have a custom font modifier that I am using often, however it makes the code very long as I need to add it in multiple places. This is the modifier: .font(.custom("Bebas Neue", size: 24)).foregroundStyle(LinearGradient(gradient: Gradient(colors:…
Pro Girl
  • 762
  • 7
  • 21
0
votes
1 answer

SwiftUI iOS16 TextField .keyboardType add return key. How to?

My app is in landscape mode and I have a textfield which is only numbers, so I put the modifier: .keyboardType (.numberPad) However when the keypad is open there is no return key and the button/navigation link is covered by the keypad. What is the…
Pro Girl
  • 762
  • 7
  • 21
0
votes
1 answer

Present sheet with a TextField and its keyboard in a single animation?

I'm building a SwiftUI to-do app. You tap an Add button that pulls up a partial-height sheet where you can enter and save a new to-do. The Add sheet's input (TextField) should be focused when the sheet appears, so in order to keep things feeling…
0
votes
1 answer

How to handle text wrapping and alignment / padding with consecutive Text Views in SwiftUI?

When putting Text() views that have enough text to cause it to wrap, one after the other, they don't have the same alignment / padding unless they have a similar word structure. I would like to both have a solution to this problem that allows for…
Corith
  • 65
  • 6
0
votes
2 answers

Text not expanding horizontally SwiftUI

Fetching text from JSON API all is working fine however text is not taking full space horizontally instead wrapping up after every item: HStack(alignment: .top){ HStack{ Text("Sample Type :") .font(.system(size: 12)) …
tintin
  • 335
  • 2
  • 8
0
votes
1 answer

SwiftUI TextFields based on @Published array not updating

I am trying to lay out a bunch of CustomTextViews which can toggle between a SwiftUI TextField or Text view. Consider this example. import SwiftUI struct ContentView: View { @StateObject var doc: Document = Document() var body:…
0
votes
1 answer

How to determine width needed for a button in SwiftUI

If I have a string that I will place inside of a SwiftUI button label, how can I determine how much width I need to allow the button to consume such that the text in the button will not be truncated with ellipsis? This would assume no font size…
pinglock
  • 982
  • 2
  • 12
  • 30
0
votes
1 answer

SwiftUI Text: How to always show the last characters of a text even if the text is too long?

I have a text in a frame that can become too long depending on the user input. If a text is too long in SwiftUI, SwiftUI abbreviates it with "..." at the end. Example: "That's a very long te..." But now I want the last x characters to always be…
SwiftUI_Max
  • 201
  • 2
  • 6
0
votes
1 answer

swiftui text is not centered

The code I used below is not center centered. the top space is twice as much as the bottom space. Don't need to be equal to the bottom and top space? How I can center Text? struct ContentView: View { var body: some View { …
ursan526
  • 485
  • 3
  • 10
0
votes
0 answers

How to get the size of a Text View in SwiftUI w/o rendering the view?

On my content view, I’d like to display a small table. To illustrate: In HTML I’d just say
First itemFirst value
Second itemSecond value
Third itemThird…
Joe Völker
  • 781
  • 1
  • 5
  • 19
0
votes
1 answer

How to set up Textfield and Button in Custom SwiftUI View

I am attempting the configure the text field and button in my openweathermap app to be in its own view other than the main content view. In TextFieldView, the action of the button is set up to call an API response. Then, the weather data from the…
0
votes
1 answer

SwiftUi is there a way to get a Text inside a TextField

I have recently migrated from UIKit to SwiftUi 2.0 and I am rebuilding my app with SwiftUI . In UIKit I have a textbox and inside that textbox I have a post button and I am trying to do the same in SwiftUi but have not succeeded . In the image below…
user1591668
  • 2,591
  • 5
  • 41
  • 84
0
votes
0 answers

Two Text inside a ScrollView that Fit to the content of the Texts

I have two Text in a VStack. Both texts can grow to an unlimited amount of lines. I want that if the text grows more than the screen I can scroll and see all the content. Mi first approach: var body: some View { VStack(alignment: .center,…
Andres
  • 11,439
  • 12
  • 48
  • 87
1 2 3
4