【发布时间】:2018-04-09 16:09:49
【问题描述】:
我使用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:上启动它(保持非活动状态)
【问题讨论】:
标签: ios objective-c ios11 uiviewpropertyanimator