I've constrained an UIImageView
in IB. I tried to animate another constraint, the center, but when I'm using layoutIfNeeded
with animateWithDuration
, I can see that iOS is also resizing my UIImageView
.
With a little help from print() I've figured out that my UIImageView
is actually 1000.0, 1000.0 before super.viewDidLoad()
and 200.0, 200.0 after, which is the size of my constraint.
I don't get it. I've never ever entered 1000 anywhere, and my image asset is 200x200, 400x400@2x and 600x600@3x.
What am I doing wrong ?
edit : Here's some of my code. I've tweaked it a little bit, more based on my asset size, but it's still not what I wanted :
@IBOutlet weak var bigLogoOutlet: UIImageView!
override func viewWillAppear(_ animated: Bool) {
bigLogoOutlet.frame.size.height = 0
bigLogoOutlet.frame.size.width = 0
}
override func viewDidLoad() {
super.viewDidLoad()
self.title = "My title"
}
override func viewDidLayoutSubviews() {
UIView.animate(withDuration: 0.5, delay: 0.5, usingSpringWithDamping: 0.5, initialSpringVelocity: 0, options: [], animations: {
self.bigLogoOutlet.frame.size.height = 200
self.bigLogoOutlet.frame.size.width = 200
self.view.layoutIfNeeded()
}, completion: nil)
}
So now, It's resizing from 0x0 to 200x200. Ok, cool, but it's also moving from x:0 y:0 where my IB constraints told him to be at least superview.center.x !