Skip to content

Instantly share code, notes, and snippets.

@thillsman
thillsman / mstdn-link.php
Last active August 10, 2023 15:55
mstdn.link logic
public extension UIFont {
static func loadGothamNarrow(ofSize size: CGFloat, weight: UIFont.Weight) -> UIFont {
let name: String = {
switch weight {
case .bold, .black, .heavy, .semibold:
return "GothamNarrow-Bold"
default:
return "GothamNarrow-Book"
}
@thillsman
thillsman / CombineBackport.swift
Last active April 13, 2020 17:42
Combine backport
import Foundation
@propertyWrapper
struct Published<Value> {
var projectedValue: Published { self }
var wrappedValue: Value { didSet { valueDidChange() } }
private var observations = MutableReference(
value: List<(Value) -> Void>()
)
@thillsman
thillsman / morphColor.swift
Created November 5, 2016 19:37
Morph from one UIColor to another
extension UIColor {
// First extend UIColor to make it easier to get components out
var coreImageColor: CIColor {
return CIColor(color: self)
}
var components: (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) {
let color = coreImageColor
return (color.red, color.green, color.blue, color.alpha)
}