Hi!
The IOS developers are begin to move from the existing Objective-C into Brand New Sift.
In our existing Objective-C we have lot of library to make a customization . Likewise in SWIFT also we can customize the UI. But if googled we can find very few amount of results only.
Now i have create a custom UIButton with Customize Border, Color, Background, Adjust the Button size depends on button Title & Padding around the title of Button.
Swift Class for Custom UIButton
On your UIButton set the class as the Custom UIButton Class That's all..,
Enjoy!..,
Thank You!
Have A Happy Day..,
The IOS developers are begin to move from the existing Objective-C into Brand New Sift.
In our existing Objective-C we have lot of library to make a customization . Likewise in SWIFT also we can customize the UI. But if googled we can find very few amount of results only.
Now i have create a custom UIButton with Customize Border, Color, Background, Adjust the Button size depends on button Title & Padding around the title of Button.
Swift Class for Custom UIButton
import UIKit
import Foundation
class Btn: UIButton {
// init method for UIButton
required init(coder aDecoder: NSCoder) {
// Override the Super class of UIButton
super.init(coder:aDecoder)
// Make padding around the button
self.contentEdgeInsets = UIEdgeInsets(top: 2.0, left: 5.0, bottom: 2.0, right: 5.0)
// To adjust the button size depends on the button Title
self.titleLabel?.adjustsFontSizeToFitWidth = true
// Minimum Label size
self.titleLabel!.minimumScaleFactor = 0.5
// Set the Radius size as 5.0
self.layer.cornerRadius = 5.0;
// Set the Border Color & With
self.layer.borderColor = UIColor.whiteColor().CGColor
self.layer.borderWidth = 1.5
// Set the Background Color
self.backgroundColor = UIColor.redColor()
// Set the Tint Color
self.tintColor = UIColor.orangeColor()
}
} On your UIButton set the class as the Custom UIButton Class That's all..,
Enjoy!..,
Thank You!
Have A Happy Day..,

