0
我的要求是導航欄的標題必須從左向右滑動。我該如何做這種類型的動畫?我正在使用故事板來開發我的應用程序。 謝謝!如何在ios swift中的Uinavigation Bar中實現滑動標題?
我的要求是導航欄的標題必須從左向右滑動。我該如何做這種類型的動畫?我正在使用故事板來開發我的應用程序。 謝謝!如何在ios swift中的Uinavigation Bar中實現滑動標題?
您可以創建自定義UILabel
爲titleView
,然後動畫它在viewDidAppear
你的代碼應該看起來像(測試代碼)
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")
}
請更具體,所以你要能刷卡標題有另一個文本,或者當你的視圖出現從左到右的動畫標題時你想要這個? – Aladin
對不起,不具體。基本上,只要我的主頁出現,導航欄標題將動態顯示,標題將始終保持從左到右的動畫效果。 – abhishek