【发布时间】:2015-02-26 13:11:52
【问题描述】:
我正在尝试使用 AutoLayout 从“自下而上”为视图设置动画。
这在 iOS 8 中效果很好,但在 iOS 7 中却没有动画效果。
这是一个代码sn-p:
@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 上进行这项工作的任何建议?
【问题讨论】:
标签: ios iphone ios7 ios8 autolayout