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

查看:32
本文介绍了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天全站免登陆