Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  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.*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement