2016-10-21 133 views
0

我的目标是让我的按钮看起来像这样:如何制作圆形的椭圆形按钮?

enter image description here

减号按钮四周的黑边。

读了不少帖子后,我看到的大部分的解决方案说使用

layer.cornerRadius = 10.0 

当我这样做,我得到这个:

enter image description here

这轮的边缘,但没有按”给我我想要的目标。

有什么建议吗?

回答

5

斯威夫特3

myButton.layer.cornerRadius = myButton.frame.height/2 

myButton.backgroundColor = UIColor.blue 
myButton.clipsToBounds = true 
myButton.tintColor = UIColor.white 
myButton.setTitle("Connect With Facebook", for: .normal) 

enter image description here

1

你可以做这样的(例如,如果你按钮被称为按钮):

button.layer.cornerRadius = button.bounds.size.height/2.0 
+0

这个问题已经被问一千时间在stackoverflow和我给你一个链接在这里请做一些努力,而不是直接询问博客http://stackoverflow.c OM /问题/ 17401032 /设置cornerradius和-了setBackgroundImage到的UIButton –