I am trying to animate each view of NSTabView with a slide in when the view is selected. I have this working in a fashion, but it only animates the first time i select a new tab view. After that i do not see an animation when switching tab views, although i can see the the function is fired every time.?
override func tabView(tabView: NSTabView, didSelectTabViewItem tabViewItem: NSTabViewItem) {
tabViewItem.view!.setFrameOrigin(NSPoint(x: tabViewItem.view!.frame.origin.x + 300, y: tabViewItem.view!.frame.origin.y))
tabViewItem.view!.animator().setFrameOrigin(NSPoint(x: tabViewItem.view!.frame.origin.x - 300, y: tabViewItem.view!.frame.origin.y))
// i can see this fires every time i switch tab views but the animation only works the fist time
}
If you're using NSTabViewController. You only need to set transitionOptions inside viewDidLoad Method.
class TabVC: NSTabViewController {
override func viewDidLoad() {
super.viewDidLoad()
/// When new tab will select, it will perform slide transition.
self.transitionOptions = .slideRight
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With