在xib中通过kvc设置button的圆角

通过IB中的User Defined Runtime Attributes,它能够通过KVC的方式,配置一些在IB中不能配置的属性,帮助我们编写更简洁的代码。步骤如下:

1)拖一个button到xib或storyBoard中,设置成custom,设置背景图片

在xib中通过kvc设置button的圆角_第1张图片

2)增加kaypath,通过kvc添加button的layer.cornerRadius与layer.masksToBounds两个属性,如图

在xib中通过kvc设置button的圆角_第2张图片

附一篇通过代码设置圆角属性的链接:(iOS button设置背景图片后,设置cornerRadius没效果的问题 - )

你可能感兴趣的:(在xib中通过kvc设置button的圆角)