This file contains 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
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { | |
///Update fonts after dynamic fonts settings was changed | |
if traitCollection.preferredContentSizeCategory != previousTraitCollection?.preferredContentSizeCategory { | |
setFonts() | |
} | |
} | |
private func setFonts() { | |
title.font = UIFont(.h3, .black) | |
subtitle.font = UIFont(.bodyM, .medium) |
This file contains 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
// somewhere here is a declaration of the Font Style parts | |
// https://gist.github.com/popcornomnom/5288be0c003fedff3e9d43c332837dca | |
// and func stringName(_, _) -> String | |
// https://gist.github.com/popcornomnom/1238714fea8d9a8efa109782958a5b99 | |
///optional type in case if you don't want to support scaled font yet | |
private let autoScaleSettings: AutoScaleSettings? = AutoScaleSettings() | |
private class AutoScaleSettings { | |
let mostPopularScreenWidth: CGFloat = 375 |
This file contains 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
// | |
// FontManager.swift | |
// | |
// Created by http://www.popcornomnom.com | |
// Copyright © 2020 Marharyta Lytvynenko. All rights reserved. | |
// | |
import UIKit | |
///optional type in case if you don't want to support scaled font yet |
This file contains 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
#if DEBUG | |
extension UIFont.Size { | |
var debugDescription: String { "\(self)" } | |
} | |
extension UIFont { | |
class func printAllFonts() { | |
let families = UIFont.Family.allCases | |
let sizes = UIFont.Size.allCases |
This file contains 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
//MARK: - Font Parts | |
public extension UIFont { | |
enum Family: String, CaseIterable { | |
case system = ".SFUIText" //".SFUI" | |
case inter = "Inter" | |
} | |
enum CustomWeight: String, CaseIterable { |
This file contains 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
enum Localizable { | |
enum Global: String, LocalizableDelegate { | |
case cancel, close | |
} | |
enum WelcomePage: String, LocalizableDelegate { | |
case title = "welcomeTitle" | |
case ctaButtonTitle = "start" | |
case next |
This file contains 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
Text("my label") | |
.font(.init(.h3, .bold)) |
This file contains 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
//Swift | |
let label = UILabel() | |
label.font = UIFont(.h3, .bold) |
This file contains 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
deinit { | |
stopwatch.stop() | |
} |
This file contains 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
func timeString(from timeInterval: TimeInterval) -> String { | |
let seconds = Int(timeInterval.truncatingRemainder(dividingBy: 60)) | |
let minutes = Int(timeInterval.truncatingRemainder(dividingBy: 60 * 60) / 60) | |
let hours = Int(timeInterval / 3600) | |
return String(format: "%.2d:%.2d:%.2d", hours, minutes, seconds | |
} |