Skip to content

Instantly share code, notes, and snippets.

@vinczebalazs
vinczebalazs / fonts1.swift
Created February 10, 2020 18:08
fonts part 1
struct Fonts {
enum Font: String {
case poppins = "Poppins"
case quicksand = "Quicksand"
}
}
UIFont(name: Fonts.Font.poppins.rawValue, size: 12)
static func font(_ name: Font, size: CGFloat) -> UIFont {
UIFont(name: name.rawValue, size: size)!
}
Fonts.font(.poppins, size: 12)
enum Weight: String {
case bold = "Bold"
case light = "Light"
case regular = "Regular"
case semiBold = "SemiBold"
}
static func font(_ name: Font, weight: Weight, size: CGFloat) -> UIFont {
UIFont(name: "\(name.rawValue)-\(weight.rawValue)", size: size)!
}
struct Fonts {
enum Weight: String {
case bold = "Bold"
case light = "Light"
case regular = "Regular"
case semiBold = "SemiBold"
}
enum Font: String {
titleLabel?.font = Fonts.font(.quicksand, weight: .bold, size: 14)
func constrainToEdges(of view: UIView) {
translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
leftAnchor.constraint(equalTo: view.leftAnchor),
topAnchor.constraint(equalTo: view.topAnchor),
rightAnchor.constraint(equalTo: view.rightAnchor),
bottomAnchor.constraint(equalTo: view.bottomAnchor)
])
}
@vinczebalazs
vinczebalazs / SheetModalPresentationController.swift
Last active January 9, 2023 23:02
SheetModalPresentationController.swift
import UIKit
final class SheetModalPresentationController: UIPresentationController {
// MARK: Private Properties
private let isDismissable: Bool
private let interactor = UIPercentDrivenInteractiveTransition()
private let dimmingView = UIView()
private var propertyAnimator: UIViewPropertyAnimator!