如何从左到右将 UIView 移出屏幕,然后从左侧再次将其带入屏幕?!
提前致谢,
最佳答案
您所要做的就是为 View 的 x 原点位置设置动画,并使用设备屏幕来确定多少。所以对于右边的屏幕外:
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
_yourView.frame = CGRectMake(screenRect.size.width, _yourView.frame.origin.y, _yourView.frame.size.width, _yourView.frame.size.height);
}
completion:^(BOOL finished) {
//position screen left after animation
_yourView.frame = CGRectMake(-screenRect.size.width, _yourView.frame.origin.y, _yourView.frame.size.width, _yourView.frame.size.height);
}];
在屏幕上返回 0.0 x 位置或任何您的起点:
[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
_yourView.frame = CGRectMake(0.0, _yourView.frame.origin.y, _yourView.frame.size.width, _yourView.frame.size.height);
}
completion:^(BOOL finished) {
//do something after animation
}];
关于ios - 从左到右将 UIView 移出屏幕并从左再次将其移入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23911468/