Skip to content

Instantly share code, notes, and snippets.

@Gurdeep0602
Last active October 8, 2018 07:22
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gurdeep0602/526f856a5f64630b0f8d4ef69f1c131c to your computer and use it in GitHub Desktop.
Save Gurdeep0602/526f856a5f64630b0f8d4ef69f1c131c to your computer and use it in GitHub Desktop.
//
// AppFonts.swift
// AppFonts
//
// Created by Gurdeep on 15/12/16.
// Copyright © 2016 Gurdeep. All rights reserved.
//
import Foundation
import UIKit
enum AppFonts : String {
case Helvetica
case Avenir
case Calibri
}
extension AppFonts {
func withSize(_ fontSize: CGFloat) -> UIFont {
return UIFont(name: self.rawValue, size: fontSize) ?? UIFont.systemFont(ofSize: fontSize)
}
func withDefaultSize() -> UIFont {
return UIFont(name: self.rawValue, size: 12.0) ?? UIFont.systemFont(ofSize: 12.0)
}
}
// USAGE : let font = AppFonts.Helvetica.withSize(13.0)
// USAGE : let font = AppFonts.Helvetica.withDefaultSize()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment