iOS - jagged edges on text and image. Why? and how to fix?

送分小仙女□ 提交于 2021-02-08 09:24:12

问题


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

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.

Does anybody have an idea?

See attached for an example.

EDIT:
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! :)

EDIT EDIT EDIT EDIT

Answer will posted tomorrow (after 24 hours).

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) 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:];

Jagged edges


回答1:


Solved it :D

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) 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:];



来源:https://stackoverflow.com/questions/27608129/ios-jagged-edges-on-text-and-image-why-and-how-to-fix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!