美文网首页ios开发记录
iOS 四周半透明中间圆形全透明View制作

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

作者: selice | 来源:发表于2019-07-25 15:50 被阅读0次

转载自原文: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];

}

相关文章

网友评论

    本文标题:iOS 四周半透明中间圆形全透明View制作

    本文链接:https://www.haomeiwen.com/subject/ejvhrctx.html