I am trying to pass parameter to function to change layout constraint in animation block dynamically.
This works:
func moveKeyboard (up: Bool, newMargin: Int)
{
UIView.animateWithDuration(0.2, delay: 0, options: .CurveEaseIn, animations: {
self.topMarginConstraint.constant=10;
}, completion: { finished in
println("Animation end!")
})
}
and this doesn't (i get error "Could not find member CurveEaseIn"):
func moveKeyboard (up: Bool, newMargin: Int)
{
UIView.animateWithDuration(0.2, delay: 0, options: .CurveEaseIn, animations: {
self.topMarginConstraint.constant=newMargin;
}, completion: { finished in
println("Animation end!")
})
}
How should i define my function to be able to use newMargin parameter inside animation block?
It's because, the "constant" is of type "CGFLoat" and you are passsing "Int":
Check this out it's working fine.