作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 SwiftUI 的 Link从应用程序打开 Safari。但我有一个很长的链接文本。
目前,文本的第二行始终保持居中对齐。
我希望能够使用leading TextAlignment有了它。
所以我尝试使用 multilineTextAlignment但没有成功。
Link("Some long text even very looong even that long text here!", destination: URL(string: "https://www.apple.com/")!)
.multilineTextAlignment(.leading)
需要帮助。
最佳答案
我的解决方案是使用链接本身的另一个签名和multilineTextAlignment。
Link(destination: URL(string: "https://www.apple.com/")!) {
Text("Some long text even very looong even that long text here!")
.multilineTextAlignment(.leading)
}
public struct Link<Label> : View where Label : View {
/// Creates a control, consisting of a URL and a label, used to navigate
/// to the given URL.
///
/// - Parameters:
/// - destination: The URL for the link.
/// - label: A view that describes the destination of URL.
public init(destination: URL, @ViewBuilder label: () -> Label)
希望能帮助别人!
最佳
关于SwiftUI 链接长文本对齐多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73699299/
我是一名优秀的程序员,十分优秀!