WWDC 2006 2007 2008 2009 2010 2011 2012 2013 2014
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 | |
} | |
} |