SwiftUI之如何使Text背景全屏

1.给View添加一个extensionextension View { func expandable () -> some View { ZStack { Color.clear ...

SwiftUI之如何绘制虚线

1.使用Rectangle()绘制struct ContentView: View { var body: some View { Rectangle() .strokeBorder(style: Str...

SwiftUI之stroke()和strokeBorder()区别

1.stroke()会使View变大,因为绘制边框一半在里面,一半在外面you’ll see the circle looks bigger because the stroke is drawn half inside and half out...

SwiftUI之之如何给View绘制边框

1.最简单的边框Text("Hacking with Swift") .border(Color.green)2.边框不紧挨着ViewText("Hacking with Swift") .padding() .border(C...

SwiftUI之Menu示例

1.最简单的Menu```swiftstruct ContentView: View { var body: some View { Menu(“Options”) { Button(“Order Now...

SwiftUI之Picker(menu/segmented/wheel)

1.menu会自动显示已选择项(前面一个✔️),会根据按钮位置自动调整向上或向下弹窗```swiftstruct ContentView: View { @State private var selection = “Red” let...

SwiftUI之如何代码切换TabView选中的tabItem

给tab view items 添加数字```swiftstruct ContentView: View { @State var selectedView = 1

SwiftUI之如何使用badge(iOS 15)

在iOS 15 新增了badge() modifier1.给tab view items 添加数字```swiftstruct ContentView: View { var body: some View { VStack ...

SwiftUI之如何给text里面插入images

使用+号,直接插入,将Image当成Text初始化值1.示例Text("Hello ") + Text(Image(systemName: "star")) + Text(" World!")2.示例(Text("Hello ") + Text(...