gpt4 book ai didi

ios - 约束更改时的自动布局 UIView 不会为 iOS 7 设置动画

转载 作者:行者123 更新时间:2023-12-01 18:12:32 25 4
gpt4 key购买 nike

我正在尝试使用 AutoLayout 从“自下而上”为 View 设置动画。

这在 iOS 8 中效果很好,但是在 iOS 7 中没有动画效果。

这是一个代码片段:

@interface ViewController ()
@property (strong) AViewController *aVC;
@end

@implementation ViewController

- (void)viewDidLoad
{
[super viewDidLoad];
self.aVC = [[AViewController alloc] init];
self.aVC.view.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:self.aVC.view];
[self.aVC.view autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:0];
[self.aVC.view autoSetDimension:ALDimensionHeight toSize:100];
[self.aVC.view autoSetDimension:ALDimensionWidth toSize:320];
NSLayoutConstraint *constraint = [self.aVC.view autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:-100];
[self.view layoutIfNeeded];
[UIView animateWithDuration:2 animations:^{
constraint.constant = -25;
[self.view layoutIfNeeded];
}];

}

我正在使用很棒的 PureLayout类别,轻松添加约束。

project sample on Github - 适用于 iOS 8 模拟器,而不是 iOS 7 模拟器。

关于如何在 iOS 7 上进行这项工作的任何建议?

最佳答案

如果替换 [self.view layoutIfNeeded][self.aVC.view layoutIfNeeded] ,它适用于两个 iOS 版本。虽然我不知 Prop 体原因。

编辑。

请尝试这样的事情。

[self.aVC.view layoutIfNeeded];
[UIView animateWithDuration:2 animations:^{
constraint.constant = -25;
[self.view layoutIfNeeded];
}];

关于ios - 约束更改时的自动布局 UIView 不会为 iOS 7 设置动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27704295/

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