SHARE
TWEET

Untitled

a guest Jun 16th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. * i have programmed a bars graph when each bar is uiview with constraints on it's height and top constraint to the superview.Once they get values i perform an animation with 10 seconds duration. However, the animation is displayed very fast.
  2.  
  3. tried to set needs layout for the superview
  4.  
  5. // calculating the new height of the bar
  6.  
  7.       let portion = Float(self.currentValue!) / Float(self.maxValue!) // portion of max height of the bar
  8.         let newTopConstraint =  Float(maxTopConstraint) * portion // the new distance from the top of the superview
  9.      
  10. var heightDiff = newTopConstraint - Float(self.barTopConstraint.constant)
  11.         if (heightDiff < 0 ) {
  12.             heightDiff = heightDiff * -1
  13.         }
  14.      
  15. UIView.animate(withDuration: 10, animations: {[self] in
  16.             self.barTopConstraint.constant = CGFloat(newTopConstraint)
  17.             self.heightCons.constant += CGFloat(heightDiff)
  18.            self.barView.setNeedsLayout()
  19.             })
  20.  
  21. i except the bars  to rise in the correct speed.*
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top