4

How can I draw dots in semi circular pattern in iphone programmatically?

Nassif
  • 1,113
  • 2
  • 14
  • 34
  • Use CoreGraphics. Here is a Tutorial:http://www.raywenderlich.com/32283/core-graphics-tutorial-lines-rectangles-and-gradients – Puneet Sharma Aug 19 '13 at 10:23

2 Answers2

2

I did using the below code

    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;
}
Nassif
  • 1,113
  • 2
  • 14
  • 34
1

you can like this way 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);
}

check out bellow all drawing examples :-

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

Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144