title: iOS set the autolyout in the animation view comply with all the device
body: <p>I have a question is about the autoLayout in iOS. </p>
  
  <p>I was research long weeks, but I still not reach to my need action. /  \</p>
  
  <p>I was build a animation view(container view). There have a click button in the container view.</p>
  
  <p>Init status like these below photo:
  <img src="https://i.stack.imgur.com/TC5Kr.png" alt="enter image description here"></p>
  
  <p>The the click button, the container view will use animate (slide) to the bottom button upper. </p>
  
  <p>And the container will cover the white part(bottom button upper part).</p>
  
  <p>final wish like below:</p>
  
  <p><img src="https://i.stack.imgur.com/twsz3.png" alt="enter image description here"></p>
  
  <p>And click the button at the container view. It will collapse the view back to the the init state.</p>
  
  <p>I can write the code to control the constraint about the contaienr view.</p>
  
  <pre><code> - (IBAction)slideBtnAction:(id)sender {
       if (isContainerOpen) {
      // 100 is for user click region
      // it is slide view action (close)
      [self replaceTopConstraintOnView:self.containerView withConstant: -self.containerView.frame.size.height + 40];
  } else {
      // it is slide view action(open)
           [self replaceTopConstraintOnView:self.containerView withConstant:           self.containerView.frame.size.height - _btmBtn1.frame.size.height - 40];
  }
  
  [self animateConstraints];
  isContainerOpen = !isContainerOpen;
  
   }
  
   - (void)replaceTopConstraintOnView:(UIView *)view withConstant:(float)constant
   {
       [self.view.constraints enumerateObjectsUsingBlock:^(NSLayoutConstraint *constraint, NSUInteger idx, BOOL *stop) {
      if ((constraint.firstItem == view) &amp;&amp; (constraint.firstAttribute == NSLayoutAttributeTop)) {
          constraint.constant = constant;
      }
  }];
   }
  
   - (void)animateConstraints
   {
  [UIView animateWithDuration:0.5 animations:^{
      [self.view layoutIfNeeded];
  }];
   }
  </code></pre>
  
  <p>But the station is the container view fix the height and the animation can't slide to the correct position at the bottom upper position(cover white part).</p>
  
  <p>I want to the container view can comply with all the iOS device. So the container view will dynamic height.</p>
  
  <p>But I don't know how to set the container view heigh in the slide station.(the fix heigh I was implement in these code.)</p>
  
  <p>Have anyone can help me how to achievement the effect?</p>
  
  <p>Because I have set some autolayout in the storyboard. </p>
  
  <p>So I up my simple project to the github<a href="https://github.com/dickfala/slideTest.git" rel="nofollow noreferrer">[here]</a>.</p>
  
  <p>Please give me some hint and tutor , thank you very much..</p>
  
  <p>---------------------edit-----------</p>
  
  <p>for @YuviGr</p>
  
  <p>If I change the constraint (use your suggestion)</p>
  
  <pre><code> // it is slide view action(open)
   [self replaceTopConstraintOnView:self.containerView
     withConstant: self.containerView.bounds.size.height - _btmBtn1.bounds.size.height];
  
   - (void)replaceTopConstraintOnView:(UIView *)view withConstant:(float)constant
   {
       [self.view.constraints enumerateObjectsUsingBlock:^(NSLayoutConstraint *constraint, NSUInteger idx, BOOL *stop) {
      if ((constraint.firstItem == view) &amp;&amp; (constraint.firstAttribute == NSLayoutAttributeTop)) {
          constraint.constant = constant;
      }
  }];
  </code></pre>
  
  <p>}</p>
  
  <p>When I click the button , the view was not animate to correct position.
  like these
  <img src="https://i.stack.imgur.com/GUGk3.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/zGSu7.png" alt="enter image description here"></p>