iOS 剪切圆形图片
2015-12-17 17:31
483 查看
使用Quartz2D来绘制图形
+(UIImage*) circleImage:(UIImage*) image withParam:(CGFloat) inset {
}
通过
+(UIImage*) circleImage:(UIImage*) image withParam:(CGFloat) inset {
UIGraphicsBeginImageContext(image.size); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 40); CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor); CGRect rect = CGRectMake(inset, inset, image.size.width - inset * 2.0f, image.size.height - inset * 2.0f); CGContextAddEllipseInRect(context, rect); CGContextClip(context); [image drawInRect:rect]; CGContextAddEllipseInRect(context, rect); CGContextStrokePath(context); UIImage *newimg = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return newimg;
}
通过
相关文章推荐
- iOS xib文件引入的两种方式
- IOS_AFNetworking
- ios开发同一个版本多次提交不想改变版本号的解决方法
- iOS应用之间的跳转与数据传递
- IOS常用第三方框架
- iOS开发textfield的一些方法汇总
- IOS提醒用户重新授权打开定位功能
- IOS开发银行系统的四舍五入的算法
- ios文件路径
- iOS pop到前一个页面时键盘闪一下的问题
- iOS提醒用户进入设置界面进行重新授权通知定位等功能
- 解决navigationbar颜色不纯问题
- iOS适配 旧项目工程在iOS9下不能正常显示
- iOS中通知机制
- iOS21 广告服务
- JS判断客户端是否是iOS或者Android
- assert 在iOS 中的作用
- iOS分享 - AFNetworking之多图片/文件上传
- IOS开发-通知与消息机制
- iOS 3DES加密解密(一行代码搞定)