[英]Animate a UIImageView in iOS 7
好吧,所以我有一些動畫,這些動畫是我從以前的應用程序中提取的,這些動畫都可以在以前的iOS版本上使用,但是iOS 7卻給我帶來了問題
最奇怪的是,這在ViewController.m(主視圖)中可以完美運行,但在game.m中卻不能,因為我現在將其放在viewDidLoad中。 在游戲視圖控制器中,它將加載圖像,但會跳過整個動畫,因此一旦加載視圖,它將以0,0結束。 在視圖控制器中,它將具有3秒的延遲,然后需要10秒鍾進行動畫處理。
UIImage *bg1 = [UIImage imageNamed:@"bgImage.png"];
UIImageView *background = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 568, 320, 568)] initWithImage:bg1];
[self.view addSubview:background];
[UIView animateWithDuration:10.0
delay:3.0
options:UIViewAnimationOptionCurveLinear animations:^{
[background setFrame:CGRectMake(0, 0, background.frame.size.width, background.frame.size.height)];
}
completion:nil
];
所以我的問題是為什么它可以在ViewController中工作而不能在GameViewController中工作呢?我感覺它與UIView有關,所以應該放在那里?
添加到標題
UIImageView *background
修改后的代碼
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UIImage *bg1 = [UIImage imageNamed:@"bgImage.png"];
background = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 568, 320, 568)] initWithImage:bg1];
[self.view addSubview:background];
}
-(void)viewDidAppear:(BOOL)animated {
[UIView animateWithDuration:10.0
delay:3.0
options:UIViewAnimationOptionCurveLinear animations:^{
[background setFrame:CGRectMake(0, 0, background.frame.size.width, background.frame.size.height)];
}
completion:nil
];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.