gpt4 book ai didi

ios - Swift - 在 UISearchBar 顶部可见的范围按钮

转载 作者:搜寻专家 更新时间:2023-11-01 06:18:25 27 4
gpt4 key购买 nike

我创建了一个搜索栏和一个范围栏,但是当页面启动时,范围按钮在搜索栏后面直接可见。我知道 .Minimal 设置使我的搜索栏变得半透明,但它给我一种漂亮的灰色,在白色背景上看起来很棒。

单击搜索栏,然后单击取消按钮将正确显示所有内容。下面的链接准确地显示了我在说什么。

UISearchBarStyleMinimal shows scope buttons on top of UISearchBar

有人知道如何解决这个问题吗?

SearchController.swift

let searchController = UISearchController(searchResultsController: nil)

override func viewDidLoad() {
super.viewDidLoad()

// Create search bar
self.searchController.searchResultsUpdater = self
self.searchController.dimsBackgroundDuringPresentation = false
self.searchController.hidesNavigationBarDuringPresentation = true
self.searchController.searchBar.sizeToFit()

self.definesPresentationContext = true
self.tableView.tableHeaderView = searchController.searchBar

self.searchController.searchBar.delegate = self
self.searchController.searchBar.scopeButtonTitles = ["All", "btn1", "btn2", "btn3"]

tableView.allowsMultipleSelectionDuringEditing = true
}

AppDelegate.swift

    UISearchBar.appearance().searchBarStyle = .Minimal
UISearchBar.appearance().backgroundColor = UIColor.whiteColor()
UISearchBar.appearance().barTintColor = UIColor.whiteColor()
UISearchBar.appearance().tintColor = Constants.MAIN_THEME_COLOR

最佳答案

我在搜索时遇到了同样的问题,但通过添加以下行解决了这个问题:

self.searchController.searchBar.showsScopeBar = true

关于ios - Swift - 在 UISearchBar 顶部可见的范围按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39188164/

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