Author
Travis Kirton


Opacity

Easily change the opacity of a view (and all it’s subviews) by setting it’s associated property:

view.opacity = 0.5

Example

var origin = Point()
let size = Size(canvas.width/10, canvas.height)
let dx = Vector(x: size.width, y: 0)
repeat {
    let r = Rectangle(frame: Rect(origin, size))
    r.opacity = origin.x/canvas.width
    canvas.add(r)
    origin += dx
} while origin.x < canvas.width