title: Add UISLider with Autolayout programmatically
body: <p>I'm trying to add a UISlider to my view programmatically including constraints so that its width adapts to the whole screen width.
  This is what I got so far:</p>
  
  <p><img src="https://i.stack.imgur.com/D7RsM.png" alt="enter image description here"></p>
  
  <pre><code>//2 Add UISlider
  self.slider = [[UISlider alloc] init];
  [self.view addSubview:self.slider];
  
  [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.slider
                                                        attribute:NSLayoutAttributeLeft 
                                                        relatedBy:NSLayoutRelationEqual
                                                           toItem:self.view 
                                                        attribute:NSLayoutAttributeLeft 
                                                       multiplier:1 
                                                         constant:0]];
  
  
  [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.slider
                                                        attribute:NSLayoutAttributeRight 
                                                        relatedBy:NSLayoutRelationEqual
                                                           toItem:self.view 
                                                        attribute:NSLayoutAttributeRight 
                                                       multiplier:1 
                                                         constant:0]];
  
  [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.slider
                                                        attribute:NSLayoutAttributeBottom 
                                                        relatedBy:NSLayoutRelationEqual
                                                           toItem:self.view 
                                                        attribute:NSLayoutAttributeBottom 
                                                       multiplier:1 
                                                         constant:0]];
  </code></pre>