Slide 42
Slide 42 text
UIPatternCGColorΛ࡞Δ
let drawPattern: CGPatternDrawPatternCallback = { info, context in
let subunit = CGFloat(20.0)
context.setFillColor(red: 0.5, green: 0, blue: 0, alpha: 1)
context.fill(CGRect(x: 0, y: 0, width: subunit, height: subunit))
context.setFillColor(red: 1, green: 0.3, blue: 0.3, alpha: 1)
context.fill(CGRect(x: subunit, y: subunit, width: subunit, height: subunit))
context.setFillColor(red: 0.7, green: 0.3, blue: 0, alpha: 1)
context.fill(CGRect(x: 0, y: subunit, width: subunit, height: subunit))
context.setFillColor(red: 0.7, green: 0.3, blue: 0, alpha: 1)
context.fill(CGRect(x: subunit, y: 0, width: subunit, height: subunit))
}
var callbacks = CGPatternCallbacks(version: 0, drawPattern: drawPattern, releaseInfo: nil)
let pattern = CGPattern(info: nil, bounds: CGRect(x: 0, y: 0, width: 1, height: 1), matrix:
CGAffineTransform(a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0), xStep: 40, yStep: 40,
tiling: .constantSpacing, isColored: true, callbacks: &callbacks)!
let color = UIColor(cgColor: CGColor(patternSpace: CGColorSpace(patternBaseSpace: nil)!, pattern:
pattern, components: [1, 1, 1, 1])!)
ࣈదͰ͢
42