【发布时间】:2011-10-02 15:05:18
【问题描述】:
以this 为例。
当我为 tabBarController 制作动画时,我正在为 PhotoViewerViewController 的框架制作动画(用于全屏效果)。 PhotoViewer 使用 uiscrollview 来生成与 Apple 的照片应用程序相同的效果。无论出于何种原因,它有时会与我的 PhotoViewer 框架一起动画,有时则不会。
您可以在第一个示例中看到它在增加帧大小时会跳转,但在减小帧大小(并恢复标签栏)时会很好地动画。
但是在this 示例中,当照片是垂直的时,它会在两个方向上跳跃。
在这两种情况下,如果我用滚动视图放大照片,它会在两个方向上正确动画。
我知道证据在那里,但我无法确定这里发生了什么。
这是我的动画块:
void (^updateProperties) (void) = ^ {
self.navigationController.navigationBar.alpha = hidden ? 0.0f : 1.0f;
self.navigationController.toolbar.alpha = hidden ? 0.0f : 1.0f;
if (self.tabBarController) {
int height = self.tabBarController.tabBar.bounds.size.height;
for(UIView *view in self.tabBarController.view.subviews)
{
int newHeight;
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (UIInterfaceOrientationIsPortrait(orientation)) {
newHeight = hidden ? [[UIScreen mainScreen] bounds].size.height : [[UIScreen mainScreen] bounds].size.height - height;
} else {
newHeight = hidden ? [[UIScreen mainScreen] bounds].size.width : [[UIScreen mainScreen] bounds].size.width - height;
}
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, newHeight, view.frame.size.width, view.frame.size.height)];
}
else
{
CGRect newFrame = CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, newHeight);
[view setFrame:newFrame];
// update our VC frame with animation
[self.view setFrame:newFrame];
}
}
}
};
代码改编自 SO 上的帖子:UITabBar wont hide
github 上的完整源代码。
【问题讨论】:
标签: objective-c ios ipad uiscrollview