UIButton *btn = [[UIButtonalloc] init];
self.button = btn;
self.button.backgroundColor = [UIColoryellowColor];
NSDictionary *views = NSDictionaryOfVariableBindings(_button, self.toview); [self.buttonsetTranslatesAutoresizingMaskIntoConstraints:NO]; [self.toviewaddSubview:self.button];
[self.toviewaddConstraints:[NSLayoutConstraintconstraintsWithVisualFormat:@"V:|-上面的距离-[_button(100)]-下面的距离-|"options:0 metrics:nilviews:views]];
[self.toviewaddConstraints:[NSLayoutConstraintconstraintsWithVisualFormat:@"H:|-左面的距离-[_button(100)]-右面的距离-|"options:0 metrics:nilviews:views]];