0

I'm new to animation in ios and i'm trying to apply an animation on the titleView in the navigationBar but following code keep saying:

Cannot invoke 'animateWithDuration' with an argument list of type '(FloatLiteralConvertible, delay: FloatLiteralConvertible, options: UIViewAnimationOptions, animations: () -> () -> $T4, completion: (($T16) -> ($T16) -> $T15) -> (($T16) -> $T15) -> $T15)'

when i remove the

self.navigationItem.titleView?.center = CGPointMake(10, 10)

there is no error, but how can i apply an animaiton on the titleView/title?

@IBAction func animateButtonTapped(sender: UIBarButtonItem) {



    UIView.animateWithDuration(0.7, delay: 1.0, options: UIViewAnimationOptions.CurveEaseOut, animations: {

        self.navigationItem.titleView?.center = CGPointMake(10, 10)

        }, completion: { finished in
            println("Basket doors opened!")
    })


}
1
  • Yes i'm new to animations in IOS and just starting by making some kind of animation? why do i then get the above swift compiler error? Commented Nov 19, 2014 at 17:03

1 Answer 1

1
UIView.animateWithDuration(0.7, delay: 1.0, options:.CurveEaseOut, animations: {
    // Optional chaining may return nil
    _ = self.navigationItem.titleView?.center = CGPointMake(10, 10)
    // return
    }, completion: {
        finished in
        println("Basket doors opened!")
})
Sign up to request clarification or add additional context in comments.

9 Comments

Implicit returns from single-expression closures.
So why is this not animating the titleView?
Did you set this property to a custom title view?
No at the moment its just a text title? so what do i need to change in order to animate that?
You can set it with a UILabel() if you just want a text title. titleView is nil by default.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.