Skip to content

Instantly share code, notes, and snippets.

import SwiftUI
extension String: Identifiable {
public var id: String { self }
}
struct CollectionViewSizeKey<ID: Hashable>: PreferenceKey {
typealias Value = [ID: CGSize]
static var defaultValue: [ID: CGSize] { [:] }
import SwiftUI
struct RoundedCorner: Shape {
var radius: CGFloat = .infinity
var corners: UIRectCorner = .allCorners
func path(in rect: CGRect) -> Path {
let path = UIBezierPath(roundedRect: rect, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
return Path(path.cgPath)
import SwiftUI
struct RoundedCorner: Shape {
var radius: CGFloat = .infinity
var corners: UIRectCorner = .allCorners
func path(in rect: CGRect) -> Path {
let path = UIBezierPath(roundedRect: rect, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
return Path(path.cgPath)
enum MySpecialEnum {
case someCase
case someCaseWithAssociatedData(String)
case someCaseWithNumbers(Int)
}
func handleSpecialEnum(_ value: MySpecialEnum) {
switch value {
case .someCase:
public final class BlurryBackgroundButton: UIControl {
public init() {
super.init(frame: .zero)
setup()
}
public override init(frame: CGRect) {
super.init(frame: frame)
setup()
/**
This sample code is available under the MIT license.
*/
@available(iOS 12.0, *)
public final class ShortcutManager {
/**
This enum specifies the different intents available in our app and their various properties for the `INIntent`.
Replace this with your own shortcuts.
//
// ParallaxHeader.swift
// MealPlanUI
//
// Created by Simon Ljungberg on 2017-11-15.
// Copyright © 2017 Filibaba. All rights reserved.
//
import Foundation
import UIKit

Keybase proof

I hereby claim:

  • I am simme on github.
  • I am simmelj (https://keybase.io/simmelj) on keybase.
  • I have a public key ASADuVzngznoJZLHqpiRN_Xf1Ky1CmfWOBrffVicRrhCRAo

To claim this, I am signing this object:

@simme
simme / Label.swift
Created May 16, 2018 09:09
A `UILabel` subclass that allows content padding.
// MIT License applies.
import UIKit
/**
A `UILabel` subclass that provides a way of adding padding to the label.
*/
open class Label: UILabel {
/// The amount of padding for each side in the label.
//
// UIView+AutoLayout.swift
//
// Created by Simon Ljungberg on 28/12/16.
// Copyright © 2016 Redhill. All rights reserved.
//
import UIKit
public extension UIView {