Swift: Giving Context To Cgcontext (Part I)
First encounters alongside CGContext tin flaming hold upwards bewildering. We are presented alongside a lot of code that looks most dissimilar Swift together with to a greater extent than than probable it's inwards a drawRect: method of a UIView. So let's consider the entry signal to drawing: override func drawRect(rect: CGRect) { if permit context = UIGraphicsGetCurrentContext() { } } To explain, during the lifetime of a drawRect: in that location is a CGContext that nosotros tin flaming gain access to past times precisely calling UIGraphicsGetCurrentContext() as demonstrated above. Once nosotros convey the context, which is the house that we're going to hold upwards drawing to, nosotros tin flaming draw. And this drawing volition appear every fourth dimension a stance of our UIView subclass type is presented on screen. Demonstrating CGContext To demonstrate this, the showtime affair we're going to practise is to fill upwards the stance together with to ...