SVGLayer becomes pixelated when zoomed
sebastianludwig opened this issue · 1 comments
sebastianludwig commented
Steps to reproduce the issue
- Use the following snippet as
viewDidLoad
inIcelandicViewController
- Run the demo and choose "Icelandic"
- Zoom in
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
let svgURL = Bundle.main.url(forResource: "iceland", withExtension: "svg")!
let svgLayer = SVGLayer(contentsOf: svgURL)
icelandicView.layer.addSublayer(svgLayer)
svgLayer.bounds = CGRect(x: 0, y: 0, width: svgLayer.preferredFrameSize().width, height: svgLayer.preferredFrameSize().height)
icelandicView.frame = svgLayer.bounds
let scrollview = UIScrollView(frame: view.bounds)
scrollview.maximumZoomScale = 50.0
scrollview.minimumZoomScale = 0.5
scrollview.contentSize = svgLayer.bounds.size
scrollview.delegate = self
scrollview.addSubview(icelandicView)
view.addSubview(scrollview)
}
One great advantage of vector images is, that they can be zoomed without blurring/pixelating. However PocketSVG/SVGLayer does not yield this benefit, because rasterization is enabled.
The origin of this goes back to the implementation of SVGImageView
in 2014, unfortunately without explanation why rasterization was enabled.
Do you guys remember? If so, could you maybe a comment about it in the readme? Otherwise I suggest leaving shouldRasterize
on its default value NO
.
fjolnir commented
I made it on by default for performance reasons. It's easy to disable if needed.