【问题标题】:Make UIButton image appear crisp-perfect on retina display使 UIButton 图像在视网膜显示器上显得清晰完美
【发布时间】:2016-12-21 00:12:11
【问题描述】:

所以我已经阅读了大量关于如何在 iOS 中的 UIButton 的 .imageView 属性上实现完美图像质量的阅读。这是我的例子->

根据以下行,我有一个 UIButton 24x24 点:

myButton = [UIButton buttonWithType:UIButtonTypeCustom];
myButton.frame = CGRectMake(82, 8, 24, 24);
myButton.contentMode = UIViewContentModeCenter;
buttonImage = [UIImage imageNamed:@"myImage.png"];
ogImage = [buttonImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

然后我将原始图像大小设置为 46x46 像素(按钮上的两倍 23x23、24x24 以防止 iOS 自动锯齿),然后将图像@2x 设置为 92x92 像素。我在 iPhone 6s(显然是视网膜显示器)上进行测试,但我的 UIButton 图像上仍然出现一些锯齿状。我在这里做错了什么?我还是不明白如何获得完美的视网膜质量吗?

这是一张图片,我希望它可以很好地显示,例如:

【问题讨论】:

  • 你试过设置按钮imageView的内容模式吗?即myButton.imageView.contentMode = UIViewContentModeCenter;

标签: ios uibutton uiimage


【解决方案1】:

不确定这是否会有所帮助,但这是我个人的偏好。例如,如果我有一个大小为 24x24 的 UIButoon,我总是生成 24x24、48x48 和 72x72 的图像。我依靠我的 Adob​​e Illustrator 来创建像素完美的图像。始终在像素预览模式下检查您的图像,并确保边缘与像素对齐。如果没有,它会产生您在 xCode 中看到的工件。 如果这是您在 Illustrator 中想要的,那么这就是您在 xCode 中获得的。

【讨论】:

    猜你喜欢
    • 2015-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-01
    • 1970-01-01
    • 2012-06-13
    相关资源
    最近更新 更多