SwiftUI之如何使Text背景全屏
1.给View添加一个extensionextension View { func expandable () -> some View { ZStack { Color.clear ...
1.给View添加一个extensionextension View { func expandable () -> some View { ZStack { Color.clear ...
1.使用Rectangle()绘制struct ContentView: View { var body: some View { Rectangle() .strokeBorder(style: Str...
1.stroke()会使View变大,因为绘制边框一半在里面,一半在外面you’ll see the circle looks bigger because the stroke is drawn half inside and half out...
1.最简单的边框Text("Hacking with Swift") .border(Color.green)2.边框不紧挨着ViewText("Hacking with Swift") .padding() .border(C...
1.最简单的Menu```swiftstruct ContentView: View { var body: some View { Menu(“Options”) { Button(“Order Now...
1.menu会自动显示已选择项(前面一个✔️),会根据按钮位置自动调整向上或向下弹窗```swiftstruct ContentView: View { @State private var selection = “Red” let...
给tab view items 添加数字```swiftstruct ContentView: View { @State var selectedView = 1
在iOS 15 新增了badge() modifier1.给tab view items 添加数字```swiftstruct ContentView: View { var body: some View { VStack ...
使用+号,直接插入,将Image当成Text初始化值1.示例Text("Hello ") + Text(Image(systemName: "star")) + Text(" World!")2.示例(Text("Hello ") + Text(...