Check out the repo instead. The Wisdom of Quinn Now with 100% more archived PDFs.
Informative DevForum posts from everyone's favorite DTS member.
(Arranged newest to oldest)
// | |
// NSThread+blocks.swift | |
// Swift extensions | |
// | |
import Foundation | |
public typealias Block = @convention(block) () -> Void | |
extension NSThread { |
// A view that can flip between its "front" and "back" side. | |
// | |
// Animation implementation based on: | |
// Chris Eidhof, Keyframe animations <https://gist.github.com/chriseidhof/ea0e435197f550b195bb749f4777bbf7> | |
import SwiftUI | |
// MARK: - Chris's keyframe animation design | |
struct Keyframe<Data: Animatable> { |
NSVisualEffectMaterial constants, and the undocumented materials they coorespond to in various modes: | |
+----------------------+-------+----------+------+---------+ | |
| MATERIAL # | LIGHT | LIGHT EM | DARK | DARK EM | | |
+----------------------+-------+----------+------+---------+ | |
| | | | | | | |
| 0 - Appearance Based | 3 | 3 | 5 | 5 | | |
| | | | | | | |
| 1 - Light | 3 | 3 | 3 | 3 | | |
| | | | | | | |
| 2 - Dark | 4 | 4 | 4 | 4 | |
- (UIImage *)pspdf_preloadedImage { | |
CGImageRef image = self.CGImage; | |
// make a bitmap context of a suitable size to draw to, forcing decode | |
size_t width = CGImageGetWidth(image); | |
size_t height = CGImageGetHeight(image); | |
CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB(); | |
CGContextRef imageContext = CGBitmapContextCreate(NULL, width, height, 8, width*4, colourSpace, | |
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little); |
// Paste me into a playground! | |
import Cocoa | |
//: # Basic Setup | |
protocol FancyProtocol { | |
associatedtype Thing | |
func holdPinkyUp(x: Thing) | |
} |
extension UIView { | |
/// Example: call someView.nudge(0, 30) | |
func nudge(_ dx: CGFloat, _ dy: CGFloat) { | |
self.frame = self.frame.offsetBy(dx: dx, dy: dy) | |
CATransaction.flush() | |
} | |
} | |
extension UIView { | |
/// Example: po UIView.root |
var cache = [Int: Int]() | |
let queue = DispatchQueue(label: "cacheQueue", attributes: .concurrent) | |
let iterations = 100000 | |
// In the first run, cache is empty so we're writing each time | |
do { | |
let start = CFAbsoluteTimeGetCurrent() | |
for i in 0 ... iterations { | |
var exists = false | |
queue.sync { |
Check out the repo instead. The Wisdom of Quinn Now with 100% more archived PDFs.
Informative DevForum posts from everyone's favorite DTS member.
(Arranged newest to oldest)