How to make a rounded oval button?

流过昼夜 提交于 2019-12-20 03:23:04

问题


My goal is to make my button look like this:

minus the black edges around the button.

After reading quite a few posts, I see most solutions saying to use

layer.cornerRadius = 10.0

When I do that I get this:

It rounds the edges, but doesn't give me my desired goal.

Any suggestion?


回答1:


Swift 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)




回答2:


You Can do it like this (For Example if you button is called button):

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


来源:https://stackoverflow.com/questions/40185419/how-to-make-a-rounded-oval-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!