Created
December 15, 2014 13:28
-
-
Save jimmyhillis/dfb8711dc696246f817e to your computer and use it in GitHub Desktop.
UIFont+CustomFont.swift
This file contains hidden or 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: String) -> UIFont { | |
switch(style) { | |
case UIFontTextStyleBody: | |
return UIFont.systemFontOfSize(17) | |
case UIFontTextStyleHeadline: | |
return UIFont.boldSystemFontOfSize(17) | |
case UIFontTextStyleSubheadline: | |
return UIFont.systemFontOfSize(15) | |
case UIFontTextStyleFootnote: | |
return UIFont.systemFontOfSize(13) | |
case UIFontTextStyleCaption1: | |
return UIFont.systemFontOfSize(12) | |
case UIFontTextStyleCaption2: | |
return UIFont.systemFontOfSize(11) | |
default: | |
return UIFont.systemFontOfSize(17) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment