利用CAShapeLayer創建圓形圖片
2017-06-29 本文已影响0人
夏至末Kara
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
imageView.image = [UIImage imageNamed:@'1'];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:imageView.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:imageView.bounds.size];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init]; //设置大小
maskLayer.frame = imageView.bounds; //设置图形样子
maskLayer.path = maskPath.CGPath;
imageView.layer.mask = maskLayer;