GeometryReader
public struct GeometryReader : Element
An element that dynamically builds its content based on the available space.
Use this element to build elements whose contents may change responsively to different layouts.
Example
GeometryReader { (geometry) -> Element in
let image: UIImage
switch geometry.constraint.width.maximum {
case ..<100:
image = UIImage(named: "small")!
case 100..<500:
image = UIImage(named: "medium")!
default:
image = UIImage(named: "large")!
}
return Image(image: image)
}
-
Declaration
Swift
public init(elementRepresentation: @escaping (GeometryProxy) -> Element)
-
Declaration
Swift
public var content: ElementContent { get }
-
Declaration
Swift
public func backingViewDescription(with context: ViewDescriptionContext) -> ViewDescription?