【问题标题】:Is it possible to animate a constraint in iOS 7 custom transition是否可以在 iOS 7 自定义过渡中为约束设置动画
【发布时间】:2014-10-15 21:06:34
【问题描述】:

我在示例中似乎只能找到使用变换或正在修改框架。我错过了什么明显的东西吗?目前其他动画(淡入淡出)都工作正常,但约束保持锁定在适当的位置。

快速编码sn-p:

[[customViewController view] layoutIfNeeded];
[UIView animateWithDuration:2 animations:^{

    [[customViewController constraintToAnimate] setConstant:1024];
    [[customViewController view] layoutIfNeeded];

} completion:^(BOOL finished) {
    [transitionContext completeTransition:YES];
}];

【问题讨论】:

  • 我想我应该把它当作不..
  • 我也有同样的问题。有什么帮助或发现吗?
  • 我还没有找到方法 - 我现在要回退到帧动画
  • 感谢您的回复。但我想在我的 UI 中使用自动布局。我可以混合自动布局并同时在过渡中使用帧吗?谢谢。
  • 是的,帧在过渡中工作正常 - 尽管您确实有更多代码要编写。

标签: ios7 autolayout custom-transition


【解决方案1】:

您需要在[[customViewController view] superview] 上致电layoutIfNeeded

【讨论】:

  • 不确定这是否是当时的答案,但它是最有帮助的。 iOS 9 中的测试似乎只允许直接进行约束操作,而不必担心超级视图。
猜你喜欢
  • 2021-06-29
  • 1970-01-01
  • 2015-02-26
  • 2011-06-08
  • 2020-12-06
  • 2020-09-19
  • 2014-09-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多