How to unhide view with animations

后端 未结 4 693
孤街浪徒
孤街浪徒 2021-02-19 03:47

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?

4条回答
  •  温柔的废话
    2021-02-19 04:15

    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;
    }];
    

提交回复
热议问题