2013-08-19 48 views
2

如何以編程方式在iphone中以半圓圖案繪製點?如何在半圓圖案中繪製點

+0

使用CoreGraphics。這裏是一個教程:http://www.raywenderlich.com/32283/core-graphics-tutorial-lines-rectangles-and-gradients –

回答

1

你可以像這樣Quartz_2D: -

- (void)drawRect:(CGRect)rect { 
    CGContextRef context = UIGraphicsGetCurrentContext(); 
    CGContextSetLineWidth(context, 20.0); 
    CGContextSetStrokeColorWithColor(context, 
     [UIColor blueColor].CGColor); 
    CGFloat dashArray[] = {2,6,4,2}; 
    CGContextSetLineDash(context, 3, dashArray, 4); 
    CGContextMoveToPoint(context, 10, 200); 
    CGContextAddQuadCurveToPoint(context, 150, 10, 300, 200); 
    CGContextStrokePath(context); 
} 

退房波紋管所有的繪圖例子: -

http://www.techotopia.com/index.php/An_iOS_5_iPhone_Graphics_Drawing_Tutorial_using_Quartz_2D

2

我沒有使用下面的代碼

CGContextRef ctx = UIGraphicsGetCurrentContext(); 

float angle = 0; 

float centerX = self.frame.size.width/2; 
float centerY = self.frame.size.width/2; 

float startX = 0.0; 
float startY = 0.0; 
for (int i = 0; i < 8 ; i++) { 

    startX = centerX + cos(angle) * (radius + 50) - 5 ; 
    startY = centerY + sin(angle) * (radius + 50) - 5; 
    CGContextFillEllipseInRect(ctx, CGRectMake(startX, startY, 5, 5)); 
    [[UIColor blackColor] setStroke]; 
    angle-= M_PI/7; 
}