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

前端 未结 4 549
轮回少年
轮回少年 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:05

    Easiest way is simply to create a semi-transparent square UIView, then set the cornerRadius of its layer to be half of its width/height. Something like:

    UIView *squareView = [[UIView alloc] initWithFrame:CGRectMake(0,0,100,100)];
    squareView.alpha = 0.5;
    squareView.layer.cornerRadius = 50;
    ...
    [squareView release];
    

提交回复
热议问题