![](/img/trans.png)
[英]How to adjust navigationBarTitle and Label Text alignment in SwiftUI
[英]SwiftUI change vertical alignment of Label to center image and text
我们可以使用自定义标签样式来做到这一点,比如
struct DemoStyle: LabelStyle {
func makeBody(configuration: Configuration) -> some View {
HStack(alignment: .center) { // << here !!
configuration.icon
configuration.title
}
}
}
并使用它
Label {
Text("Test fdasf \n adfsa dsfsd f asdf \n asd fasd fads sad fda")
} icon: {
Image(systemName: true ? "checkmark.circle.fill" : "circle")
}
.labelStyle(DemoStyle())
使用 Xcode 13 / iOS 15 测试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.