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?
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.
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.
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;
}];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With