Reputation: 75
I'm trying to scale up the universal PDF image asset in order to get a sharp output, but the image is blurry after scaling it even though the universal resource is a vector file.
override func viewDidLoad() {
super.viewDidLoad()
let image: UIImage = UIImage(named: "map")!
let imageView = UIImageView(image: image)
//following line scales the image 20x
imageView.frame = CGRectMake(0, 0, imageView.frame.width*20, imageView.frame.height*20)
self.view.addSubview(imageView)
}
The above code produces this:
.
The image asset setting looks like this:
.
I need to display a sharp image at unknown sizes, so I though a PDF is a perfect candidate for this, but it continues to produce a blurry output. Any help is appreciated!
Upvotes: 2
Views: 2192
Reputation: 5834
When support for vector resources (PDF files) has been introduced, the vector resources were converted to multiple raster images at different resolutions (for various device capabilities) at build time not at runtime.
So what you are actually drawing in your view is a bitmap image not the PDF file.
If you want to display the PDF content and look sharp you have to use the CGPDF API to render the file in your view.
Upvotes: 4