【问题标题】:how to change size and position of searchController?.searchBar?如何更改 searchController?.searchBar 的大小和位置?
【发布时间】:2016-09-18 16:44:52
【问题描述】:

例如,我尝试更改 searchController.searchBar 的大小和位置 我将 y 从 0 更改为 100,但我可以看到我的程序有任何变化。

这是我的代码:

    placesClient = GMSPlacesClient.sharedClient()
    resultsViewController = GMSAutocompleteResultsViewController()
    resultsViewController?.delegate = self
    searchController = UISearchController(searchResultsController: resultsViewController)
    searchController?.searchResultsUpdater = resultsViewController

    searchController?.searchBar.sizeThatFits(CGSize(width: 600, height: 44.0 ))


         self.definesPresentationContext = true

    searchController?.searchBar.frame = (CGRectMake(0, 100,600, 44.0))

    self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: (searchController?.searchBar)!)

    // Keep the navigation bar visible.
    searchController?.hidesNavigationBarDuringPresentation = false
    searchController?.modalPresentationStyle = UIModalPresentationStyle.Popover

picture

任何人都可以帮助我吗?

【问题讨论】:

    标签: swift swift2 resize xcode7.3


    【解决方案1】:

    您可以更改搜索栏或文本字段的大小作为另一个示例,通过使用该项目中的大小检查器。此外,当您为对象设置约束时,您可以将高度或宽度设置为您希望的任何内容......在屏幕的限制范围内。因此,设置高度为 30 的文本字段现在可以设置为 50 或任何您希望适合您的审美的值。我曾经通过搜索自己找到了这个,最后在带有 Mark Price 的 iOS 9 的 Udemy 课程中发现了它。我会转发链接,但这是一门付费课程。祝你好运!

    【讨论】:

      猜你喜欢
      • 2020-02-12
      • 2021-06-24
      • 1970-01-01
      • 1970-01-01
      • 2013-06-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多