图像圆角消失的 Interface Builder UIButton
使用 Interface Builder,我有一个 UIView,其中有许多 UIButton 作为子视图。在 IB 中,所有按钮类型都设置为圆角矩形,并且每个按钮都使用图像下拉框中的图像。图像是正方形的,圆角矩形 UIButton 的大小与图像相同。这些图像是 png 的,它们来自黑白照片。
问题是 UIButton 圆角消失了,IB 中的所有内容都是方形的,并且在模拟器下运行时。(还没有硬件)我希望按钮 drawRect 能够裁剪图像并保留圆角矩形外观。有办法做到这一点吗?在IB?
感谢您的帮助。
Using Interface Builder I have a UIView with a number of UIButtons as subviews. In IB all of the button types are set to Rounded Rect and each button uses an image from the image drop down box. The images are square and the size of the rounded rect UIButton is the same as image. The images are png's and they are from b&w photo's.
The issue is the UIButton rounded corners are gone and everything is square in IB and when running under the simulator.(no hardware yet) I was hoping the button drawRect would crop the image and preserve the rounded rect look. Is there a way to do this? in IB?
Appreciate the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保在 IB 中选中剪辑子视图。它位于“视图”部分下的“属性检查器”中。
Make sure that Clip Subviews are checked in IB. It's in the Attributes Inspector under the View section.