// UIView * view = [[ UIView alloc]init];
// [view setTranslatesAutoresizingMaskIntoConstraints:NO];
// view.backgroundColor =[UIColor yellowColor];
// [self.view addSubview:view];
//
// [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[view(160)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(view)]];
// [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[view(160)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(view)]];
//
//
// UIView * viewa = [UIView new];
// [viewa setTranslatesAutoresizingMaskIntoConstraints:NO];
// viewa.backgroundColor =[UIColor redColor];
// [self.view addSubview:viewa];
//
//// [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[viewa(view)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(viewa,view)]];
////
//// [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[view]-10-[viewa]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(viewa,view)]];
//
//
// NSLayoutConstraint * layoutcon = [NSLayoutConstraint constraintWithItem:viewa attribute:NSLayoutAttributeCenterX relatedBy:0 toItem:view attribute:NSLayoutAttributeCenterX multiplier:1.0f constant:0.0f];
// layoutcon.active = YES;
// NSLayoutConstraint * layouty = [NSLayoutConstraint constraintWithItem:viewa attribute:NSLayoutAttributeCenterY relatedBy:0 toItem:view attribute:NSLayoutAttributeCenterY multiplier:1.0f constant:0.0f];
// layouty.active = YES;
//
// NSLayoutConstraint * layout =[NSLayoutConstraint constraintWithItem:viewa attribute:NSLayoutAttributeHeight relatedBy:0 toItem:view attribute:NSLayoutAttributeHeight multiplier:0.5f constant:0.0f];
// layout.active = YES;
//
// NSLayoutConstraint * layoutw =[NSLayoutConstraint constraintWithItem:viewa attribute:NSLayoutAttributeWidth relatedBy:0 toItem:view attribute:NSLayoutAttributeWidth multiplier:1.0f constant:0.0f];
// layoutw.active = YES;
//
// NSLog(@"%lf",view.bounds.size.width);
网友评论