0

我想在我的 iPhone 应用程序中创建放大镜类型效果,其中文本在动画中从模糊变为不模糊。谁能想到一种方法来做到这一点?谢谢。

4

2 回答 2

2

在 iOS 6 中,我们终于可以使用 CIFilter 使图像变得模糊。因此,如果您真的想要,您可以制作要模糊的区域的图像,使用 CIFilter 对其进行模糊,然后叠加该模糊图像。然后您可以使用计时器或 CADisplayLink 来请求动画的连续“帧”,并且每次您都会做同样的事情,只是创建一个越来越模糊的图像并显示它。

于 2012-11-02T03:48:56.587 回答
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

于 2012-11-02T03:46:24.530 回答