I use Masonry library that helps with adding constraints programmatically. Its fine, but now i faced the problem that i need to uninstall and add new constraints after user rotate device from landscape to portrait. I tried rather "brutal" solution, it did change constraints, but, in fraction of second i could see "old" constraints. Is there are easy way to add/remove constraints after user rotate device? That is what i tried (it work, but as i described above in a fraction of second i could see "old" frames):
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)){
[bottomRight mas_updateConstraints:^(MASConstraintMaker *make) {
NSLog(@"We are on landscape");
make.top.equalTo(upperRight.mas_bottom).with.offset(20);
make.left.equalTo(self.view.mas_centerX).with.offset(20);
make.right.equalTo(bottomRightRight.mas_left).with.offset(-20);
make.bottom.equalTo(self.view.mas_bottom).with.offset(-100);
make.width.equalTo(bottomRightRight);
}]; }
else {
NSLog(@"Swapped");
[bottomRight mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(upperRight.mas_bottom).with.offset(200);
make.left.equalTo(self.view.mas_centerX).with.offset(200);
make.right.equalTo(bottomRightRight.mas_left).with.offset(-200);
make.bottom.equalTo(self.view.mas_bottom).with.offset(-200);
make.width.equalTo(bottomRightRight);
}];
}
}