Last active
October 8, 2018 07:22
-
-
Save Gurdeep0602/526f856a5f64630b0f8d4ef69f1c131c to your computer and use it in GitHub Desktop.
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
// | |
// 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