mgy*_*yky 2 text-alignment swiftui swiftui-link
我正在使用 SwiftUI 的链接从应用程序中打开 Safari。但我有一个很长的链接文本。
目前,文本的第二行始终保持居中对齐。
我希望能够使用领先的 TextAlignment。
所以我尝试使用multilineTextAlignment但没有成功。
Link("Some long text even very looong even that long text here!", destination: URL(string: "https://www.apple.com/")!)
.multilineTextAlignment(.leading)
Run Code Online (Sandbox Code Playgroud)
需要帮忙。
我的解决方案是使用 Link 本身的另一个签名与multilineTextAlignment。
Link(destination: URL(string: "https://www.apple.com/")!) {
Text("Some long text even very looong even that long text here!")
.multilineTextAlignment(.leading)
}
Run Code Online (Sandbox Code Playgroud)
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)
Run Code Online (Sandbox Code Playgroud)
希望能帮助别人!
最好的
归档时间: |
|
查看次数: |
798 次 |
最近记录: |