我目前正在尝试使用滑动手势从一个 View 到另一个 View 的动画,这反过来会将 View A 从屏幕向左动画化,然后让 View B 从右侧出现并随之动画化。
这实际上在我的应用程序中起作用,但是当 View 动画而不是 View B 跟随 View A 的边缘并让它们同时移动时, View B 不会移动,直到 View A 的动画完成为止...
这就是代码的样子
- (void)swipedScreen:(UISwipeGestureRecognizer*)gesture
{
if (gesture.direction = UISwipeGestureRecognizerDirectionLeft) {
[UIView animateWithDuration:1.50 animations:^{
// [self.detailViewB.view setAlpha:1.0f];
[self.detailViewB.view setCenter:CGPointMake(CGRectGetMidX(self.view.frame), CGRectGetMidY(self.view.frame))];
[self.detailViewA.view setCenter:CGPointMake(-640, CGRectGetMidY(self.view.frame))];
}];
}
}
如果您想自己编译源代码,这里有一个指向我正在处理的代码的链接。 http://dl.dropbox.com/u/53813770/SMPrototypeB.zip
任何帮助将不胜感激。
最佳答案
修复了您的代码并重新上传了项目 here
我所做的更改:
-(void) viewDidLoad
{
[self.detailViewB.view setFrame:CGRectMake(320, 0, self.view.frame.size.width, self.view.frame.size.height)];
}
- (void)swipedScreen:(UISwipeGestureRecognizer*)gesture
{
if (gesture.direction = UISwipeGestureRecognizerDirectionLeft) {
[UIView animateWithDuration:1.50 animations:^{
// [self.detailViewB.view setAlpha:1.0f];
[self.detailViewB.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[self.detailViewA.view setFrame:CGRectMake(-320, 0, self.view.frame.size.width, self.view.frame.size.height)];
}];
}
关于iphone - UIView动画异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10811286/