How to Anti-Alias Layers in iPhoneOS

自闭症网瘾萝莉.ら 提交于 2019-12-04 04:53:56

This has the effect of adding a transparent border:

layer.cornerRadius = 1.01;
Shannon A.

The best result that I could come up with was by doing what I suggested in my comment: I grew each (transparent) graphic by 1 pixel on each side. With that little bit of margin, the cards composited much better with the background.

So, not exactly an iPhone code answer, but one that nonetheless works on the iPhone.

Here's an "after" shot that you can compare to the "before", above:

I never used the framework, but it looks like the anti-aliasing works only on the inner side of the card, not on the outer side (assuming the rounded corners on non-rotated cards are a special case).

So IMHO it actually is a composition problem of cards and background.

A quick view to the docs offers some hints (only assumptions, try them):

Make sure Opaque property is false (maybe what you see is the result of an optimization of the rendering code).

Check what it looks like if you set Opacity to "near opaque" (maybe 0.9?).

Check the Mask property. It should allow you to create a mask like an alpha channel, with soft borders - though I know its not really what you want...

If you don't want to fire up photoshop, here's a way that you can do it programmatically:

http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/

Specifically the -transparentBorderImage: category method in UIImage+Alpha.h/.m.

Hope this helps others out there.

Thanks http://vocaro.com/trevor/blog!

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