Skip to content

Instantly share code, notes, and snippets.

View im-jersh's full-sized avatar

Josh O'Steen im-jersh

  • TrackVia
  • Denver, CO
View GitHub Profile
@im-jersh
im-jersh / AutoLayout+PropertyWrapper.swift
Last active July 9, 2022 01:22
A Swift property wrapper to make `translatesAutoresizingMaskIntoConstraints = false` a thing of the past
import UIKit
/// A property wrapper that ensures the wrapped `UIView`'s
/// `translatesAutoresizingMaskIntoConstraints` property is
/// set to `false`
@propertyWrapper
public struct AutoLayout<T: UIView> {
public var wrappedValue: T {
didSet {
@im-jersh
im-jersh / Groupable-Array-Extension.swift
Last active April 20, 2017 17:37
Group elements of array by some property
import Foundation
internal protocol Groupable {
associatedtype GroupingType : Hashable
var groupingKey : GroupingType? { get }
}
extension Array where Element : Groupable {
typealias GroupingType = Element.GroupingType
@im-jersh
im-jersh / iOS Layout Anchors.swift
Last active April 6, 2017 17:19 — forked from jurezove/iOS Layout Anchors.swift
Demonstrating Layout Anchors on iOS
//: Playground - noun: a place where people can play
import UIKit
import PlaygroundSupport
var container = UIView(frame: CGRect(x: 0, y: 0, width: 400, height: 400))
container.backgroundColor = UIColor.green
PlaygroundPage.current.liveView = container
// First label - centered