自定义 UIImage 作为 UIBarButtonItem 出现 pixelated/blurry
Custom UIImage as UIBarButtonItem showing up pixelated/blurry
我正在使用自定义图像作为栏按钮项。在 iPhone 屏幕上看起来不错,但在 运行 更大的显示器(iPad)上看起来像素化。
iPad2:
iPhone6S:
这是我的代码:
// Set Custom Image for Bar Button Item
let button = UIButton(type: .Custom)
button.setImage(UIImage(named: "Share.png"), forState: UIControlState.Normal)
button.addTarget(self, action:"shareButtonClicked", forControlEvents: UIControlEvents.TouchDragInside)
button.frame=CGRectMake(0, 0, 30, 30)
let barButton = UIBarButtonItem(customView: button)
self.navigationItem.rightBarButtonItem = barButton
如何设置图片比例?
iPhone 6s 具有视网膜显示屏。 iPad 2 没有。在晚于该版本的 iPad 的任何版本上试用它,它将是视网膜显示屏,我敢打赌它不会显示为像素化。
您可能可以通过 choosing the resampling method 从较大的图像仔细改进 non-retina 显示器上使用的图像。
我正在使用自定义图像作为栏按钮项。在 iPhone 屏幕上看起来不错,但在 运行 更大的显示器(iPad)上看起来像素化。
iPad2:
iPhone6S:
这是我的代码:
// Set Custom Image for Bar Button Item
let button = UIButton(type: .Custom)
button.setImage(UIImage(named: "Share.png"), forState: UIControlState.Normal)
button.addTarget(self, action:"shareButtonClicked", forControlEvents: UIControlEvents.TouchDragInside)
button.frame=CGRectMake(0, 0, 30, 30)
let barButton = UIBarButtonItem(customView: button)
self.navigationItem.rightBarButtonItem = barButton
如何设置图片比例?
iPhone 6s 具有视网膜显示屏。 iPad 2 没有。在晚于该版本的 iPad 的任何版本上试用它,它将是视网膜显示屏,我敢打赌它不会显示为像素化。
您可能可以通过 choosing the resampling method 从较大的图像仔细改进 non-retina 显示器上使用的图像。