Rounded Corner Button in Swift

It’s very simple to create buttons with rounded corners. Create a button like you normally would in Interface Builder, create an Outlet to it, and then in viewDidLoad, set the attributes like this:

button.layer.borderWidth = 3.0
button.layer.borderColor = UIColor.white.cgColor // Set this to the background color of your button
button.layer.cornerRadius = 8.0