美文网首页
SwiftUI 枚举/类/对象

SwiftUI 枚举/类/对象

作者: 小凡凡520 | 来源:发表于2019-10-18 15:47 被阅读0次
    状态
    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"
    }
    

    相关文章

      网友评论

          本文标题:SwiftUI 枚举/类/对象

          本文链接:https://www.haomeiwen.com/subject/ykaimctx.html