状态
struct PageView: View {
@State var show:Bool = false
var body: some View {
Image("2")
.onTapGesture {
self.show.toggle()
print(self.show)
}
}
}
struct PageView_Preview: PreviewProvider {
static var previews: some View {
PageView()
}
}
枚举
struct CircleImage: View {
@State var value:CGFloat = 0.5
var body: some View {
VStack {
Slider(value: $value)
}
}
enum CirType:String,Codable,CaseIterable,Hashable {
case type1 = "typ1"
case type2 = "type2"
}
}
struct CircleImage_Preview: PreviewProvider {
static var previews: some View {
CircleImage()
}
}
定义对象
struct OBJ:Codable,Hashable {
}
类
class Test: NSObject {
@Published var name1:String = "test"
}
网友评论