我是ios中的动画新手,我试图在navigationBar中的titleView上应用动画,但是下面的代码一直在说:
Cannot invoke 'animateWithDuration' with an argument list of type '(FloatLiteralConvertible, delay: FloatLiteralConvertible, options: UIViewAnimationOptions, animations: () -> () -> $T4, completion: (($T16) -> ($T16) -> $T15) -> (($T16) -> $T15) -> $T15)'
当我删除
self.navigationItem.titleView?.center = CGPointMake(10, 10)
没有错误,但我如何在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!")
})
}
答案 0 :(得分: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!")
})