使用 Storyboard 遮罩 UIView 并给出圆角? [英] Use Storyboard to mask UIView and give rounded corners?

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

问题描述

很多问题

并启用

剪辑子视图

结果:

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

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.

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}

and enable

Clips subviews

Results:

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

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