I am trying to make a simple drawing application for iPhone. Everything worked fine until I tried to execute the layout.
My image should have a fixed 3: 4 aspect ratio, due to the iPhone image format. I also pinned it to the top guide of the layout and to the sides.
The lines I draw are distorted and flow

The closer I get to the lower end of the view, the more the line rises.
I read somewhere that this could be caused by a view getting a height that is not an integer after auto shutdown, which seems true:

I donβt want to hardcode the rectangle for every iOS device.
How can I round this 0.5 high?
Here is my line drawing method:
func drawLineFrom(fromPoint: CGPoint, toPoint: CGPoint) { // 1 UIGraphicsBeginImageContext(tempImageView.frame.size) let context = UIGraphicsGetCurrentContext() tempImageView.image?.drawInRect(CGRect(x: 0, y: 0, width: tempImageView.frame.size.width, height: tempImageView.frame.size.height)) // 2 CGContextMoveToPoint(context, fromPoint.x, fromPoint.y) CGContextAddLineToPoint(context, toPoint.x, toPoint.y) // 3 CGContextSetLineCap(context, CGLineCap.Round) CGContextSetLineWidth(context, brushWidth) CGContextSetRGBStrokeColor(context, red, green, blue, 1.0) CGContextSetBlendMode(context, CGBlendMode.Normal) // 4b CGContextStrokePath(context) // 5 tempImageView.image = UIGraphicsGetImageFromCurrentImageContext() tempImageView.alpha = opacity UIGraphicsEndImageContext() }
I was already trying to switch the antialization, but it didnβt help, it just seemed awful.