Change UITextField and UITextView Cursor / Caret Color

前端 未结 16 2062
醉话见心
醉话见心 2020-12-07 09:33

I\'m wondering about changing the color of the cursor / caret in a UITextField (And UITextView if its the same answer) in iOS. I\'ve seen answers f

16条回答
  •  南笙
    南笙 (楼主)
    2020-12-07 10:02

    If the UITextField is from UISearchBar then first get the textField from searchBar and then apply tintColor property:

    let textFieldInsideSearchBar = searchBar.value(forKey: "searchField") as? UITextField
    textFieldInsideSearchBar?.tintColor = UIColor.lightGray
    

提交回复
热议问题