Created
April 6, 2015 13:02
-
-
Save yuxiangq/dc9faab124f1eedf82a8 to your computer and use it in GitHub Desktop.
设置约束
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)p_updateConstraints{ | |
[self.contentView removeConstraints:self.contentView.constraints]; | |
NSDictionary *views=@{@"contentLabel":self.contentLabel}; | |
NSMutableArray *constraints=[NSMutableArray array]; | |
//设置水平约束 | |
[constraints addObjectsFromArray:[NSLayoutConstraint | |
constraintsWithVisualFormat:@"H:|-5-[contentLabel]-5-|" | |
options:0 | |
metrics:nil | |
views:views]]; | |
//设置垂直约束 | |
[constraints addObjectsFromArray:[NSLayoutConstraint | |
constraintsWithVisualFormat:@"V:|-5-[contentLabel]-5-|" | |
options:0 | |
metrics:nil | |
views:views]]; | |
[self.contentView addConstraints:constraints]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment