Tôi muốn giả mạo cảm giác của màn hình splash chính mờ dần bất cứ khi nào applicationDidBecomeActive
được gọi, nhưng nó không hoạt động. Tôi đang làm gì sai?ios fade out màn hình splash (iphone 5 thân thiện)
- (void)applicationDidBecomeActive:(UIApplication *)application
{
if(IS_IPHONE_5)
splash = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default-568h.png"]];
else
splash = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default.png"]];
[self.window.rootViewController.view addSubview:splash];
[UIView animateWithDuration:0.5
animations:^{
splash.alpha = 0;
}
completion:^(BOOL finished) {
[splash removeFromSuperview];
}];
}
Sau đó, bạn cần xác định phần sau ở đâu đó. Tôi sử dụng dự án .pch
nhưng bạn có thể sử dụng tiêu đề của mình nếu muốn.
#define IS_IPHONE_5 (fabs((double)[ [ UIScreen mainScreen ] bounds ].size.height - (double)568) < DBL_EPSILON)
Rất tiếc, trong trình mô phỏng, hiện tượng giật gân tăng lên mỗi lần, nhưng trong thiết bị chỉ có trên tải ban đầu. tốt để biết. – Jacksonkr