用故事板掩盖的UIView,并给圆角? [英] Use Storyboard to mask UIView and give rounded corners?

查看:336
本文介绍了用故事板掩盖的UIView,并给圆角?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很多问题<一href=\"http://stackoverflow.com/questions/28182206/storyboard-and-autolayout-how-make-a-circular-image\">like这解释如何以编程方式创建一个面具,以一个UIView提供圆角。

Lots of questions like this explain how to programmatically create a mask and provide rounded corners to a UIView.

有没有办法做这一切在故事板?只是问,因为它看起来像创建圆角故事板保持presentation和逻辑之间的划分更清晰。

Is there a way to do it all within Storyboard? Just asking because it seems like creating rounded corners in Storyboard keeps a clearer demarcation between presentation and logic.

推荐答案

是的,我用了很多,但问题是这样已经回答了很多次了。

Yes, I use that a lot but question like this was already answered many times.

但无论如何在Interface Builder。
您需要添加用户自定义运行属性是这样的:

But anyway in Interface Builder. You need to add User Defined Runtime Attributes like this:

layer.masksToBounds Boolean YES
layer.cornerRadius Number {View's Width/2}

和启用

Clips subviews

结果:

在这里输入的形象描述

这篇关于用故事板掩盖的UIView,并给圆角?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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