【问题标题】:iPhone - having a Ripple effect on a UIImageViewiPhone - 在 UIImageView 上产生波纹效果
【发布时间】:2011-05-12 05:08:54
【问题描述】:

我试图在 imageView 被触摸时创建类似波纹的效果,但是我不明白如何为 windows 实现 OpenGL 并将其移植到 iOS。我曾尝试使用http://www.codeproject.com/KB/openGL/dsaqua.aspx 和 cocos2d,但我发现后者完全令人困惑。有人愿意提供一些建议或可以指出我正确的方向吗?

非常感谢!

【问题讨论】:

  • 嘿!穆勒你是如何完成涟漪效应的。请你帮助我好吗?我已经尝试过 Jhaliya 给出的以下答案,但无法获得涟漪。

标签: iphone uiimageview image-manipulation ripple


【解决方案1】:

如果你想在视图上产生涟漪效果,你可以使用它。

    CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:2.0f];
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
[animation setType:@"rippleEffect" ];
[myView.layer addAnimation:animation forKey:NULL];

【讨论】:

  • +1,动画像魅力一样工作......!,如果你帮助我在用户触摸位置应用涟漪效果是可能的怎么办?
  • 这段代码 AppStore 安全吗?我会因为使用它而被拒绝吗?
  • 我使用这个代码它工作......但我想在 imageview 上的触摸点上获得动画......我该怎么做?
  • 它是私有的,但苹果无法检测到.. 我不会随它一起发货
  • 如果您使用的是 ARC,请将 UIViewAnimationcurveEaseInOut 替换为 [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]
【解决方案2】:

在 iPhone 中使用下面的涟漪效果

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:(UIViewAnimationTransition) 110 forView:view cache:NO];
[UIView commitAnimations];

更多效果可以查看这个链接:

http://www.iphonedevwiki.net/index.php?title=UIViewAnimationState

【讨论】:

  • 我不会依赖这个,这不是一个真正的枚举,而只是一个无证数字是有原因的!
  • @JustSid :同意你的观点,因为它目前不在文档中,所以当它可用时,使用数字值没有害处。
  • 有没有办法让它只在图像的某个区域产生这种效果?我是通过点击手势完成的,但它会将其应用于整个图像。
  • 抱歉,我无法使用此代码获得任何动画效果。我刚刚将视图替换为 self.myImageView。还需要更改吗???
  • 我使用此代码但无法获得任何动画......我只是将“view”替换为“imgView”。如果您对此有任何想法,请帮助我
【解决方案3】:

@Rony 在 Swift 中的 CATransition Ripple

let animation = CATransition()
animation.delegate = self
animation.duration = 2
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
animation.type = "rippleEffect"
myView.layer.addAnimation(animation, forKey: nil)

(这是我的第一篇文章,如果我做对了,那就别想了:D)

【讨论】:

    【解决方案4】:

    对于 Swift 3.0

    let animation = CATransition()
    animation.delegate = self
    animation.duration = 5.0
    animation.timingFunction = CAMediaTimingFunction(name : kCAMediaTimingFunctionEaseInEaseOut)
    animation.type = "rippleEffect"
    viewForAnimation.layer.add(animation, forKey: nil)
    

    【讨论】:

      【解决方案5】:

      我已经尝试过上述代码,但没有一个能完美运行。找出以下源代码。 https://github.com/willstepp/gl_image_ripple

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-07-22
        • 1970-01-01
        • 1970-01-01
        • 2021-12-17
        • 2017-05-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多