您的位置:首页 > 产品设计 > UI/UE

如何把图片UIImageView某个区域变成透明

2015-06-03 15:31 375 查看
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 64, SIZE.width, SIZE.height)];

// imageView.alpha = 0.8;

[imageView setBackgroundColor:[UIColor grayColor]];

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRect:imageView.bounds];

UIBezierPath *holePath = [UIBezierPath bezierPathWithRect:CGRectInset(CGRectMake(50, 100, SIZE.width-100, SIZE.width-100), 0, 0)];//
[maskPath appendPath:holePath];

CAShapeLayer *mask = [CAShapeLayer layer];
[mask setFillRule:kCAFillRuleEvenOdd];
mask.path = maskPath.CGPath;

[imageView.layer setMask:mask];

[self.view addSubview:imageView];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: