0.20.1 SwiftUI SVGView
SwiftUI
Adds native SwiftUI support with SVGView
:
var body: some View {
SVGView(named: "sample.svg")
.aspectRatio(contentMode: .fit)
.padding()
}
Pass a SVG
instance for better performance:
var image: SVG
var body: some View {
SVGView(svg: image)
}
Transformation
SVG
is now a struct
and gains the ability to transform the image, updating its size before rasterization:
let svg = SVG(name: "fish.svg")! // 100x100
.expanded(left: 10, right: 10) // 120x100
.scaled(2) // 240x200
imageView.image = svg.rasterize() // 240x200
Note:
@objc(SVGImage)
has been removed.SVG
is now astruct
and incompatible with ObjectiveC. Users can write their own objc wrapper to continue use.