![]() This is because SwiftUI lets us recolor text however we want, but it must always be a simple color, whereas you can place any kind of view in the background – a color, yes, but also a shape, some other text, and more. Tip: You might wonder why foregroundStyle() has color in the name, whereas background() does not. Anyway, to give our layout a yellow background color we would add this: Text("The best laid plans") background() because it’s possible to use more advanced backgrounds than just a flat color. You can also set the background color, but that uses. using a gradient, you should use foregroundStyle() like this: Text("The best laid plans") foregroundStyle() modifier, like this: Text("The best laid plans")įor more complex text coloring, e.g. We can control the color of text using the. font() on it like this: Text("This is an extremely long text string that will never fit even the widest of phones without wrapping") ![]() ![]() Not only do text views give us a predictably wide range of control in terms of how they look, they are also designed to work seamlessly alongside core Apple technologies such as Dynamic Type.īy default a Text view has a “Body” Dynamic Type style, but you can select from other sizes and weights by calling. How to style text views with fonts, colors, line spacing, and more ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |