Skip to content

Instantly share code, notes, and snippets.

//
// Created by Muhammad Ashir Mubeen on 13/07/2022.
//
#if os(iOS) || os(tvOS)
import UIKit
#elseif os(OSX)
import AppKit
#endif
import UIKit
enum AppStoryboard : String{
case Main = "Main"
case PreLogin = "Payment"
var instance : UIStoryboard {
return UIStoryboard(name: self.rawValue, bundle: Bundle.main)
}
func viewController<T>(vc : T.Type) -> T where T: UIViewController{
let identifier = String(describing: T.self)
@joncardasis
joncardasis / UIFont+BestFit.swift
Last active May 11, 2023 03:20
Swift Dynamic Font Size for Bounds
extension UIFont {
/**
Will return the best font conforming to the descriptor which will fit in the provided bounds.
*/
static func bestFittingFontSize(for text: String, in bounds: CGRect, fontDescriptor: UIFontDescriptor, additionalAttributes: [NSAttributedStringKey: Any]? = nil) -> CGFloat {
let constrainingDimension = min(bounds.width, bounds.height)
let properBounds = CGRect(origin: .zero, size: bounds.size)
var attributes = additionalAttributes ?? [:]