iOS 13 Set UISearchTextField placeholder color

后端 未结 5 1720
执笔经年
执笔经年 2020-12-10 02:20

How do you set the placeholder color of iOS 13\'s UISearchTextField?

I tried the following with no success:

searchField.attributedPlaceh         


        
5条回答
  •  我在风中等你
    2020-12-10 02:28

    I found the following code snippet worked:

    DispatchQueue.main.asyncAfter(deadline: .now()+0.5) {
        // Stackoverflow said the above doesn't work on viewDidLoad style methods, so running it async after a 0.5s delay to workaround.  Works.
        searchField.attributedPlaceholder = NSAttributedString(string:"Search", attributes: attributesDictionary)
    }
    

提交回复
热议问题