[英]Auto Layout UIView on constraint change does not animate iOS 7
我正在嘗試使用AutoLayout從“自下而上”動畫化視圖。
這在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類別,以輕松添加約束。
在Github上附加項目示例 -將在iOS 8模擬器上運行,而不是在iOS 7模擬器上運行。
關於如何在iOS 7上執行此操作的任何建議?
如果將[self.view layoutIfNeeded]
[self.aVC.view layoutIfNeeded]
替換為[self.aVC.view layoutIfNeeded]
,則它將在兩個iOS版本上均適用。 我不知道具體原因。
編輯。
請嘗試這樣的事情。
[self.aVC.view layoutIfNeeded];
[UIView animateWithDuration:2 animations:^{
constraint.constant = -25;
[self.view layoutIfNeeded];
}];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.