My requirement is that the title of the navigation bar must slide from left to right. How can I do this type of animations? I am using storyboard for my app development. Thanks!
You can create a custom UILabel
as a titleView
and then animate it in viewDidAppear
your code should looks like (code tested)
override func viewDidAppear(animated: Bool) {
/* Create custom label as titleView of the navigation controller */
let titleLabel = UILabel(frame: CGRectMake(0, 0, 50, 50))
titleLabel.text = "My Title"
self.navigationItem.titleView = titleLabel
/* Animate the label */
let moveAnimation = CATransition()
moveAnimation.duration = 0.5
moveAnimation.type = kCATransitionPush
titleLabel.layer.addAnimation(moveAnimation, forKey:"moveText")
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.