I created a class that draws a coffee mug using the code that I imported from PaintCode, and I applied this class to the view. Using @IBDesignable, I can see in my storyboard that the circle is drawn inside the view, however the overall shape is too large. I could redraw the form in the code to fit the current size of the view, but there is no way to scale the shape after drawing it, so when my view resizes on different devices, does the form scale correctly?
I looked through CGContextScaleCTM(aRef, <#sx: CGFloat#>, <#sy: CGFloat#>)but not sure how to convert CGRectmy view boundsto the right scale factor
I did not want to publish all this, but my drawing code starts as follows
bezierPath.moveToPoint(CGPointMake(64.8, 52.81))
bezierPath.addCurveToPoint(CGPointMake(58.89, 43.44), controlPoint1: CGPointMake(64.21, 48.28), controlPoint2: CGPointMake(62.11, 44.95))
bezierPath.addCurveToPoint(CGPointMake(56.82, 42.76), controlPoint1: CGPointMake(58.24, 43.13), controlPoint2: CGPointMake(57.55, 42.9))
It goes on then
bezierPath.closePath()
bezierPath.miterLimit = 4
bezierPath.usesEvenOddFillRule = true;
Then there are two more pieces of drawing code for drawing two small lines for coffee steam. I add these two paths to the original bezierPath, then set the fill color and fill the entire shape.
source
share