在我的iOS应用程序中,我正在尝试执行以下简单动画:
- (void)dismissToolbar
{
NSLog(@"bx: %f by: %f bw: %f bh: %f ",
toolbar.frame.origin.x,
toolbar.frame.origin.y,
toolbar.frame.size.width,
toolbar.frame.size.height);
CGRect tempRect = CGRectMake(0,
toolbar.frame.origin.y + toolbar.frame.size.height,
toolbar.frame.size.width,
toolbar.frame.size.height);
[UIView animateWithDuration:animationsDuration
delay:0
options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowAnimatedContent
animations:^{
NSLog(@"bx: %f by: %f bw: %f bh: %f ",
tempRect.origin.x,
tempRect.origin.y,
tempRect.size.width,
tempRect.size.height);
toolbar.frame = tempRect; // frame value doesn't change here!
}
completion:^(BOOL finished) {
NSLog(@"bx: %f by: %f bw: %f bh: %f ",
toolbar.frame.origin.x,
toolbar.frame.origin.y,
toolbar.frame.size.width,
toolbar.frame.size.height);
NSLog(@"dismiss toolbar complete");
[toolbar setHidden:YES];
isPlayerToolbarActive = NO;
isDissmissingToolbar = NO;
}
];
[[NSNotificationCenter defaultCenter] postNotificationName:@"animateSidePanels" object:@"removingPlayerToolbar"];
}
我从上面的日志中获得以下输出到控制台:
bx:0.000000 by:724.000000 bw:1024.000000 bh:44.000000
bx:0.000000 by:768.000000 bw:1024.000000 bh:44.000000
bx:0.000000 by:724.000000 bw:1024.000000 bh:44.000000
关闭工具栏完成
你可以看到框架的价值没有改变......我真的不明白为什么......
任何形式的帮助都非常感谢!
答案 0 :(得分:2)
您是否使用xib或界面生成器创建了视图?
如果是这样,请尝试选择xib并取消选择使用autoLayout