我想在我的應用程序中繪製地圖註釋 - 非常像MapKit的MKAnnotationView,但沒有mapkit。與核心圖形繪製路徑的問題 - iPhone
我有一個視圖輪廓的路徑排序問題,我不知道。結果
圖片:
http://img504.imageshack.us/img504/5458/screenshot20091010at703.png
代碼:
CGFloat minx = CGRectGetMinX(currentBounds);
CGFloat midx = CGRectGetMidX(currentBounds);
CGFloat maxx = CGRectGetMaxX(currentBounds);
CGFloat miny = CGRectGetMinY(currentBounds)+10.0f;
CGFloat midy = CGRectGetMidY(currentBounds)+10.0f;
CGFloat maxy = CGRectGetMaxY(currentBounds)+10.0f;
CGContextBeginPath(currentContext);
CGContextMoveToPoint(currentContext, minx, miny+radius); //before top left arc
CGContextAddArcToPoint(currentContext, minx, miny, midx, miny, radius); //top left
CGPoint points1[] = {
CGPointMake(midx-10.0f, miny),
CGPointMake(midx, 0.0f), //tip of arrow
CGPointMake(midx+10.0f, miny),
};
CGContextAddLines(currentContext, points1, 3);
CGContextAddArcToPoint(currentContext, maxx, miny, maxx, midy, radius); //top right
CGContextAddArcToPoint(currentContext, maxx, maxy, midx, maxy, radius); //bottom right
CGContextAddArcToPoint(currentContext, minx, maxy, minx, midy, radius); //bottom left
CGContextClosePath(currentContext);
CGContextClosePath(currentContext);
CGContextDrawPath(currentContext, kCGPathFillStroke);
//CGContextDrawPath(currentContext, kCGPathEOFillStroke);
這並不是因爲CGContextAddToLines做了一個隱式的'moveto'來取消你的顯式的操作,所以它不起作用。在我的回答中查看我的最新評論。 – 2009-10-10 21:33:08