Created
August 31, 2015 19:09
-
-
Save JaviLorbada/4c3c07da7d9294fd3d71 to your computer and use it in GitHub Desktop.
Load custom fonts within Swift playgrounds
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
//: Playground - noun: a place where people can play | |
import UIKit | |
let fontURL = NSBundle.mainBundle().URLForResource("PillGothic300mg-bold", withExtension: "ttf") | |
CTFontManagerRegisterFontsForURL(fontURL!, CTFontManagerScope.Process, nil) | |
var pillGothicFontBold = UIFont(name: "PillGothic300mg-bold", size: 30) | |
var attrs = [NSFontAttributeName : pillGothicFontBold!, | |
NSForegroundColorAttributeName : UIColor.whiteColor(), | |
NSBaselineOffsetAttributeName : 0.0] | |
let nameAttrSring = NSAttributedString(string: "Pill Gothic font 300mg Bold size 30", attributes: attrs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Swift 4.1: