Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to unhide view with animations

Say I have a hidden view in Xcode for iOS. Now, when I set the view to not hidden (view.hidden=NO), how can I make it so that it now appears, but with animations?

like image 911
Snowman Avatar asked Aug 14 '11 22:08

Snowman


People also ask

How do you animate a view?

You can use the view animation system to perform tweened animation on Views. Tween animation calculates the animation with information such as the start point, end point, size, rotation, and other common aspects of an animation.

How do you animate a view in Swift?

To be exact, whenever you want to animate the view, you actually call layoutIfNeeded on the superview of that view. Try this instead: UIView. animate(withDuration: 0.1, delay: 0.1, options: UIViewAnimationOptions.


1 Answers

What you probably want is not to set view.hidden, but to set view.alpha to 0 (corresponds to hidden = YES) or 1 (hidden = NO).

You can then use implicit animations to show the view, e.g

[UIView animateWithDuration:0.3 animations:^() {
    view.alpha = 1.0;
}];
like image 62
mrueg Avatar answered Nov 15 '22 17:11

mrueg