Skip to content

Instantly share code, notes, and snippets.

@AttiaMo AttiaMo/Extension.swift
Last active Dec 19, 2017

Embed
What would you like to do?
Extension file
import Foundation
import UIKit
extension UILabel {
var substituteFontName : String {
get { return self.font.fontName }
set {
if self.font.fontName.range(of:"-Bd") == nil {
self.font = UIFont(name: newValue, size: self.font.pointSize)
}
}
}
var substituteFontNameBold : String {
get { return self.font.fontName }
set {
if self.font.fontName.range(of:"-Bd") != nil {
self.font = UIFont(name: newValue, size: self.font.pointSize)
}
}
}
}
extension UITextField {
var substituteFontName : String {
get { return self.font!.fontName }
set { self.font = UIFont(name: newValue, size: (self.font?.pointSize)!) }
}
}
extension UIFont {
class func appRegularFontWith( size:CGFloat ) -> UIFont{
return UIFont(name: Constants.App.regularFont, size: size)!
}
class func appBoldFontWith( size:CGFloat ) -> UIFont{
return UIFont(name: Constants.App.boldFont, size: size)!
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.