Reputation: 2343
I would like to achieve this kind of simple animation effect:
So there are those two Labels (Label: and the 29.8 which is in the ViewController as a @IBOutlet weak var valueLabel: UILabel!
) and UIView under those two (@IBOutlet weak var pm10View: UIView!
)
Unfortunately the CGAffineTransform doesn't work because it resizes this rectangle as an anchor point was in the center. I've tried setting the anchor point to the top-left corner but then the UIView was misplace:
pm10View.layer.anchorPoint = CGPoint(x: 0, y: 0)
UIView.animate(withDuration: 3) {
self.pm10View.transform = CGAffineTransform(scaleX: 2.2, y: 1.0)
}
So how to keep this UIView in the same position as in the Main.storyboard (anchor the top-left and bottom-left corner) and resize only Y value. While the UIView is under the UILabel does it require to be in Stack View or something to keep everyithing in place?
Upvotes: 0
Views: 98
Reputation: 411
Sorry, your question is unclear? do you want to increase the width of the label? if so,
UIView.animate(withDuration: 1.0) {
yourLabel.frame.size.width = newWidthValue;
yourLabel.layoutIfNeeded()
}
Upvotes: 3