SwiftUI文本对齐 [英] SwiftUI text-alignment

查看:771
本文介绍了SwiftUI文本对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Text视图的许多属性中,我找不到与文本对齐有关的任何属性.我在一个演示中看到它可以自动处理RTL,并且在使用View的body放置内容时,它总是自动居中.

Among the many properties of the Text view, I couldn't find any related to text alignment. I've seen in a demo that it automatically handles RTL, and when placing stuff using View's body, it always centers it automatically.

SwiftUI中的布局系统是否缺少一些概念,如果没有,如何将文本对齐属性设置为Text?

Is there some concept that I'm missing about layout system in SwiftUI and if not, how can I set the text alignment properties to the Text?

推荐答案

您可以通过修饰符.multilineTextAlignment(.center)来实现.

You can do this via the modifier .multilineTextAlignment(.center).

Apple文档

这篇关于SwiftUI文本对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆