如何在 SwiftUI 中制作指数 [英] How to make exponents in the SwiftUI
本文介绍了如何在 SwiftUI 中制作指数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 SwiftUI 中发现了一种新方法,可以让您创建指数.
I found the new method in SwiftUI to allow you to create an exponent.
这里我编写的代码基于 Swift Playground 上的 SwiftUI.
Here what I write code is based in SwiftUI on the Swift Playground.
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())
\n 允许您在 UIKit 中换行并换行.但是,SwiftUI 可以让您在断行时创建顶部并在第二个文本内创建一个新行.您可以在文本中为字体设置大小.
The \n allows you to break the line and make a new line in UIKit. However, SwiftUI gives you to make a top while break line and make a new line inside the second Text. You can make a size for the Font in the Text.
就是这样!您在 SwiftUI 中创建了指数!
That's it! You made the exponent in SwiftUI!
推荐答案
以下看起来更自然...作为变体
The following seems look more naturally... as variant
var body: some View {
Text("8") + Text("2").font(.system(.footnote)).baselineOffset(10)
}
这篇关于如何在 SwiftUI 中制作指数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文