如何创建模糊到非模糊的动画

时间:2012-11-02 03:43:44

标签: iphone ios

我想在我的iPhone应用程序中创建放大镜类型效果,其中文本在动画中从模糊变为不模糊。任何人都可以想到这样做的方法吗?感谢。

2 个答案:

答案 0 :(得分:2)

在iOS 6中,我们终于能够使用CIFilter使图像模糊不清。因此,如果你真的想要,你可以制作一个模糊区域的图像,用CIFilter模糊它,并叠加模糊的图像。然后你可以使用计时器或CADisplayLink来询问动画的连续“帧”,每次你做同样的事情,只创建一个越来越少模糊的图像并显示它。

答案 1 :(得分:0)

这是放大镜效果。

- (void)drawRect:(CGRect)rect {
    // here we're just doing some transforms on the view we're magnifying,
    // and rendering that view directly into this view,
    // rather than the previous method of copying an image.
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextTranslateCTM(context,1*(self.frame.size.width*0.5),1*(self.frame.size.height*0.5));
    CGContextScaleCTM(context, 1.5, 1.5);
    CGContextTranslateCTM(context,-1*(touchPoint.x),-1*(touchPoint.y));
    [self.viewToMagnify.layer renderInContext:context];
}

参考:http://coffeeshopped.com/2010/03/a-simpler-magnifying-glass-loupe-view-for-the-iphone

相关问题