1
我有一個應用程序在那裏我畫我做了一個特殊的橢圓通過一系列貝塞爾路徑如下:拉伸形狀適合框架?
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);
我想知道,是否有核心圖形的任何方式,我可以把我塑造只是在水平和垂直方向創建並拉伸,使其完美地適合其視圖框架? IE瀏覽器,所以我不必手動進入所有的觀點和價值觀,並在視圖邊界上寫下它們?我知道這個形狀就不會是困難的,但我有一些更復雜的形狀是耗費更多的時間,我寧願避免這樣做的..
爲什麼試圖編輯它以符合框架,如果您最初可以正確繪製它? – 2012-07-13 13:38:11
嘗試[Scale to Fill](http://stackoverflow.com/a/3401284/1059705)和[stretchableImageWithLeftCapWidth:topCapHeight](http://developer.apple.com/library/ios/#documentation/uikit/reference/ UIImage_Class/DeprecationAppendix/AppendixAdepledAPI.html#// apple_ref/occ/instm/UIImage/stretchableImageWithLeftCapWidth%3atopCapHeight%3a) – Bala 2012-07-13 13:39:12
@teodorcarstea - 我有更多的形狀比這更復雜,並有一噸貝塞爾路徑,做起來容易。 – 2012-07-13 13:56:09