gpt4 book ai didi

ios - UIView 的框架属性未在 iOS 上的动画内部分配

转载 作者:行者123 更新时间:2023-11-28 22:14:07 25 4
gpt4 key购买 nike

在我的 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

关闭工具栏完成

如你所见,框架的值没有改变......我真的不明白为什么......

非常感谢任何形式的帮助!

最佳答案

您是使用 xib 还是 interfaceBuilder 创建 View 的?

如果是这样,请尝试选择 xib 并取消选择使用 autoLayout

enter image description here

关于ios - UIView 的框架属性未在 iOS 上的动画内部分配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22180969/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com