Skip to content

Instantly share code, notes, and snippets.

View KrisRJack's full-sized avatar
💡
"Here’s to the crazy ones..." – Steve Jobs, 1997

Kristopher Jackson KrisRJack

💡
"Here’s to the crazy ones..." – Steve Jobs, 1997
View GitHub Profile
@KrisRJack
KrisRJack / Array+Extension.swift
Last active February 22, 2025 13:41
Helpful Swift Extensions
import UIKit
extension Array where Element == NSLayoutConstraint {
/// Activates each constraint in an array of `NSLayoutConstraint`.
///
/// Example usage: `[view.heightAnchor.constraint(equalToConstant: 30), view.widthAnchor.constraint(equalToConstant: 30)].activate()`
func activate() {
NSLayoutConstraint.activate(self)
}
@KrisRJack
KrisRJack / ReferenceArray.swift
Last active May 30, 2022 12:12
ReferenceArray
/*
Custom array represented as a reference type.
Unlike NSArray and NSMutableArray, this class
allows for observing changes realtime.
Created by Kristopher Jackson on 5/22/22.
*/
import Foundation
@KrisRJack
KrisRJack / PaddedLabel.swift
Last active January 2, 2021 16:13
Padded label in Swift
//
// Label.swift
// Created by Kristopher Jackson
//
import UIKit
@IBDesignable
class Label: UILabel {
@KrisRJack
KrisRJack / LabeledPickerView.swift
Last active January 2, 2021 16:13
Labeled Picker View In Swift
//
// LabeledPickerView.swift
// Created by Kristopher Jackson
//
import UIKit
protocol LabeledPickerViewDataSource {
func numberOfComponents(in pickerView: UIPickerView) -> Int
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int
@KrisRJack
KrisRJack / Logging.swift
Last active May 30, 2021 20:36
Better logging in Swift
//
// Logging.swift
// Created by Kristopher Jackson
//
import Foundation
class Log {
enum LogType: String {
@KrisRJack
KrisRJack / Window.swift
Last active January 2, 2021 16:14
Application Visible Window
//
// Window.swift
// Created by Kristopher Jackson.
//
import UIKit
let window = UIApplication.shared.connectedScenes
.filter({$0.activationState == .foregroundActive})
.map({$0 as? UIWindowScene})
@KrisRJack
KrisRJack / BlurView.swift
Last active January 2, 2021 16:14
An easy approach to defining a Blur View in Swift
//
// BlurView.swift
// Created by Kristopher Jackson.
//
class BlurView: UIView {
// Can set style of blur after initialization
var style: UIBlurEffect.Style {
get {
@KrisRJack
KrisRJack / Vibration.swift
Last active June 4, 2023 21:54
Haptic feedback in Swift
//
// Vibration.swift
// Created by Kristopher Jackson.
//
import UIKit
import AudioToolbox
enum Vibration {
@KrisRJack
KrisRJack / TextView.swift
Last active May 24, 2022 09:48
TextView with Placeholder
/*
Custom text view containing a placeholder
when text is `nil` (currently not supported by
UITextView). Placeholder can be modified both
programmatically and in the interface builder.
Created by Kristopher Jackson on 5/23/22.
*/
import UIKit