title: Why using self.view.layoutIfNeeded() in Animation cause App Freezing?
body: <p>In my App, and once the user enters to it, I have too many animations on the dashboard the occurs once only -i.e when the user enter the app for the first time - </p>
  
  <p>I perform the animation like this way in <strong>viewDidAppear</strong> in call <code>upperViewAnimation()</code> function which calls another animation functions, to be more clear this is the used code: </p>
  
  <pre><code> func upperViewAnimation() {
  
      contianerTop.constant = 0
      UIView.animateWithDuration(0.45, animations: { () -&gt; Void in
  
          self.view.layoutIfNeeded()
  
          }, completion:{(finished)  in
  
              if finished {
                  if noInternetConnection &amp;&amp; !noInternetConnectionPopup {
                      self.noConnectionViewHeight.constant = 50
                      UIView.animateWithDuration(0.3, animations: {
                      self.view.layoutIfNeeded()
                      })
  
                      noInternetConnectionPopup = true
                      openNoInternetConnection()
                  }
                  else if noInternetConnection {
                      self.noConnectionViewHeight.constant = 50
                      UIView.animateWithDuration(0.3, animations: {
                      self.view.layoutIfNeeded()
                      })
  
                  }
                  else {
                      self.noConnectionViewHeight.constant = 0
                      UIView.animateWithDuration(0.3, animations: {
                      self.view.layoutIfNeeded()
                          }, completion: { (finished) in
                             self.pullToRefreshAction()
                      })
                  }
                  self.notificationButtonAnimationAndMenuButton()
                  self.moreAppsLabel.hidden = false
              }
      })
  }
  
  func pullToRefreshAction() {
      pullToRefreshContainsFailure = false
      addBlurToCellDelegate?.removeBlurFromAllCells()
  
      if firstAppear || userLoggedIn {
          self.firstAppear = false
          userLoggedIn = false
          loadingView2.removeFromSuperview()
          sucessView.removeFromSuperview()
          var viewHeight:CGFloat = 50
          if isiPadFlag {
              viewHeight = 60
          }
          loadingView2 = NSBundle.mainBundle().loadNibNamed("GettingDataView", owner: self, options: nil)[0] as! GettingDataView
          loadingView2.frame = CGRect(x: 0, y: 0, width: screenWidth, height: viewHeight)
          self.noConnectionView.addSubview(loadingView2)
          loadingView2.initView()
          gettingDataForFirstTime = true
  
          if showPullToRefreshBool {
                  self.noConnectionViewHeight.constant = 50
              }
              UIView.animateWithDuration(0.3, animations: {
                  self.view.layoutIfNeeded()
              })
          }
          else {
              self.noConnectionViewHeight.constant = 0
          }
      }  if !gettingData  {
            // I called  requests to get data
  
          }
  }
  </code></pre>
  
  <p>when I perform the previous code my app sometimes freeze, and it seems that the layout NEVER changed (i.e it seems that the app never render the UI )</p>
  
  <p>I wonder if use too many self.view.layoutIfNeeded() cause this problem?</p>
  
  <p>Really I give up on this strange problem, </p>
  
  <p>Please help, </p>
  
  <p>Thanks.</p>