Masonryを使うとコードでのAutoLayoutの記述が簡単に書けます。
view1には、Storyboardでtop,left,width,heightの制約を設定しており
view2には、left->view1から8,top,width,heightはview1と同じになるように設定してあります。
view1に対して、アニメーション処理を実行することでview2も追従することになります。
MAsonryを使ったアニメーション
- (IBAction)actionAnimationButton:(id)sender {
[UIView animateWithDuration:0.3f
delay:0
options:UIViewAnimationOptionCurveEaseIn
animations:^{
[self.view1 mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(arc4random() % 200 + 100);
make.height.mas_equalTo(arc4random() % 200 + 10);
}];
[self.view layoutIfNeeded];
} completion:^(BOOL finished) {
}];
}