[UIView transitionWithView:imageView
duration:3.0
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
imageView.image = [UIImage imageNamed:[welcomePhoto objectAtIndex:photoCount]];
}
completion:^(BOOL finish){
}];
When the animation transition at the three second,
imageView can't receive custom gesture,
other times is fine.
How can i fix it? Thanks.
The reason : when UIView animation starts from one point to another, the actual view goes to the new position straight away but it is just hidden. And the view you see moving is just an illusion.
My Given reason is based on paul hagerty's stanford lecture about animation.
The solution to this can be found in other given answer.
Related
My problem is as follows:
An UIImageView's view is going to be changed with an animation, like this:
[UIView transitionWithView:_backgroundArtworkImageView
duration:ANIMATION_DURATION
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
_backgroundArtworkImageView.image = blurredImage;
}
completion:nil];
It works perfectly fine as long as I don't have an UIVisualEffectView over the image view. If using the blur view on top, it results in no animation at all.
I've looked around for a bit and seen that snapshots of views could be something to look into, which also seems to be what Apple uses internally on iOS, for example when bringing up the app switcher; I'm not really sure how exactly to approach it though.
Got it working by taking a snapshot, append it to the superview, hide the real view, change it without animation and then fade the real view in with animation.
__block UIView *snapshot = [_backgroundArtworkImageView snapshotViewAfterScreenUpdates:NO];
[_artworkContainer insertSubview:snapshot belowSubview:_backgroundArtworkImageView];
_backgroundArtworkImageView.alpha = 0.0f;
_backgroundArtworkImageView.image = blurredImage;
[UIView transitionWithView:_artworkContainer
duration:ANIMATION_DURATION
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
_backgroundArtworkImageView.alpha = 1.0f;
}
completion:^(BOOL _) {
[snapshot removeFromSuperview];
snapshot = nil;
}];
Edit: I realized that the blur view was taking a small time to update, but to solve that a new snapshot of the resulting view could be taken and then animated with.
I have implemented a custom segue class for emulating the push transition without navigation bar. The trick is to take to snapshots, add them to the view, replace the viewController, move the snapshots, and finally remove them. This emules a horizontal movement of the viewController, but actually only two UIImagesView are moved.
The following code implements this.
self.destinationImageView.frame = offsetFrameD;
self.sourceImageView.frame = offsetFrameS;
//ViewController replacement
[self.sourceViewController presentModalViewController:self.destinationViewController animated:NO];
//Overpose the snapShot who will simulate the transition between vies.
[destinationView addSubview: self.sourceImageView];
[destinationView addSubview: self.destinationImageView];
[UIView animateWithDuration:1.0
delay:0.0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
self.destinationImageView.frame = self.finalFrameD;
self.sourceImageView.frame = self.finalFrameS;
}
completion:^(BOOL finished) {
[self.sourceImageView removeFromSuperview];
[self.destinationImageView removeFromSuperview];
}];
This code worked with iOS 7. However, when using iOS 8, it seems like the animation is not performed. The destinationImageView and sourceImageView are directly moved to the finalPosition (WITHOUT ANIMATING) and the completion block is not called, so both UIImageView are not finally removed.
Does anyone knows how the animation should be performed with iOS 8?
You should adjust the auto layout constraints and not the frames position. Have a look at this solution. I hope it helps.
UIView transitionWithView & setting the frame no longer works iOS8
Use the following line of code before the start of the animation:
[UIView setAnimationsEnabled:YES];
The problem is when I'm using:
[transLabel.layer removeAllAnimations];
(transLabel is a UILabel that show the information)
After that, I try to add a new animation to this Label
[UIView animateWithDuration:showTime
animations:^{
transLabel.hidden = NO;
transLabel.transform = CGAffineTransformMakeScale(1.5, 1.5);
}
completion:^(BOOL finished) {
transLabel.hidden = YES;
transLabel.transform = CGAffineTransformMakeScale(1.0, 1.0);
}];
But It didn't work anymore, it just work at odd number click. Like, first time it works, and second time it doesn't work, but third time it shows again, forth not, fifth yes..
What I want to do is keep pushing down one button again again again
and the Label is show again again again with animation
Thank you and wait for your answer
If i understood your question correctly, the problem occurs because the presentation layer do all the animations and are the layer that actually performs all the animations. When you cancel an ongoing animation that is reflected upon the presentation layer and not the view layer. Try capturing the changes to the view's layer and see if that helps you in this case:
transLabel.layer.transform = transLabel.layer.presentationLayer.transform;
I just had a similar issue. The problem is that when you stop animation you hide your transLabel.
Show it right after [transLabel.layer removeAllAnimations]; like this:
[transLabel.layer removeAllAnimations];
transLabel.hidden = NO;
Trying here develop a side menu, but i'm facing a problem that i cannot figure out why is happening.
Here is a video sample to show what the problem is:
https://www.dropbox.com/s/i97iigus8gj2sl4/problem_side_menu.mov
When I press the menu button the labels appear first than the view controller, what I want is that the latest follow the transition animation.
I have a container view controller that manages all my views controllers.
Already did some research, but I really don't know which keywords use to find useful information.
I really appreciate any help you can provide.
The animation suggests that you have drawn your buttons on wrong view. Make sure your side menu is owner of your button.
What I would recommend doing is fading the UILabels/UIButtons as the transition happens. So in your code that hides the side menu container, do the animations there.
[UIView animateWithDuration:0.2
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^
{
self.label.alpha = 0.0;
self.button.alpha = 0.0;
}
completion:^(BOOL finished)
{
if (finished)
{
self.label.alpha = 1.0;
self.button.alpha = 1.0;
}
}];
I am trying to animate the alpha value of a MapKit overlay view (specifically an MKCircleView) in iOS 5 using the following code:
-(void) animateCircle:(MKCircle*)circle onMap:(MKMapView*) mapView
{
MKCircleView * circleView = (MKCircleView*) [mapView viewForOverlay:circle];
UIViewAnimationOptions options = UIViewAnimationOptionCurveEaseInOut|UIViewAnimationOptionTransitionNone;
[UIView animateWithDuration:5.0
delay:0.0
options:options
animations:^(void) { circleView.alpha = 0.9; }
completion:^(BOOL finished) {}
];
}
The alpha value of the overlay is changing as I want, but it is jumping there instantaneously rather than animating over the specified duration.
Can anyone suggest what might be wrong? Perhaps animation on overlay views os more complex with blocks than I had thought.
Core Animation has interesting behavior when concurrent animations effect the same view... If you try to animate a view before the view's last animation finished, it will assume you intended the subsequent animation to start from the desired end-state of the initial one. This can result in jumps of frames as well as jumps of alpha values.
In your case, this view is likely being animated by something else. Try locating and removing the other animation / or'ing in UIViewAnimationOptionBeginFromCurrentState to its options.