随笔分类 -  CoreGraphics

摘要:最近工作中,遇到一个需求,需要把一个UIView对象转成UIImage对象显示。经过网络搜索,找到如下答案:1 -(UIImage*)convertViewToImage:(UIView*)v{2 CGSize s = v.bounds.size;3 UIGraphicsBeginImageContext(v.bounds.size);4 [v.layer renderInContext:UIGraphicsGetCurrentContext()];5 UIImage*image = UIGraphicsGetImageFromCurrentImageConte... 阅读全文
posted @ 2013-11-25 13:25 ubersexual 阅读(658) 评论(0) 推荐(0)
摘要:我知道的实现方法有三种。1、通过image mask来操作,需要添加mask目标图片。2、通过imageview的layer来操作如下代码1 UIImageView * imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"oiuyfdsa.png"]]; 2 imageView.frame = CGRectMake(20.f, 20.f, 100.f, 100.f); 3 imageView.layer.masksToBounds = YES; 4 imageView.layer.corn 阅读全文
posted @ 2013-11-18 14:24 ubersexual 阅读(917) 评论(0) 推荐(0)
摘要:Quartz2D提供了两种渐变填充方法。第一种是使用Quartz自带的Gradient填充方法;第二种是使用自定义的着色器。这里将先描述如何使用CGGradient对象来做渐变填充。 1 // Drawing code 2 3 // 创建Quartz上下文 4 CGContextRef context = UIGraphicsGetCurrentContext(); 5 6 // 创建色彩空间对象 7 CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); 8 9... 阅读全文
posted @ 2013-11-16 00:02 ubersexual 阅读(330) 评论(0) 推荐(0)