[英]How to make exponents in the SwiftUI
I found the new method in SwiftUI to allow you to create an exponent.我在 SwiftUI 中找到了允许您创建指数的新方法。
Here what I write code is based in SwiftUI on the Swift Playground.这里我编写的代码基于 Swift Playground 上的 SwiftUI。
import SwiftUI
import PlaygroundSupport
struct V: View {
var body: some View {
HStack {
Text("8")
Text("2\n").font(Font.system(size: 10))
}
}
}
PlaygroundPage.current.setLiveView(V())
The \\n allows you to break the line and make a new line in UIKit. \\n 允许您在 UIKit 中断行并创建新行。 However, SwiftUI gives you to make a top while break line and make a new line inside the second Text.
但是,SwiftUI 可以让您在断行时创建顶部并在第二个文本内创建一个新行。 You can make a size for the Font in the Text.
您可以在文本中为字体设置大小。
That's it!就是这样! You made the exponent in SwiftUI!
您在 SwiftUI 中创建了指数!
The following seems look more naturally... as variant以下看起来更自然......作为变体
var body: some View {
Text("8") + Text("2").font(.system(.footnote)).baselineOffset(10)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.