【发布时间】:2017-08-02 23:00:37
【问题描述】:
我试图在初始视图加载后 5 秒后让视图 scrim 淡入视图控制器中的所有内容。这就是我现在所拥有的。
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self setupAlarmPoll];
[self setupTimeLabel];
self.shouldRefresh = YES;
[self refreshSpotifyToken];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(receiveNotification:)
name:@"backHome"
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(receiveNotification:)
name:@"applicationDidEnterBackground"
object:nil];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 5.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[UIView animateWithDuration:2.00 animations:^{
self.scrim.hidden = NO;
}];
});
但是,我没有逐渐淡入。视图刚刚出现。如何在 Objective-c 中完成这个动画?
【问题讨论】:
-
试试
self.scrim.alpha = 1.0; -
在 didLoad 中将 scrim.alpha = 0 设置为 0,在 Animation 部分设置为 1.0
标签: ios objective-c animation