MonoTouch的:圆角UIImage的便捷方法 [英] MonoTouch: Rounded UIImage Convenience Method
问题描述
有一个MonoTouch的内置方法来圆一个的UIImage
?
Is there a MonoTouch built-in method to round the edges of a UIImage
?
我似乎记得看到过一次。
I seem to remember seeing it once.
推荐答案
四舍五入一个UIImage会产生另一UIImage的。
Rounding a UIImage would produce another UIImage.
如果您创建一个CGContext上渲染与同样大小的原始图像,您可以做到这一点,然后添加一个剪切路径与圆角和渲染你原来的UIImage。
You can do this if you create a CGContext to render into with the same size as the original image, then add a clipping path with the rounded corners and rendering your original UIImage.
然后就可以拉的UIImage出CGContext上的。
Then you can pull the UIImage out of the CGContext.
另一种选择是避免中间步骤,是推动在上下文绘制图形状态,加上圆润路径作为剪贴路径,绘制图像,然后弹出图形状态回到这一点。
Another option is to avoid the intermediate step, is to push the graphics state in your context drawing, add the rounded path as a clipping path, draw the image and then pop the graphics state to go back to this.
您可以看到TweetStation如何使用这为它的玻璃按钮
You can see how TweetStation uses this for its Glass Buttons:
这篇关于MonoTouch的:圆角UIImage的便捷方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!