Drawing a transparent circle on top of a UIImage - iPhone SDK

前端 未结 4 533
轮回少年
轮回少年 2021-02-11 07:19

I am having a lot of trouble trying to find out how to draw a transparent circle on top of a UIImage within my UIImageView. Google-ing gives me clues, but I still can\'t find a

4条回答
  •  梦如初夏
    2021-02-11 08:03

    This has got to be the simplest solution:

    CGFloat r = 150;
    
    UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(0,0,1.5*r,1.5*r)];
    lbl.text = @"●";
    lbl.transform = CGAffineTransformMakeTranslation(0.0f, -r/6);
    lbl.textAlignment = UITextAlignmentCenter;
    lbl.backgroundColor = [UIColor clearColor];
    lbl.textColor = [UIColor redColor];
    lbl.font = [UIFont systemFontOfSize:2*r];
    lbl.alpha = 0.5;
    lbl.center = self.view.center;
    [self.view addSubview:lbl];
    

提交回复
热议问题