0

I just want to draw circle with stroke, the code below draws well but it fills the circle.

I do not want it filled. Please help me

    self.circleView = [[UIView alloc] initWithFrame:CGRectMake(10,20,20,20)];
    circleView.alpha = 0.5;
    self.circleView.layer.cornerRadius = 50;
    self.circleView.backgroundColor = [UIColor whiteColor];
erdemgc
  • 1,701
  • 3
  • 23
  • 43

1 Answers1

1

change

self.circleView.backgroundColor = [UIColor whiteColor];

to

self.circleView.backgroundColor = [UIColor clearColor];

and for the border (Stroke) add

self.circleView.layer.borderColor = [[UIColor redColor] CGColor];
self.circleView.layer.borderWidth = 1;
Jonathan Cichon
  • 4,396
  • 16
  • 19
  • it is blank now, nothing appears on the screen – erdemgc Jul 12 '13 at 08:35
  • 1
    oh you have to set the borderWidth also: `self.circleView.layer.borderWidth = 2` – Jonathan Cichon Jul 12 '13 at 08:39
  • then this is the problem, i just want to fill inside of the circle with a number; my code is UILabel* circleLabel = [[UILabel alloc] init]; [circleLabel setText:@"1"]; [circleView addSubview:circleLabel]; but it does not work – erdemgc Jul 12 '13 at 08:51
  • 1
    that's because your circleLabel has a frame (0,0,0,0). You need to use `[[UILabel alloc] initWithFrame:];` insted of `[[UILabel alloc] init];` – Renderhp Jul 12 '13 at 09:34