这里我在 Img 中获取图像但显示 nil 但是当我在 imageview 中打印图像的大小或显示图像(Img)时,我也在 imageview 中获取它的大小和图像,然后当我传递图像的大小(Img)在渲染器中,问题是渲染器是 nil 我也尝试打印日志,但它得到 Null 的帮助将不胜感激
我的代码:
UIImage* Img =_myimage;
UIImageView * imageview = [[UIImageView alloc]initWithImage:Img];
// 我得到的渲染器在 IOS 9.3 中是 nil
UIGraphicsImageRenderer * renderer = [[UIGraphicsImageRenderer alloc] initWithSize:_myimage.size];
// CGSize size=CGSizeMake(Img.size.width,Img.size.height)
NSLog(@"renderer %@",renderer);
UIBezierPath *Path;
Path = [UIBezierPath bezierPath];
Path.contractionFactor = 0.8;
NSValue *mvalue = [_pointsarray objectAtIndex:0];
CGPoint mp2 = [mvalue CGPointValue];
[Path moveToPoint:mp2];
[Path addBezierThroughPoints:_pointsarray];
[Path closePath];
Path.lineWidth = 2;
CAShapeLayer*shapeLayer = [CAShapeLayer new];
shapeLayer.path=Path.CGPath;
[shapeLayer setFillColor:[UIColor redColor].CGColor];
[shapeLayer fillColor];
UIImage shapeImage = [renderer imageWithActions:^(UIGraphicsImageRendererContext _Nonnull context){
[shapeLayer renderInContext: context.CGContext];}];
CIImage * shapeCimage = [[CIImage alloc] initWithImage:shapeImage];
CIFilter * gaussianBlurFilter = [CIFilter filterWithName: @"CIGaussianBlur"];
[gaussianBlurFilter setValue:shapeCimage forKey: @"inputImage"];
[gaussianBlurFilter setValue:@7 forKey:@"inputRadius"];
CIImage * blurredCIImage = [gaussianBlurFilter valueForKey:kCIOutputImageKey];
UIImage * blurredImage = [UIImage imageWithCIImage:blurredCIImage];
[self.view addSubview:imageview];