iOS 13和Xcode 11-UINavigationBar断开滚动显示大标题

iOS 13和Xcode 11-UINavigationBar断开滚动显示大标题,ios,uiscrollview,uinavigationbar,ios13,Ios,Uiscrollview,Uinavigationbar,Ios13,在iOS 12和Xcode 10.3上,我对大标题的滚动没有问题,但对于相同的代码,Xcode 11和iOS 13,我遇到了如下所示的问题: 在iOS 12上,我有一个带有所需行为的导航栏,如下所示: 有人遇到过同样的问题吗?对于其余部分,我当然使用prefersLargeTitles=true,并且我确信我使用的代码对于这两种不同的行为是相同的。感谢您的帮助经过调查,我找到了解决方案,因此我将分享我的发现,因为我认为这可以帮助一些人。 解决方案是,从iOS 13开始,我们必须使用UINavig

在iOS 12和Xcode 10.3上,我对大标题的滚动没有问题,但对于相同的代码,Xcode 11和iOS 13,我遇到了如下所示的问题:

在iOS 12上,我有一个带有所需行为的导航栏,如下所示:


有人遇到过同样的问题吗?对于其余部分,我当然使用prefersLargeTitles=true,并且我确信我使用的代码对于这两种不同的行为是相同的。感谢您的帮助

经过调查,我找到了解决方案,因此我将分享我的发现,因为我认为这可以帮助一些人。 解决方案是,从iOS 13开始,我们必须使用UINavigationBarAppearance。创建此对象后,我们可以将其指定给一些新属性,称为:

标准外观 紧凑外观 scrollEdgeAppearance这一个很可能是我的bug的原因 我将其作为扩展发布一个示例:

extension UINavigationBar {

    func setupLarge() {
        // ... Set up here your tintColor, isTranslucent and other properties if you need

        if #available(iOS 11.0, *) {
            prefersLargeTitles = true
            //largeTitleTextAttributes = ...Set your attributes
        }

        if #available(iOS 13.0, *) {
            let appearance = UINavigationBarAppearance()
            appearance.backgroundColor = barTintColor
            appearance.titleTextAttributes = [.foregroundColor: UIColor.white]
            appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white]

            standardAppearance = appearance
            compactAppearance = appearance
            scrollEdgeAppearance = appearance
        }
    }
}

经过一些调查,我找到了一个解决方案,所以我将分享我的发现,因为我认为它可以帮助一些人。 解决方案是,从iOS 13开始,我们必须使用UINavigationBarAppearance。创建此对象后,我们可以将其指定给一些新属性,称为:

标准外观 紧凑外观 scrollEdgeAppearance这一个很可能是我的bug的原因 我将其作为扩展发布一个示例:

extension UINavigationBar {

    func setupLarge() {
        // ... Set up here your tintColor, isTranslucent and other properties if you need

        if #available(iOS 11.0, *) {
            prefersLargeTitles = true
            //largeTitleTextAttributes = ...Set your attributes
        }

        if #available(iOS 13.0, *) {
            let appearance = UINavigationBarAppearance()
            appearance.backgroundColor = barTintColor
            appearance.titleTextAttributes = [.foregroundColor: UIColor.white]
            appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white]

            standardAppearance = appearance
            compactAppearance = appearance
            scrollEdgeAppearance = appearance
        }
    }
}

接受你的答案,这样可以帮助别人!但我可以在两天内,因为现在我仍然不能接受你的答案,以便它可以帮助其他问题!但我能在两天内做到,现在我还是不能