iOS 四周半透明中间圆形全透明View制作

转载自原文:https://blog.csdn.net/tabttoo/article/details/51262456

- (UIImage *)getImage{
    UIGraphicsBeginImageContextWithOptions([UIScreen mainScreen].bounds.size, NO, 1.0);
    CGContextRef con = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(con, [UIColor lightGrayColor].CGColor);//背景色
    CGContextFillRect(con, [UIScreen mainScreen].bounds);
    CGContextAddEllipseInRect(con, CGRectMake(50, 100, 200, 200));
    CGContextSetBlendMode(con, kCGBlendModeClear);
    CGContextFillPath(con);
    UIImage *ima = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return ima;
}

- (void)addImage{

    UIImageView *imageV = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds];

    imageV.image = [self getImage];

    imageV.alpha = 0.5;

    [self.view addSubview:imageV];

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容