I've got a UIView. In function drawRect() I'm drawing a grid on it (vertical and horizontal lines). When I run my app on iPhone 4S - fps is not high enough. Without interface everything is pretty good, but if there is something else on the screen - fps falling down.
I optimized drawing function as much as I could. For example I'm not using CGContextAddLineToPoint(). Instead of it I'm drawing lines using CGContextStrokeRect(), because as I could see - the last one works faster.
Anyway - app still works not fast enough. iPhone 4S and new models have few graphics cores, so I think, that I can speed up my app by drawing grid in another thread
I tried to make it like that
override func drawRect(rect: CGRect) {
let context = UIGraphicsGetCurrentContext()
let screenScale = self.window!.screen.scale
let queue = NSOperationQueue()
queue.addOperationWithBlock() {
drawGrid(context, rect: rect, screenScale: screenScale)
}
}
But for some reason drawn grid is twice smaller then must to be.
So what am I doing wrong and can I draw on UIView in separate thread using Swift? Please, help me to find out.