Skip to content

Instantly share code, notes, and snippets.

View ericjkunz's full-sized avatar
📱
@ Instagram

Eric Kunz ericjkunz

📱
@ Instagram
View GitHub Profile
@ericjkunz
ericjkunz / isNilOrEmpty.swift
Created April 12, 2019 19:31
Checks for nil or empty Optional<String>
extension Optional where Wrapped == String {
var isNilOrEmpy: Bool {
return self?.isEmpty ?? true
}
}
import UIKit
extension UIColor {
func withBrightnessComponent(_ brightness: CGFloat) -> UIColor {
var h: CGFloat = 0
var s: CGFloat = 0
var a: CGFloat = 0
getHue(&h, saturation: &s, brightness: nil, alpha: &a)
return UIColor(hue: h, saturation: s, brightness: brightness, alpha: a)
}

Best in Class iOS Apps

What things can I quantify that help make an app great?

A summary of: A Best in Class iOS App

The five sections this document covers are:

  1. Accessibility: Designing for everyone is the right thing to do, and the best apps do it and they do it exceptionally well.
  2. Platform Technology: Apple loves it when apps utilize their new APIs to great effect, you should too. It’s not about shoehorning features, it’s about looking at your product and seeing how to utilize iOS around it.
import UIKit
extension UIStackView {
open override var intrinsicContentSize: CGSize {
var size = arrangedSubviews.reduce(CGSize.zero) { size, view -> CGSize in
var size = size
switch axis {
case .horizontal:
size.width += view.intrinsicContentSize.width
func shouldPerformIntensiveUnecessaryAnimation() -> Bool {
return ProcessInfo.processInfo.thermalState != ProcessInfo.ThermalState.critical ||
!ProcessInfo.processInfo.isLowPowerModeEnabled ||
!UIAccessibilityIsReduceMotionEnabled() ||
!(UIDevice.current.batteryLevel < 10 && UIDevice.current.batteryState == .unplugged)
}
import Foundation
extension UnitDuration {
/// the time a beard takes to grow one inch
static var beardInches: UnitDuration {
return UnitDuration(symbol: "beardInches", converter: UnitConverterLinear(coefficient: 2526336))
}
/// the mathematician John von Neumann used the term microcentury to denote the maximum length of a lecture
static var microCenturies: UnitDuration {
infix operator <> { associativity none precedence 135 }
func <>(lhs: Int, rhs: Int) -> CountableRange<Int> {
return (lhs + 1)..<rhs
}