【发布时间】:2017-12-06 10:00:53
【问题描述】:
您好,我想将UIButton 标题标签设为一个圆圈。所以我就这样做了。
btnAttachments.setTitle(strcount, for: .normal)
btnAttachments.setTitleColor(UIColor.white, for: .normal)
btnAttachments.titleLabel?.backgroundColor=com.getRedcolor()
btnAttachments.titleLabel?.font=UIFont.init(name: "Bariol", size: 15)
btnAttachments.titleLabel?.layer.cornerRadius=(btnAttachments.titleLabel?.frame.width)!/2
但它并没有使它成为一个圆圈。看起来这段代码对titleLabel没有影响
更新
请帮帮我 谢谢
【问题讨论】:
-
我想你忘记了 btnAttachments.titleLabel.clipsToBounds = YES
-
我做了,还是一样:(为什么会这样?
-
我认为 btnAttachments.titleLabel?.frame.width = 0。我尝试 btnAttachments.titleLabel?.layer.cornerRadius = 10。它正在工作
-
你想要一个圆形的 UIButton?
-
试试下面的答案,你需要将
masksToBounds设置为true
标签: ios swift3 uibutton uilabel