Reputation: 1736
What image size should I choose if I can (at the moment) add only one image size?
Images will be used in UITableViewCell
, most likely width will be from edge to edge, while height may vary.
So should I add 1242px width images and then app itself would downscale it to 750/640px? Or should I use 750px, because there are more iPhone 6 users than 6+ and more users will have better looking image (in other words more people will see original image, rather than scaled)?
Upvotes: 1
Views: 78
Reputation: 3231
Use 1242px image and downscale it. To get the best possible image quality set yourUIImageView.layer.minificationFilter = kCAFilterTrilinear
. You wont see any difference in the image quality when using trilinear filtering.
Another options is to downscale the image before using it:
extension UIImage {
public func rescale(width: CGFloat, _ height: CGFloat) -> UIImage {
let newSize = CGSizeMake(width, height)
UIGraphicsBeginImageContextWithOptions(newSize, false, 0.0)
drawInRect(CGRectMake(0.0, 0.0, newSize.width, newSize.height))
let scaledImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return scaledImage
}
}
let myImage = UIImage(named: "myimage").rescale(newWidth, newHeight)
Upvotes: 2