我是ios开发的新手并尝试使用代码过滤器......
imgAnimation=[[UIImageView alloc]initWithFrame:frame];
imgAnimation.animationImages=_arrimg;
//animationImages=animationImages;
imgAnimation.contentMode=UIViewContentModeScaleAspectFit;
imgAnimation.animationDuration = 2.0f;
imgAnimation.animationRepeatCount = 0;
[imgAnimation startAnimating];
[self.view addSubview:imgAnimation];
我的动画工作正常,但我怎样才能应用像sepia, grey scale
这样的过滤器我找到了很多教程,但是对于单张图片有点帮助???
答案 0 :(得分:0)
基本上你必须使用过滤器预先加载所有图像。然后将它们加载到数组并将其设置为animationImages属性。
要获取各种过滤器,您可以从github
中引用此项目答案 1 :(得分:0)
示例代码:
+(UIImage *) applyFilterToImage: (UIImage *)inputImage
{
CIImage *beginImage = [CIImage imageWithCGImage:[inputImage CGImage]];
CIContext *context = [CIContext contextWithOptions:nil];
CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone" keysAndValues: kCIInputImageKey, beginImage, @"inputIntensity", [NSNumber numberWithFloat:0.8], nil];
CIImage *outputImage = [filter outputImage];
CGImageRef cgimg = [context createCGImage:outputImage fromRect:[outputImage extent]];
UIImage *newImg = [UIImage imageWithCGImage:cgimg];
CGImageRelease(cgimg);
return newImg;
}
答案 2 :(得分:0)