iOS - 文本和图像上的锯齿状边缘.为什么?以及如何解决? [英] iOS - jagged edges on text and image. Why? and how to fix?

查看:79
本文介绍了iOS - 文本和图像上的锯齿状边缘.为什么?以及如何解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我正在开发的应用中的某些文本和图像会出现锯齿状边缘?

Why are there jagged edges on some of the texts and images in the app i am developping?

我试过遍历帧,我没有使用除法来设置帧(所以 1.134234 不是问题),我尝试了不同的抗锯齿方法.

I have tried to go through the frames, and i have not used a division to set a frame (so the 1.134234 is not an issue), and I have tried different antialiasing methods.

有人有想法吗?

示例见附件.


缩小时,图像会变得锯齿状.因此,要么直接调整它们以适应实际文件中的大小,要么按照其他 StackOverflow 问题中的建议通过代码进行调整.
现在试图弄清楚如何修复文本!:)


The images become jagged, when downscaled. So either resize them to fit the size directly in the actual file, OR via code as suggested in other StackOverflow questions.
Now trying to figure out how to fix the text also! :)

编辑编辑编辑编辑

答案将于明天(24 小时后)发布.

Answer will posted tomorrow (after 24 hours).

1) 图像问题:确保您使用的实际图像尺寸接近您实际使用的尺寸...(Feks 100 点,@1x 处的图像为 100,@2x 为 200,@3x 即 300,其中 100,200 和 300 是实际图像文件像素).或者以正确的方式使用代码调整大小以匹配.
当 iOS 缩小(以及放大)图像时,像素会失真.
我的问题是使用太大的图像.

1) Image problem: Make sure the actual image size you are using is close to the size you are actually using it... (Feks 100 points with an image at @1x that is 100, @2x that is 200, and @3x that is 300, where 100,200, and 300 are the actual image file pixels). Or resize using code in the correct way to match.
When iOS is downscaling (as well as upscaling) an image, the pixels get disorted.
The problem in my case was using a too big an image.

2) 至于按钮,我不知道确切的原因,但它解决了使用属性文本作为标题而不是通常的文本.使用的方法是:
[按钮 setAttributedTitle: forState:];

2) As to the button, I don't know exactly why, but it got solved using attributedText for the title instead of the usual text. Method used is:
[button setAttributedTitle: forState:];

推荐答案

已解决 :D

1) 图像问题:确保您使用的实际图像尺寸接近您实际使用的尺寸...(Feks 100 点,@1x 处的图像为 100,@2x 为 200,@3x 即 300,其中 100,200 和 300 是实际图像文件像素).或者以正确的方式使用代码调整大小以匹配.当 iOS 缩小(以及放大)图像时,像素会变得混乱.我的问题是使用了太大的图像.

1) Image problem: Make sure the actual image size you are using is close to the size you are actually using it... (Feks 100 points with an image at @1x that is 100, @2x that is 200, and @3x that is 300, where 100,200, and 300 are the actual image file pixels). Or resize using code in the correct way to match. When iOS is downscaling (as well as upscaling) an image, the pixels get disorted. The problem in my case was using a too big an image.

2) 至于按钮,我不知道确切的原因,但它解决了使用属性文本作为标题而不是通常的文本.使用的方法是:[按钮 setAttributedTitle: forState:];

2) As to the button, I don't know exactly why, but it got solved using attributedText for the title instead of the usual text. Method used is: [button setAttributedTitle: forState:];

这篇关于iOS - 文本和图像上的锯齿状边缘.为什么?以及如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆