JSA986
JSA986

Reputation: 5936

Why is my whole view animating rather than just my UIImage View

Im making a custom alert in storyboards by overlaying a UIImage over my entire view alpha set .5 then another UIImage over that, set initially to hidden.

an IBAction then sets these to hidden = NO

I have then animated this to simulate the AlertView 'bounce" with some code from another post on here.

.m under IBAction

tint.hidden = NO; <<tint image

storm.hidden = NO; << my image view

mybtn.hidden = NO; << button to dismiss the view



self.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);
self.view.alpha = 1.0;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(bounce1AnimationStopped)];
self.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
[UIView commitAnimations];


[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(bounce2AnimationStopped)];
self.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);
[UIView commitAnimations];



[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
self.view.transform = CGAffineTransformIdentity;
[UIView commitAnimations];

The problem is the WHOLE view animates and bounces inc the view controller underneath, I only want the UIImage storm to animate and not the whole screen.

So far I tried changing Self to my UIImage, and also changing UIView to UIImageview

Now im out of ideas

Upvotes: 0

Views: 106

Answers (1)

Dominik Hadl
Dominik Hadl

Reputation: 3619

What object is storm? Is it an UIImage or UIImageView?

If it is UIImageView, then just swap all lines from this:

self.view.transform

to this:

self.storm.transform

Also don't forget on the .alpha setting, change it to storm also :)

And that should do the trick.

Upvotes: 1

Related Questions