2013-08-19 2 views
2

아이폰의 반원형 패턴으로 도트를 프로그래밍 방식으로 그릴 수있는 방법은 무엇입니까?반원형 패턴으로 도트를 그리는 방법

당신이 좋아하는 수

+0

CoreGraphics를 사용하십시오. 자습서는 다음과 같습니다. http : //www.raywenderlich.com/32283/core-graphics-tutorial-lines-rectangles-andgradients –

답변

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; 
} 
관련 문제