【问题标题】:I Need to Change the Color of Placeholder Text [duplicate]我需要更改占位符文本的颜色 [重复]
【发布时间】:2020-04-06 02:36:23
【问题描述】:

在大多数情况下,我仍然是新手,我正在使用的代码是公司应用程序的一部分,该应用程序已经开发了很长时间。我仍在学习并承担无法积极从事的较小工作。我对许多主题仍然一无所知。这是我与搜索栏相关的代码,我需要更改占位符文本颜色:

    func addSearchController() {
            // initialize searchResultsController set to nil as we want to use this view controller to display the search results
            searchController = UISearchController(searchResultsController: nil)
            searchController.searchResultsUpdater = self
            searchController.dimsBackgroundDuringPresentation = false
            searchController.searchBar.sizeToFit()
            searchController.searchBar.tintColor = .white
            searchController.searchBar.barTintColor = .ocTopGreen()
            searchController.searchBar.searchTextField.textColor = .white
            searchController.searchBar.placeholder = "Search for a symptom"
            tableView.tableHeaderView = searchController.searchBar
        }

任何帮助将不胜感激。

【问题讨论】:

标签: swift iphone xcode


【解决方案1】:

如果您希望占位符的文本格式不同于输入的文本格式,那么您将无法使用占位符来做到这一点。

相反,您应该创建一个充当占位符的元素。只需将其放置在占位符通常的位置即可。一旦检测到输入框不为空,就让它消失。

【讨论】:

  • 已经存在占位符文本,它可以正常工作,我只需要弄清楚要输入什么代码来更改所述占位符文本的颜色。我可能误解了您的回复,如果有,我深表歉意
  • 哦,如果就这么简单:w3schools.com/howto/howto_css_placeholder.asp
猜你喜欢
  • 2013-05-12
  • 2017-05-18
  • 2013-02-04
  • 2017-11-25
  • 1970-01-01
  • 2019-02-24
  • 1970-01-01
  • 2010-11-23
相关资源
最近更新 更多