Skip to content

Instantly share code, notes, and snippets.

View zjfjack's full-sized avatar

Jeff Zhang zjfjack

  • Melbourne, Australia
View GitHub Profile
import UIKit
open class LayerView<Layer: CALayer>: UIView {
public final override class var layerClass: Swift.AnyClass {
return Layer.self
}
public final var concreteLayer: Layer {
return layer as! Layer
}
@rpassis
rpassis / ImagePickerHandler.swift
Last active August 27, 2019 10:40
Protocol and extension for handling the presentation of image picker controllers and selection of media
// Since we are unable to extend ObjC protocols in swift, we wrap this around a custom NSObject subclass
// that deals exclusive with handling the image picker delegate methods and chaining the response down to
// the MediaPickerPresenter conforming delegate
class ImagePickerHandler: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
var delegate: MediaPickerPresenter?
let sourceType: UIImagePickerControllerSourceType
let picker = UIImagePickerController()
@zacwest
zacwest / ios-font-sizes.swift
Last active November 8, 2024 02:45
iOS default font sizes - also available on https://www.iosfontsizes.com
let styles: [UIFont.TextStyle] = [
// iOS 17
.extraLargeTitle, .extraLargeTitle2,
// iOS 11
.largeTitle,
// iOS 9
.title1, .title2, .title3, .callout,
// iOS 7
.headline, .subheadline, .body, .footnote, .caption1, .caption2,
]
@PurpleBooth
PurpleBooth / README-Template.md
Last active November 13, 2024 22:21
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@kristopherjohnson
kristopherjohnson / executionTimeInterval.swift
Last active May 29, 2024 19:25
Calculate execution time for a block of Swift code
import QuartzCore
func executionTimeInterval(block: () -> ()) -> CFTimeInterval {
let start = CACurrentMediaTime()
block();
let end = CACurrentMediaTime()
return end - start
}