UIView的Frame属性未在iOS上的动画内分配 [英] Frame property of UIView is not getting assigned inside animation on iOS
问题描述
在我的iOS应用中,我尝试执行以下简单动画:
In my iOS app I'm trying to perform following simple animation:
- (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"];
}
我将从上面的日志中获得以下输出到控制台:
I'm getting the following output to a console from the logs above:
bx:0.000000通过:: 724.000000 bw:1024.000000 bh:44.000000
bx: 0.000000 by: 724.000000 bw: 1024.000000 bh: 44.000000
bx:0.000000通过:: 768.000000 bw:1024.000000 bh:44.000000
bx: 0.000000 by: 768.000000 bw: 1024.000000 bh: 44.000000
bx:0.000000通过:: 724.000000 bw:1024.000000 bh:44.000000
bx: 0.000000 by: 724.000000 bw: 1024.000000 bh: 44.000000
关闭工具栏完成
如您所见,框架的值没有改变...而且我不太明白为什么...
as you can see the value of the frame didn't change...and I don't really understand why...
任何帮助都将受到高度赞赏!
any kind of help is highly appreciated!
推荐答案
您是使用xib还是interfaceBuilder创建视图的?
Did you create the view with xib's or interfaceBuilder?
如果是这样,请尝试选择xib并取消选择使用autoLayout
If so, try selecting the xib and deselecting use autoLayout
这篇关于UIView的Frame属性未在iOS上的动画内分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!