gpt4 book ai didi

iOS 13 导航栏大标题问题

转载 作者:行者123 更新时间:2023-12-01 15:38:39 27 4
gpt4 key购买 nike

我想展示一个大 TitleNavigation bar ,但背景清晰。向上滚动时,它将是 Navigation bar带有模糊效果。

enter image description here

enter image description here

这看起来是正确的,但是,在滚动时,动画似乎被破坏了。此外,过渡有时会卡住:

enter image description here

enter image description here

我的代码如下:
UINavigationController :

override func viewDidLoad() {
super.viewDidLoad()

if #available(iOS 13.0, *) {

self.navigationBar.prefersLargeTitles = true

let style = UINavigationBarAppearance()
style.configureWithDefaultBackground()

style.titleTextAttributes = [.font: UIFont.systemFont(ofSize: 18)]

self.navigationBar.standardAppearance = style
self.navigationBar.compactAppearance = style


//Configure Large Style
let largeStyle = UINavigationBarAppearance()
largeStyle.configureWithTransparentBackground()

largeStyle.largeTitleTextAttributes = [.font: UIFont.systemFont(ofSize: 28)]

self.navigationBar.scrollEdgeAppearance = largeStyle

}
}
UITableViewUINavigationController 里面.两者都是通过 segue 方式从 Storyboard中提取的。

最佳答案

您可以尝试使用 UITableViewController 代替 UITableview。我试过使用 UITableViewController 并且它对我来说工作正常。请检查以下设计和代码。

enter image description here

class ViewController: UITableViewController
{
override func viewDidLoad() {
super.viewDidLoad()
if #available(iOS 13.0, *) {
self.navigationController?.navigationBar.prefersLargeTitles = true
let style = UINavigationBarAppearance()
style.configureWithDefaultBackground()
style.titleTextAttributes = [.font: UIFont.systemFont(ofSize: 18)]
self.navigationController?.navigationBar.standardAppearance = style
self.navigationController?.navigationBar.compactAppearance = style
//Configure Large Style
let largeStyle = UINavigationBarAppearance()
largeStyle.configureWithTransparentBackground()
largeStyle.largeTitleTextAttributes = [.font: UIFont.systemFont(ofSize: 28)]
self.navigationController?.navigationBar.scrollEdgeAppearance = largeStyle
}
self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
// Do any additional setup after loading the view.
}

override func numberOfSections(in tableView: UITableView) -> Int {
1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
10
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
cell.textLabel?.text = "\(indexPath.row)"
return cell
}
}

输出:-

enter image description here

关于iOS 13 导航栏大标题问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58920055/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com