我UIViewPropertyAnimator
用于缩小视图控制器的标题:
- (UIViewPropertyAnimator *)headerAnimator {
if (!_headerAnimator) {
_headerAnimator = [[UIViewPropertyAnimator alloc] initWithDuration:2.f curve:UIViewAnimationCurveLinear animations:^{
self.profileImageBorderWidthConstraint.constant = 58.f;
self.profileImageBorderHeightConstraint.constant = 58.f;
self.profileImageBorder.layer.cornerRadius = 29.f;
self.profileImageView.layer.cornerRadius = 25.f;
self.nameLabelTopConstraint.constant = 16.f;
[self.headerView layoutIfNeeded];
}];
}
return _headerAnimator;
}
在滚动时,我设置了fragment
:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat fraction = (scrollView.contentOffset.y / (HeaderHeight-CollapsedHeaderHeight));
self.headerAnimator.fractionComplete = fraction;
}
这工作正常。但是在我从这个控制器中展示另一个UIViewController
并关闭它之后,动画师进入非活动状态并停止响应分数设置。我怎样才能重新启动它?
我已经尝试过的:
- 将我的 animator 属性设置为
nil
, 以便下次重新创建它(崩溃) - 暂停它
-viewWillAppear:
变得活跃(变得活跃,但不动画) - 启动它
-viewWillAppear:
(保持非活动状态)