/*设置顶部图片*/
UIImageView *headerView = [[UIImageView alloc] init];
headerView.translatesAutoresizingMaskIntoConstraints = NO;
headerView.image = [UIImage imageNamed:@"btn_scroll_picture"];
[self.view addSubview:headerView];
// 设置水平居中
NSLayoutConstraint *headerViewLayoutConstraint = [NSLayoutConstraint constraintWithItem:headerView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1.0f constant:0.0f];
[self.view addConstraint:headerViewLayoutConstraint];
// 设置上边距
headerViewLayoutConstraint = [NSLayoutConstraint constraintWithItem:headerView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.topLayoutGuide attribute:NSLayoutAttributeBottom multiplier:1.0f constant:20];
[self.view addConstraint:headerViewLayoutConstraint];
// 设置图片宽高
headerViewLayoutConstraint = [NSLayoutConstraint constraintWithItem:headerView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0f constant:[UIImage imageNamed:@"btn_scroll_picture"].size.width];
[self.view addConstraint:headerViewLayoutConstraint];
headerViewLayoutConstraint = [NSLayoutConstraint constraintWithItem:headerView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0f constant:[UIImage imageNamed:@"btn_scroll_picture"].size.height];
[self.view addConstraint:headerViewLayoutConstraint];
/*设置底部按钮*/
UIButton *downButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
downButton.translatesAutoresizingMaskIntoConstraints = NO;
downButton.backgroundColor = [UIColor whiteColor];
downButton.layer.cornerRadius = 5;
downButton.titleLabel.font = [UIFont systemFontOfSize:18];
[downButton setTitle:@"Get Started" forState:UIControlStateNormal];
[self.view addSubview:downButton];
NSArray *downButtonConstraintX = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-15-[downButton]-15-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(downButton)];
[self.view addConstraints:downButtonConstraintX];
id bottomView = self.bottomLayoutGuide;
NSArray *downButtonConstraintY = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(>=0)-[downButton(43)]-(>=28)-[bottomView]-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(bottomView, downButton)];
[self.view addConstraints:downButtonConstraintY];