利用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;    
上一篇 下一篇

猜你喜欢

热点阅读