迅速如何调整文本的背景区域
我有一个带有一些堆栈的Swift文件,其中上文的作用很奇怪。我不明白为什么“控制器”文本的背景颜色延伸到屏幕的末端。如何调整背景的高度?
var body: some View {
NavigationView {
ZStack {
Color("Themecolor")
.edgesIgnoringSafeArea(.all)
VStack {
HStack(spacing: 0) {
Text("BIKE")
.font(.system(size: 52))
.fontWeight(.bold)
.foregroundColor(.white)
Text("Controller")
.font(.system(size: 52))
.foregroundColor(.black)
.background(
.white)
}
.offset(y: -50)
I have a swift file with a few stacks, of which the upper text acts weirdly. I can't understand why the background color of the "controller"-text extends up to the end of the screen. How can I adjust the height of the background?
var body: some View {
NavigationView {
ZStack {
Color("Themecolor")
.edgesIgnoringSafeArea(.all)
VStack {
HStack(spacing: 0) {
Text("BIKE")
.font(.system(size: 52))
.fontWeight(.bold)
.foregroundColor(.white)
Text("Controller")
.font(.system(size: 52))
.foregroundColor(.black)
.background(
.white)
}
.offset(y: -50)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,使用
的安全区域应用了带有样式的新背景修饰符,因此我们可以明确将其关闭,例如
用Xcode 13.4/ios 15.5进行
测试是使用不同的修饰符变体
By default new background modifier with style is applied with ignoring safe area for
.all
, so we can explicitly turn it off, likeTested with Xcode 13.4 / iOS 15.5
Alternate: for backward compatibility is to use different variant of modifier