我想從底部移動一個UIView到頂部。 我正在使用iOS SDK 7.0,uiviewcontroller的自動佈局已打開。UIView animateWithDuration沒有得到執行
- (void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.view bringSubviewToFront: myView];
[self moveFromBottom];
}
- (void) moveFromBottom{
[myView setBackgroundColor:[UIColor redColor]];
CGPoint top = myView.center;
top.y = self.view.frame.size.height - top.y;
[UIView animateWithDuration:5.0f
delay:0.0f
options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionBeginFromCurrentState
animations:^{
myView.center = top;
}
completion:^(BOOL finished){
if (finished) {
NSLog(@"finished");
}
}
];
完成塊得到執行並打印完成但UIView不移動。
我也嘗試了動畫幀而不是中心,它也不工作。
但是,如果我嘗試動畫阿爾法相反,它會工作
編輯:如果我在故事板關閉自動佈局也將正常工作。
沒有top.y和myView的center.y很不一樣 – Will