我正在尝试将一长段文字放进屏幕,但它一直溢出。有没有办法将文字换行?
我试着使用对齐使它居中,但它仍然离开屏幕。
import SwiftUI
struct OnboardingPage3: View {
var body: some View {
ZStack {
Color("Onboarding")
.edgesIgnoringSafeArea(.all)
VStack {
Color("Onboarding")
.edgesIgnoringSafeArea(.all)
Image("HomeScreen")
.resizable()
.frame(width: 300, height: 600)
.padding(EdgeInsets(top: 0, leading: 0, bottom: 200, trailing: 0))
Text("This is your home screen where you can see how much progress you have made throughout the day as well as a streaks bar to keep track of how many days straight you have been exercising.")
.frame(alignment: .center)
}
}
}
}
struct OnboardingPage3_Previews: PreviewProvider {
static var previews: some View {
OnboardingPage3()
}
}
1条答案
按热度按时间yrdbyhpb1#
您的文本实际上并没有溢出,只是被截断了。
为了防止这种情况,您可以使用
fixedSize(horizontal:vertical:)
修饰符。我还对您的代码做了一些其他的编辑-没有必要使用这么多的.edgesIgnoringSafeArea
,并且ZStack
可能会对定位产生一些意想不到的副作用。结果: