How do view types like Text or Image conform to the View protocol in SwiftUI?

前端 未结 4 1118
后悔当初
后悔当初 2021-02-20 08:39

There is one big thing that confuses me about view types in SwiftUI:

They don\'t seem to conform to the View protocol, but somehow, they mysterious

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-20 09:06

    The extensions.

       extension Text : View {
    
        /// The type of view representing the body of this view.
        ///
        /// When you create a custom view, Swift infers this type from your
        /// implementation of the required `body` property.
        public typealias Body = Never
    }
    

提交回复
热议问题