I have a very simple project, I want to animate the right margin on a label, however when I try it, it finishes instantly.
strCriteria = Brandtype & " And " & strGeneric & " And " & strManufacturer
The project is here:
https://www.dropbox.com/s/9a0v0906riunkww/test2222.zip?dl=0
Am I missing something obvious?
Update #1
It seems it's a problem with UILabels specifically, a standard UIView, or UIButton animates fine....so whats wrong with a UILabel?
Update #2
If I set the UILabel View Content Mode to Center, then it works fine, but it doesn't look very smooth...very strange.
答案 0 :(得分:0)
I may be off the mark here, but it looks to me as though your animation routine just does ArgumentError: wrong number of arguments (1 for 0)
, which will cause the screen to redraw instantly. You need to change some animatable parameter of the UIView in order to see something move. Like setNeedslayout
, perhaps. The animatable properties of UIView are listed here.
答案 1 :(得分:0)
尝试使用self.view.setNeedsLayout()
self.view.layoutIfNeeded()
@IBAction func onDo(sender:UIButton) {
self.testConstraint.constant = 40.0
UIView.animateWithDuration(2.0, animations: { () -> Void in
self.view.layoutIfNeeded()
}) { (complete:Bool) -> Void in
}
}