ios - Xcode How to remove image after a number of touches? -



ios - Xcode How to remove image after a number of touches? -

i have touch event animations of 'clouds' using code. working fine want fade/remove clouds after user taps cloud 3 times. want them disappear after 3rd time touched. how do this?

- (void) touchesbegan:(nsset *)touches withevent:(uievent *)event { uitouch *touch = [touches anyobject]; cgpoint touchlocation = [touch locationinview:self.view]; cgrect cloudblrect = [[[self.cloudbl layer] presentationlayer] frame]; if (cgrectcontainspoint(cloudblrect, touchlocation)) { nslog(@"cloudbl tapped!"); cloudblpressed = true; [uiview animatewithduration:1.0 delay:0.0 options:uiviewanimationoptioncurveeaseinout animations:^{ self.cloudbl.center = cgpointmake(200, 600); self.cloudbl.alpha = 0.5; } completion:^(bool finished) { [uiview animatewithduration:2.0 delay:2.0 options: uiviewanimationoptioncurveeaseinout animations:^{ self.cloudbl.center = cgpointmake(100, 700); self.cloudbl.alpha = 0.5; } completion:^(bool finished) { self.cloudbl.alpha = 1.0; }]; } else { nslog(@"cloud not tapped."); return; } if (cloudblpressed) return; }

take variable count , initialize 0. on each touch, increment 1. check in touchgesture method, if count variable equals 2 set alpha cloud 0.0.

something this: in .m file take private int vairiable: int count; in viewdidload: count = 0; cloudview.alpha = 1.0;

- (void) touchesbegan:(nsset *)touches withevent:(uievent *)event { count++; if(count<2) { cloudview.alpha-=0.33; } else { cloudview.alpha = 0.0; } }

add in animation logic. hope helps.

you can set in code this:

- (void) touchesbegan:(nsset *)touches withevent:(uievent *)event { uitouch *touch = [touches anyobject]; cgpoint touchlocation = [touch locationinview:self.view]; cgrect cloudblrect = [[[self.cloudbl layer] presentationlayer] frame]; if(count < 2) { count++; if (cgrectcontainspoint(cloudblrect, touchlocation)) { nslog(@"cloudbl tapped!"); cloudblpressed = true; [uiview animatewithduration:1.0 delay:0.0 options:uiviewanimationoptioncurveeaseinout animations:^{ self.cloudbl.center = cgpointmake(200, 200); // self.cloudbl.alpha -=0.33; } completion:^(bool finished) { [uiview animatewithduration:2.0 delay:2.0 options: uiviewanimationoptioncurveeaseinout animations:^{ self.cloudbl.center = cgpointmake(100, 300); self.cloudbl.alpha -=0.33; } completion:^(bool finished) { // self.cloudbl.alpha = 1.0; }]; }]; } else { nslog(@"cloud not tapped."); return; } if (cloudblpressed) return; } else { [uiview animatewithduration:2.0 delay:2.0 options: uiviewanimationoptioncurveeaseinout animations:^{ self.cloudbl.center = cgpointmake(100, 300); self.cloudbl.alpha =0.0; } completion:^(bool finished) { }]; } }

ios ipad

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -