iPhone - having a Ripple effect on a UIImageView
Asked Answered
F

5

8

I am attempting to create a ripple like effect on an imageView when it is touched down on, however I do not understand how to implement OpenGL for windows and porting it to iOS. I have attempted to use http://www.codeproject.com/KB/openGL/dsaqua.aspx as well as cocos2d however I find the latter completely and utterly confusing. Would anyone be willing to give some suggestions or can point me in the right direction?

Many thanks!

Favela answered 12/5, 2011 at 5:8 Comment(1)
Hey!! Muller how you have done Ripple Effect. Could you please help me? I have tried below answer given by Jhaliya but not able to get ripple.Folsom
P
7

Use below for ripple effect in iPhone

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

For more effects you can check this link :

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

Penneypenni answered 12/5, 2011 at 5:40 Comment(5)
I wouldn't rely on this, there is a reason why this isn't a real enum but just an undocumented number!Rupture
@Rupture : Agree with you because It's not in documentation currently so by the time it's available there is no harm to use the numberic value .Penneypenni
is there a way to have it do this effect in only in a certain area of the image? I am having it done with a tap gesture, however it applies it to the whole image.Favela
Sorry but i m not able to get any animation effect using this code.. I have just replaced view with self.myImageView. Anymore changes required???Sordino
I use this code but cant get any animation....i just replace "view" with "imgView". help me if u have any idea for thisTrillion
M
48

If you want a ripple effect on a view you can use it.

    CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:2.0f];
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
[animation setType:@"rippleEffect" ];
[myView.layer addAnimation:animation forKey:NULL];
Mercerize answered 12/5, 2011 at 5:37 Comment(7)
+1,animation working like charms...!,if u help me for ripple effect apply on user touch location is possible how do?Matriarch
Is this code AppStore safe? Can I get rejected for using this?Penthea
i use this code it working...but i want to get animation on touch point on imageview...how can i do it ?Trillion
it's private, but undetectable by apple.. I wuold not ship with itBluefield
if you are using ARC, replace UIViewAnimationcurveEaseInOut with [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]Vivacity
what makes something undetectable? what makes something private? Just curious before I use this - from an iOS NoobGates
@Trillion you can try this though It is old but it is working fine in iOS 8. github.com/fodormarton/SCWaveAnimationThemis
P
7

Use below for ripple effect in iPhone

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

For more effects you can check this link :

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

Penneypenni answered 12/5, 2011 at 5:40 Comment(5)
I wouldn't rely on this, there is a reason why this isn't a real enum but just an undocumented number!Rupture
@Rupture : Agree with you because It's not in documentation currently so by the time it's available there is no harm to use the numberic value .Penneypenni
is there a way to have it do this effect in only in a certain area of the image? I am having it done with a tap gesture, however it applies it to the whole image.Favela
Sorry but i m not able to get any animation effect using this code.. I have just replaced view with self.myImageView. Anymore changes required???Sordino
I use this code but cant get any animation....i just replace "view" with "imgView". help me if u have any idea for thisTrillion
W
6

@Rony's CATransition Ripple in Swift

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

(This is my first post, so idk if I'm doing it right :D)

Winnick answered 4/3, 2016 at 16:58 Comment(0)
A
3

For 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)
Afb answered 13/10, 2016 at 7:37 Comment(0)
T
1

I have tried above mentioned codes but none work perfectly. Find out following source code. https://github.com/willstepp/gl_image_ripple

Themis answered 27/10, 2014 at 15:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.