I'm righting a function to animate something I'm passing it a UIImageView (I shall be passing it the x and y once I sort this bit out)
how do I change the CGRect(x: 400, y:500
if I change CGRect(x: 400, y:500
to CGRect(x: xdis, y:ydis
I get build fail extra argument "width" in call
but works fine as it is
func UpAndDown(thingToAnimate:UIImageView)
{
UIView.animateWithDuration(5, delay: 0, options: .CurveEaseOut, animations: {
let xdis = 30
let ydis = 20
thingToAnimate.frame = CGRect(x: 400, y:500 , width: thingToAnimate.frame.width, height: thingToAnimate.frame.height)
}, completion: { finished in
println("we moved")
})
This is probably happening because xdis
and ydis
are of type Int
, whereas CGRect
requires type CGFloat
as parameters. Therefore, you need to make xdis
and ydis
of type CGFloat
like so:
let xdis: CGFloat = 30