Questions tagged [swiftui-text]

60 questions
12
votes
2 answers

SwiftUI Word Wrap for multiline text Word Hyphenation Problem

I'm facing the following problem with SwiftUI Text: In the following example SwiftUI breaks the word "Amazement" into "amazeme" on the first line and "nt" on the second. How to avoid it, isn't it a bug? I want the word "amazement" to be written on…
Adelmaer
  • 2,209
  • 3
  • 22
  • 45
11
votes
1 answer

SwiftUI Text iOS15: Email or URL inside Text view render using accent color

When running the following code in iOS15, the color of a URL or email address within the contents uses the accent color instead of the foreground color. How can I override that? Text("Send a message to john@email.com to request support") …
Ecil
  • 1,009
  • 1
  • 13
  • 28
7
votes
1 answer

Hyphenation SwiftUI Text

How can I add hyphenation to a SwiftUI Text? Currently SwiftUI makes a paragraph when there is no space, but this makes everything hard to read and messy. I have done a bit of research and it seems that there is no native method. Is there another…
J--
  • 172
  • 1
  • 14
6
votes
1 answer

SwiftUI change output format of `Text` using as `.timer`

Is there a way to change the output format of a Text using init(_ date: Date, style: Text.DateStyle)? Using a .timer, the output is like: 0:42, but I want something like 00:00:42. Background I want to create a widget (iOS 14) where a timer is…
d4Rk
  • 6,622
  • 5
  • 46
  • 60
4
votes
1 answer

How can you make Text in SwiftUI appear sideways while also rotating the frame?

The goal is to have something that looks like this: I am aware of .rotationEffect(), and the solution provided here. However the problem with this solution is that it does not rotate the frame, it only rotates the text itself. The image below is…
NSSpeedForce
  • 127
  • 9
4
votes
2 answers

SwiftUI - IOS 15 - Text .mimimumScaleFactor - always being applied

Can't find any documentation of this issue. One of my apps has a text view with a .minimumScaleFactor(0.5). This works perfectly in iOS 14.0.* - when the text would be wider than the view its scales nicely to fit - IE filling the full width of the…
swift--help
  • 637
  • 5
  • 15
4
votes
1 answer

SwiftUI Text scaledToFit and wrap text

I have a button with dynamic text. I'm looking to scale the text down to fit it (as much as possible), and wrap the text to some number of lines (probably 2?). By default, SwiftUI appears to wrap the text on words. But it seems like when I use the…
Hoopes
  • 3,943
  • 4
  • 44
  • 60
4
votes
3 answers

SwiftUI Text unexpected padding bottom and top

I need precise control over the area taken by Text. I created the most basic program that shows unexpected top and bottom spacing being added to a text. Where is this extra padding coming from? How to get rid of it? @main struct myApp: App { …
HixField
  • 3,538
  • 1
  • 28
  • 54
3
votes
1 answer

Is there a way to set font tracking (i.e. spacing) inside a custom SwiftUI ButtonStyle?

In SwiftUI you can set font tracking (spacing between letters) on a Text View using the tracking View modifier: Text("Hello, World!") .tracking(10) If you have a Button and apply your custom ButtonStyle you can do all kinds of modifications to…
shim
  • 9,289
  • 12
  • 69
  • 108
2
votes
1 answer

Why the custom font is not changed according to my setting?

I have already imported the SOV_Assadong_C.tff file to my project using SwiftUI library. Plus, I added SOV_Assadong_C.tff value under the Fonts provided by application key in Information property list: When I used the below code, the text still…
kkk
  • 187
  • 8
2
votes
2 answers

Text() is adding extra leading trailing padding SwiftUI

Hi Im creating this design, with swiftUI but I can't figure out why the Text() is adding more padding to the string value, I just want it to the leading trailing, like margins Design: Result: Code: struct ProductDetailSwiftUIView: View { …
Eder Padilla
  • 1,507
  • 1
  • 13
  • 22
2
votes
1 answer

Filling Various Text views with variables

I'm writing my first Swift app and I am looking for some guidance on how best to fill my Text view elements with variables. Below, I have a simplified version of my app's main ContentView- in reality, it has about 100 Text view elements. I need to…
David Joyce
  • 51
  • 1
  • 5
2
votes
0 answers

SwiftUI: Editable TextFields in Lists

*** NOTE: This question concerns macOS, not iOS *** Context: I have a list of items that serves as a "Master" view in a standard Master-Detail arrangement. You select an item from the list, and the detail view updates: In SwiftUI, this is powered…
Bryan
  • 4,628
  • 3
  • 36
  • 62
2
votes
2 answers

Wrap truncated text in Double quotes in SwiftUI

Expected result (Truncated text wrapped in double-quotes): "Let's figure out your preferen..." I tried using Text("\"\(description)\"") .lineLimit(1) but unable to get a double quote at the end "Let's figure out your preferen...
2
votes
1 answer

SwiftUI Localization Issue

I have a project with two targets representing two different final products. Until now the localization was shared between the two targets, but now I have just one string to be localized differently according to the active target. In order to avoid…
Dree
  • 702
  • 9
  • 29
1
2 3 4