This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// library | |
/// a type-erased interface | |
private final class ComparatorHolder<S: Sequence> { | |
private typealias Comparator = (S.Element, S.Element) -> Int | |
private let base: S | |
private var comparators: [Comparator] = [] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIView { | |
func dumpProperties() { | |
print(""" | |
▿ | |
- bounds: \(bounds) | |
- frame: \(frame) | |
- center: \(center) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// test in playground targeting iOS | |
import UIKit | |
import QuartzCore | |
let sRGBSpace = CGColorSpace(name: CGColorSpace.sRGB)! | |
let linearSpace = CGColorSpace(name: CGColorSpace.linearSRGB)! | |
func dumpImageFirstPixel(_ image: UIImage) { | |
guard let cgImage = image.cgImage, | |
let dataBuffer = cgImage.dataProvider?.data as Data?, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class MyTextLabel: UIView { | |
var textLayer = CATextLayer() | |
var textStorage: String = "" { | |
didSet { | |
textLayer.string = textStorage | |
} | |
} |