拉伸的形状,以适应框架?

我有一个应用程序,我正在绘制一个特殊的椭圆,我做了一系列的贝塞尔path如下:

CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); CGMutablePathRef pPath_0 = CGPathCreateMutable(); CGPathMoveToPoint(pPath_0, NULL, 515.98,258.24); CGPathAddCurveToPoint(pPath_0, NULL, 515.98,435.61,415.54,515.98,258.24,515.98); CGPathAddCurveToPoint(pPath_0, NULL, 100.94,515.98,0.50,435.61,0.50,258.24); CGPathAddCurveToPoint(pPath_0, NULL, 0.50,80.86,100.94,0.50,258.24,0.50); CGPathAddCurveToPoint(pPath_0, NULL, 415.54,0.50,515.98,80.86,515.98,258.24); CGPathCloseSubpath(pPath_0); CGContextSetRGBFillColor(context, 1.0000, 1.0000, 1.0000, 1.0000); CGContextSetRGBStrokeColor(context,0.0000,0.0000,0.0000,1.0000); CGContextSetLineWidth(context, 1); CGContextSetMiterLimit(context, 10.0000); CGContextAddPath(context, pPath_0); CGContextDrawPath(context, kCGPathFillStroke); CGPathRelease(pPath_0); CGContextRestoreGState(context); 

我想知道,在核心graphics中,有没有什么方法可以把我刚刚创build的形状横向和纵向拉伸,使其完全符合其视图框架? IE浏览器,所以我不必手动进入我所有的观点和价值观,并写在视图边界? 我知道这种形状不会那么困难,但我有一些更复杂的形状,更费时间,我宁愿避免这样做。

发现可以使用:

 CGAffineTransform transform = CGAffineTransformMakeScale(frame.size.width/shapeWidth, frame.size.height/shapeHeight); CGMutablePathRef mutablePathTransform = CGPathCreateMutableCopyByTransformingPath(mutablePath, &transform);