Skip to content

Instantly share code, notes, and snippets.

@AttiaMo
Last active December 19, 2017 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AttiaMo/1d6eedab4b3ea279f63b97d4f0f972ba to your computer and use it in GitHub Desktop.
Save AttiaMo/1d6eedab4b3ea279f63b97d4f0f972ba to your computer and use it in GitHub Desktop.
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