【发布时间】:2015-08-05 17:40:13
【问题描述】:
我有一个使用尺寸类和自动布局设计的 iOS 应用通用界面。在应用程序中,我通过激活和停用约束来制作基于约束的动画。
以下方法适用于“纵向”,但是,我为“横向”尺寸类安装了可选约束。 在激活/停用动画约束时如何考虑当前的屏幕尺寸等级?
例如,我希望我的动画代码知道它是否应该激活某些约束集,而不是其他约束。
-(NSArray*)layoutFullScreen
{
return @[self.imageYCenterConstraint,
self.imageWidthRatioConstraint];
}
-(NSArray*)layoutWorkingScreen
{
return @[self.textLabelCenterYConstraint,
self.imageHeightRatioConstraint];
}
-(void)doAnimation
{
[NSLayoutConstraint deactivateConstraints:[self layoutFullScreen]];
[NSLayoutConstraint activateConstraints:[self layoutWorkingScreen]];
[UIView animateWithDuration:0.6 delay:0 options:0 animations:^{
[self.view layoutIfNeeded];
} completion:^(BOOL finished) {
}];
}
【问题讨论】:
标签: ios animation autolayout constraints size-classes