Skip to content

Instantly share code, notes, and snippets.

Rita popcornomnom

Block or report user

Report or block popcornomnom

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View FontManager.swift
//
// FontManager.swift
//
// Created by http://www.popcornomnom.com
// Copyright © 2019 Marharyta Lytvynenko. All rights reserved.
//
import UIKit
import SwiftUI
View FontManager4.swift
extension Font {
public static let title: Font = init.(.h3, .bold)
}
View FontManager3.swift
extension UIFont {
public static let title: UIFont = init.(.h3, .bold)
}
View FontManagerUsage1.swift
//Swift
let label = UILabel()
label.font = UIFont(.h3, .bold)
View FontManagerSwiftUI.swift
@available(iOS 13.0, *)
extension Font {
init(_ size: FontSize, _ weight: FontWeight) {
self.init(.defaultFamily, size, weight)
}
init(_ family: FontFamily = .defaultFamily,
_ size: FontSize, _ weight: FontWeight) {
self.init(UIFont(family, size, weight))
View FontManagerBasic.swift
import UIKit
//MARK: - Font Parts
enum FontFamily: String {
case system = ".SFUIText" //".SFUI"
case inter = "Inter"
//easy to change default app fonts family
static let defaultFamily = FontFamily.inter
View FontManager2.swift
//put Family and Weight together
private func stringName(_ family: FontFamily, _ weight: FontWeight) -> String {
let fontWeight: String
switch (family, weight) {
case (.inter, .heavy):
fontWeight = FontWeight.semibold.rawValue
default:
fontWeight = weight.rawValue
}
let familyName = family.rawValue
View FontManager1.swift
//MARK: - Font Parts
enum FontFamily: String {
case system = ".SFUIText" //".SFUI"
case inter = "Inter"
}
enum FontWeight: String {
case regular = "", medium, light, heavy, bold, semibold, black
}
You can’t perform that action at this time.