原文链接:https://github.com/fzhlee/SwiftUI-Guide#5Text-FullScreen
通过edgesIgnoringSafeArea,忽略安全区域,使文本框撑满屏幕。
这个忽略安全区域的设置,不仅适用于文本视图,对SwiftUI里的其它视图也同样适用。
示例代码:
Text("Hello World")
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity) //设置文本视图的框架属性,不限制文本视图的最大宽度和最大高度
.background(Color.orange)
.font(.largeTitle)
.edgesIgnoringSafeArea(.all) //设置文本视图的边缘,在上下左右4个方向上忽略安全区域的限制

网友评论