CGRect frame = CGRectMake(0, 500, self.view.frame.size.width, 45);
UIView *bottom = [[UIView alloc] initWithFrame:frame];
bottom.translatesAutoresizingMaskIntoConstraints = NO;
bottom.backgroundColor = [UIColor blueColor];
[self.view addSubview:bottom];
NSLayoutConstraint *constaint1 = [NSLayoutConstraint constraintWithItem: bottom
attribute: NSLayoutAttributeBottom
relatedBy: NSLayoutRelationEqual
toItem: self.view
attribute: NSLayoutAttributeBottom
multiplier: 1.0f
constant: 0.0f
];
NSLayoutConstraint *constaint2 = [NSLayoutConstraint constraintWithItem: bottom
attribute: NSLayoutAttributeLeading
relatedBy: NSLayoutRelationEqual
toItem: self.view
attribute: NSLayoutAttributeLeading
multiplier: 1.0f
constant: 00.0f
];
[self.view addConstraints:@[constaint1, constaint2]];
NSArray *verticalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:[view(height)]-|"
options:0
metrics:@{
@"height" : @(50)
}
views:@{
@"view" : view
}];
NSArray *horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[view]-0-|"
options:0
metrics:nil
views:@{
@"view" : view
}];
[self.view addConstraints:verticalConstraints];
[self.view addConstraints:horizontalConstraints];