gpt4 book ai didi

ios - 自定义 UIImage 作为 UIBarButtonItem 显示像素化/模糊

转载 作者:搜寻专家 更新时间:2023-11-01 07:27:36 24 4
gpt4 key购买 nike

我使用自定义图像作为栏按钮项。在 iPhone 屏幕上看起来不错,但在更大的显示器 (iPad) 上运行时似乎像素化了。

iPad2:

iPad2 simulator

iPhone 6S:

iPhone 6S simulator

这是我的代码:

// 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 改进非视网膜显示屏上使用的图像仔细从更大的图像。

关于ios - 自定义 UIImage 作为 UIBarButtonItem 显示像素化/模糊,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34957753/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com