Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:

Rita popcornomnom

:octocat:
View GitHub Profile
View FontManagerUsage1.swift
//Swift
let label = UILabel()
label.font = UIFont(.h3, .bold)
View FontManagerSwiftUI.swift
@available(iOS 13.0, *)
extension Font {
init(_ size: UIFont.Size, _ weight: UIFont.CustomWeight) {
self.init(.defaultFamily, size, weight)
}
init(_ family: UIFont.Family = .defaultFamily,
_ size: UIFont.Size, _ weight: UIFont.CustomWeight) {
self.init(UIFont(family, size, weight))
View FontManagerBasic.swift
//
// FontManager.swift
//
// Created by http://www.popcornomnom.com
// Copyright © 2019 Marharyta Lytvynenko. All rights reserved.
//
import UIKit
//MARK: - Font Parts
View FontManager2.swift
//put Family and Weight together
private class func stringName(_ family: Family, _ weight: CustomWeight) -> String {
let fontWeight: String
switch (family, weight) {
case (.inter, .heavy):
fontWeight = CustomWeight.semibold.rawValue
case (.inter, .light):
fontWeight = "\(weight.rawValue)BETA"
default:
fontWeight = weight.rawValue
View FontManager1.swift
//MARK: - Font Parts
public extension UIFont {
enum Family: String, CaseIterable {
case system = ".SFUIText" //".SFUI"
case inter = "Inter"
}
enum CustomWeight: String, CaseIterable {
View StopwatchTutorial3.swift
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
}
View StopwatchTutorial2.swift
import Foundation
class Stopwatch {
// MARK: Private Properties
private let step: Double
private var timer: Timer?
//The time when counting was started
View StopwatchTutorial1.swift
private let step: Double = 1.0 //1 second
private var timer: Timer?
//MARK: Timer lifecycle
private func initTimer() {
let action: (Timer)->Void = { [weak self] timer in
guard let strongSelf = self else {
return
View Localizable.swift
enum Localizable {
enum Global: String, LocalizableDelegate {
case cancel, close
}
enum WelcomePage: String, LocalizableDelegate {
case title = "welcomeTitle"
case ctaButtonTitle = "start"
case next
You can’t perform that action at this time.