Friday, February 10, 2017
How to Make UIFont Extension in Swift
Create A Categeory Class
// UIFont+CustomTextFont.swift
extension UIFont
{
class func regularFont(_ size: CGFloat) -> UIFont
{
return UIFont(name: "Lato-Regular", size: size)!
}
class func boldFont(_ size: CGFloat) -> UIFont
{
return UIFont(name: "Lato-Bold", size: size)!
}
class func semiBoldFont(_ size: CGFloat) -> UIFont
{
return UIFont(name: "Lato-Semibold", size: size)!
}
class func lightFont(_ size: CGFloat) -> UIFont
{
return UIFont(name: "Lato-Light", size: size)!
}
}
Usage :
strLabel.font = UIFont.regularFont(18)
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment