swift navigation bar title remove animation

2019-09-19 06:34发布

问题:

I have added Page Control to the title of navigation bar from Interface Builder. When the view push/pop to the next view, the Page Control animates (as how normally title would animate).

How do i prevent the Page Control from animating?

I have something like this but it didn't work:

self.navigationItem.titleView?.removeMotionEffect(UIMotionEffect())

回答1:

Solved it. I need to create a new Page View Controller to manipulate the Page Control that I have placed on the navigation bar.

Instead of having multiple Page Control on each View Controller, I just have one Page Control on the first page.

And switch between View Controller using Page View Controller instead of doing push/pop.



回答2:

Try

UIView.performWithoutAnimation { () -> Void in
        <#code#>
    }