최근 검색


최근 검색 없음

How to change the color of the search bar placeholder in the iOS SDK

답변함


2021년 7월 12일에 게시됨

I would like to know how to change the color of the search bar placeholder in the iOS SDK.

What should I write by creating help_center_article_style.css?

Thank you.

 


0

7

댓글 7개

image avatar

Eric Nelson

Zendesk Developer Advocacy

Hey Asa,

This will actually be set in your appDelegate file. You can accomplish this with the UIkit specifically the UISearchBar. I've included an example on how to accomplish below:

        UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).defaultTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
        UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).attributedPlaceholder = NSAttributedString(string: "Search...", attributes: [NSAttributedString.Key.foregroundColor: UIColor.lightGray]

Hope this helps!

Have a wonderful day!

Eric Nelson | Manager - Developer Advocacy

1


Hi, Eric

Thank you for your adcive!

I try it, so I have another problem.

I can not show anything first, but can show after editing.

Please tell me if you know anything.

Thank you.

- First

- Editing

0


image avatar

Eric Nelson

Zendesk Developer Advocacy

Hey Asa,

In that case you'd just want to use this line instead of the two I provided before:

UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).attributedPlaceholder = NSAttributedString(string: "Search...", attributes: [NSAttributedString.Key.foregroundColor: UIColor.lightGray]

Let me know if that does the trick!

Have a wonderful day!

Eric Nelson | Manager - Developer Advocacy

0


Hey Eric Nelson!

I have the same problem you mentioned earlier and I am trying to fix it according to your way, but the problem remains unresolved.

Could you please help me? 

0


image avatar

Eric Nelson

Zendesk Developer Advocacy

Hey Nikita,

Can you provide the corresponding code snippets so that I can take a look?

Thanks!

0


Hey Eric Nelson, yeah, shure, there is my code on this screenshot. 

Thank you a lot. 

0


image avatar

Eric Nelson

Zendesk Developer Advocacy

Hey Nikita,

Everything looks good code-wise, what does the UI look like when using this code? 

0


게시물 댓글 달기가 중지되었습니다.

원하는 정보를 못 찾으셨나요?

새 게시물