-
-
Save kishorek/a901cf0edcdd14da288bdf8a05875086 to your computer and use it in GitHub Desktop.
UIFont+CustomFont.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIFont { | |
class func systemFontOfSize(size: CGFloat) -> UIFont { | |
return UIFont(name: "CustomFont-Regular", size: size)! | |
} | |
func lightSystemFontOfSize(size: CGFloat) -> UIFont { | |
return UIFont(name: "CustomFont-Light", size: size)! | |
} | |
func boldSystemFontOfSize(size: CGFloat) -> UIFont { | |
return UIFont(name: "CustomFont-Bold", size: size)! | |
} | |
func preferredFontForTextStyle(style: UIFontTextStyle) -> UIFont { | |
switch(style) { | |
case UIFontTextStyle.body: | |
return UIFont.systemFont(ofSize: 17) | |
case UIFontTextStyle.headline: | |
return UIFont.boldSystemFont(ofSize: 17) | |
case UIFontTextStyle.subheadline: | |
return UIFont.systemFont(ofSize: 15) | |
case UIFontTextStyle.footnote: | |
return UIFont.systemFont(ofSize: 13) | |
case UIFontTextStyle.caption1: | |
return UIFont.systemFont(ofSize: 12) | |
case UIFontTextStyle.caption2: | |
return UIFont.systemFont(ofSize: 11) | |
default: | |
return UIFont.systemFont(ofSize: 17) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment