Skip to content

Instantly share code, notes, and snippets.

View PimCoumans's full-sized avatar
thinking about making coffee

Pim PimCoumans

thinking about making coffee
View GitHub Profile
@PimCoumans
PimCoumans / PrimaryActionHandler.swift
Last active February 8, 2024 09:57
Set primary action handler on UIButton and UIBarButtonItem
import UIKit
public extension UIAction.Identifier {
static let primary = UIAction.Identifier(rawValue: "PrimaryAction")
}
fileprivate extension UIAction {
var handler: UIActionHandler? {
// Tiny bit sketchy: cast UIAction's "handler" value to a ObjC block
typealias ActionHandlerBlock = @convention(block) (UIAction) -> Void
@PimCoumans
PimCoumans / UIView+Blur.swift
Last active September 20, 2024 08:12
Blurring a UIView using CALayer (private API)
// Based on https://github.com/aheze/VariableBlurView/blob/main/Sources/VariableBlurView.swift
import UIKit
public protocol ViewBlurring: UIView {
var blurRadius: CGFloat? { get set }
}
extension UIView: ViewBlurring {
private var blurRadiusKey: String { "inputRadius" }
private var blurFilterName: String { "blurFilter" }