Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- * 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.
- tried to set needs layout for the superview
- // calculating the new height of the bar
- let portion = Float(self.currentValue!) / Float(self.maxValue!) // portion of max height of the bar
- let newTopConstraint = Float(maxTopConstraint) * portion // the new distance from the top of the superview
- var heightDiff = newTopConstraint - Float(self.barTopConstraint.constant)
- if (heightDiff < 0 ) {
- heightDiff = heightDiff * -1
- }
- UIView.animate(withDuration: 10, animations: {[self] in
- self.barTopConstraint.constant = CGFloat(newTopConstraint)
- self.heightCons.constant += CGFloat(heightDiff)
- self.barView.setNeedsLayout()
- })
- i except the bars to rise in the correct speed.*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement