您的位置:首页 > 移动开发 > IOS开发

ios 图片裁剪加背景光环

2016-04-12 18:53 399 查看
UIImage *image = [UIImage
imageNamed:@"knockwurst.jpg"];

UIGraphicsBeginImageContextWithOptions(CGSizeMake(image.size.width+10,
image.size.height+10),
NO, 0);

NSLog(@"%f,%f",image.size.width,image.size.height);

UIBezierPath *path = [UIBezierPath
bezierPathWithOvalInRect:CGRectMake(0,
0, image.size.width+10, image.size.height+10)];
[path addClip];

[[UIColor
greenColor] set];
[path fill];

UIBezierPath *path1 = [UIBezierPath
bezierPathWithOvalInRect:CGRectMake(5,
5, image.size.width, image.size.height)];
[path1 addClip];
[image drawAtPoint:CGPointMake(5,
5)];

UIImage *image1 =
UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

UIImageView *view = [[UIImageView
alloc]initWithFrame:CGRectMake(50,
300, 200,
200)];

view.image = image1;

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