iosswiftbuttonrounded-corners

How to make a rounded oval button?


My goal is to make my button look like this:

enter image description here

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:

enter image description here

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

Any suggestion?


Solution

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

    enter image description here