How to Create Round or Round Corner button in swift 4 xcode 9

Bold Swift n Objective-C

Hi, Guys. It is like a Tutorial kind of Pots or Article. I hope it is useful or helpful for all iOS Application developers. Earlier, there is no proper or standard logic for Round corner or Round Buttons in iOS. As a experienced developed, i found a simple logic or method for that, you just go through below given instructions.

To Apply Round Corner or Create Round Button, your Button Height & Width should be Same. (width:100, Height:100)

Declaring or creation Object to UIButton Class Component

  –>  @IBOutlet weak var btnClick: UIButton!

Create Below given Method as Shown…


   func applyRoundCorner(_ object:AnyObject) {

        object.layer.cornerRadius = object.frame.size.width / 2

        object.layer.masksToBounds = true        

    }

Applying Round Corner Follow Below…


        self.applyRoundCorner(btnClick)

 

Check Below gIven Video for Video Tutorial:

 

Sample Source Code: RoundButton by NSP

Leave a Reply