Skip to content

Instantly share code, notes, and snippets.

@ryanrey
ryanrey / Font.swift
Created May 8, 2017 03:41
UIFont Extension
typealias Font = UIFont
public extension Font {
convenience init(_ family: FontFamily = .system, size: CGFloat = 17.0, weight: FontWeight = FontWeight.regular) {
let descriptor: UIFontDescriptor
if family == .system {
descriptor = UIFont.systemFont(ofSize: size, weight: weight.value).fontDescriptor
} else {
var attributes: [String: AnyObject] = [:]
attributes[UIFontDescriptorNameAttribute] = family.name as AnyObject