将字符串传递给视图
// Case 1: English alphabet is no problem
test(deck: "ABCDE")
// Case 2: Font style is missing
test(deck: "?????")
// Case 3: Font style is missing
test(deck: "ABC?????DE")
Run Code Online (Sandbox Code Playgroud)
目标视图:将字符串值存储在文本字段中
struct test: View {
@State var deck : String = ""
var body: some View {
VStack {
TextField("deck name", text: $deck)
.font(.largeTitle)
.foregroundColor(Color.black)
.multilineTextAlignment(.center)
.lineLimit(1)
}
}
}
Run Code Online (Sandbox Code Playgroud)
如您所见,当文本字段包含日语字符时,字体样式无法正常工作。
非常感谢你!
最新版本的 xCode 和 iOS 存在 bug。该问题仅在使用TextField. 如果你使用普通的,Text效果很好。
如果我找到解决这个问题的方法,我会告诉你。在此之前,您不能将 aTextField与这组字符一起使用。
| 归档时间: |
|
| 查看次数: |
56 次 |
| 最近记录: |