我的申请表有问题。我试图让图片显示出来并让它在应用程序中的某些操作完成后2秒后淡出,这一切都正常。但是,当图片在屏幕上并且我旋转我的设备时,图片的位置不会更新到屏幕的新中心,这不是一个大问题,但它看起来非常糟糕。我在下面列出了我的代码。
+(void)fadeOut:(int)type{
//create subImageView
UIImageView *myImageView = nil;
switch (type) {
case 1:
myImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"skipoverlay.png"]];
break;
case 2:
myImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkoverlay.png"]];
break;
case 3:
myImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"endoftask.png"]];
break;
case 4:
myImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"startoverlay"]];
break;
default:
break;
}
UIWindow *mainWindow = [[UIApplication sharedApplication] keyWindow];
myImageView.center=mainWindow.center;
myImageView.tag=11;
[mainWindow insertSubview:myImageView aboveSubview:mainWindow];
//add fade out animation
[UIView beginAnimations: @"Fade Out" context:nil];
// wait for time before begin
[UIView setAnimationDelay:0];
// duration of animation
[UIView setAnimationDuration:2];
myImageView.alpha = 0.0;
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(removeView)];
[UIView commitAnimations];
}