Does `ShapeStyle` inherit from `View`?

213 views Asked by At

In the official document about ShapeStyle, there is nowhere to find out whether ShapeStyle inherits from something else or not, is it a View?

1

There are 1 answers

1
Mohammad Rahchamani On

Here is the definition of ShapeStyle. As you can see, it conforms to View protocol.

/// A way to turn a shape into a view.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public protocol ShapeStyle {
}

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ShapeStyle {

    /// Return a new paint value matching `self` except using `rect` to
    /// map unit-space coordinates to absolute coordinates.
    @inlinable public func `in`(_ rect: CGRect) -> some ShapeStyle

}

/// Default View.body implementation to fill a Rectangle with `self`.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension ShapeStyle where Self : View, Self.Body == _ShapeView<Rectangle, Self> {

    public var body: _ShapeView<Rectangle, Self> { get }
}