Round-Button

About making round button in swift

Imagem de capa

Code

Create an new Swift File with Button.swift in your project folder

import UIKit
@IBDesignable
class Button: UIButton {
    @IBInspectable var cornerRadius: CGFloat = 0 {
        didSet{
            self.layer.cornerRadius = cornerRadius
        }
    }
    @IBInspectable var borderWidth: CGFloat = 0 {
        didSet{
            self.layer.borderWidth = borderWidth
        }
    }
    @IBInspectable var borderColor: UIColor = UIColor.clear {
        didSet{
            self.layer.borderColor = borderColor.cgColor
        }
    }

}

Select the button

Add class ‘Button’ in Editor Section

Set Property Corner Radius to value

eg. 9

Done

Want to see something else added? Open an issue.