1. 打开开关 ----> 开始布局
1 //1. 打开开关 2 [logoImageView setTranslatesAutoresizingMaskIntoConstraints:NO]; 3 4 //2. 开始布局 5 NSMutableArray *tmpConstraints = [NSMutableArray array]; 6 [tmpConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-70-[logoImageView(==70)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(logoImageView)]]; 7 [tmpConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"[logoImageView(==70)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(logoImageView)]]; 8 [tmpConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"|-40-[forgetPasswordBtn]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(forgetPasswordBtn)]]; 9 [tmpConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[forgetPasswordBtn]-100-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(forgetPasswordBtn)]]; 10 11 [self.view addConstraints:tmpConstraints];