@interface ViewController ()
@property(nonatomic, strong) NSLayoutConstraint *topConstraint;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
UIView *view = [[UIView alloc] init];
view.backgroundColor = [UIColor redColor];
[self.view addSubview:view];
[view autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:self.view withOffset:40];
NSLayoutConstraint *topConstraint = [view autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self.view withOffset:40];
self.topConstraint = topConstraint;
[view autoSetDimensionsToSize:CGSizeMake(100, 100)];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[UIView animateWithDuration:1 animations:^{
self.topConstraint.constant = 100;
[self.view layoutIfNeeded];
}];
}