Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)setConstraintValue:(CGFloat)value forAttribute:(NSLayoutAttribute)attribute animation:(BOOL)animation
- {
- NSArray *constraints = self.view.constraints;
- NSPredicate *predicate = [NSPredicate predicateWithFormat:@"firstAttribute = %d", attribute];
- NSArray *filteredArray = [constraints filteredArrayUsingPredicate:predicate];
- NSLayoutConstraint *constraint = [filteredArray firstObject];
- if (constraint && constraint.constant != value) {
- [self.view removeConstraint:constraint];
- constraint.constant = value;
- [self.view addConstraint:constraint];
- if (animation) {
- [UIView animateWithDuration:1.0 animations:^{
- [self.view layoutIfNeeded];
- }];
- } else
- [self.view layoutIfNeeded];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement