How to change the default text in Search Bar in IOS? - ios

HI I develop an application in IOS and I meet a problem that I want to change the default text which is "search" in search bar to "Key in video title to search". How to do it ? Please help me Thank you.

The UISearchBar and the UITextField have this property of a placeholder which is the default text in the fields.
1.Change it from the Interface Builder.
2.Change it through code
self.searchBarObject.placeholder = #"Key In Video Title To Search";
Read what Apple has written about the UISearchField.

You can use the plain old placeholder property:
mySearchBar.placeholder = #"Foo!";
Relevant documentation.
It can also be changed within Interface Builder:

You can set the placeholder property
sBar.placeholder = #"Key in video title to search";

Related

Change UIlabel title text in ZDCLoadingErrorView

I need to change title UIlabel text in ZDCLoadingErrorView when no agent is available, but unable to do that.
Using ZDCChat.instance().offlineMessageHandler.noAgentsMessage , I am only able to change message UIlabel in ZDCLoadingErrorView.
ZDCLoadingErrorView.init().title return nil and I havn't found any way to add notification for ZDCLoadingErrorView when it first appears.
Thanks in advance
You can change it through the Localizable.strings file located at the ZDCChatStrings.bundle. The key is "ios.ZDCChat.noAgentsTitle" as stated on https://developer.zendesk.com/embeddables/docs/ios-chat-sdk/customization

How to remove "border-radius" from default UITextField?

My question is, how do I remove the "border-radius" of the textfield in Swift? Is it achievable in xCode or do you need to do a customized textfield? If so, how do I do that? I want the default textfield but without it's "border-radius" if you know what I mean.
Help, please!
UITextField has an attribute borderStyle, which can be changed either in interface builder:
...or in code:
public var borderStyle: UITextBorderStyle // default is UITextBorderStyleNone. If set to UITextBorderStyleRoundedRect, custom background images are ignored.
You can set the border style using Storyboards.
And also you can set border style programitically
[txtUserName setBorderStyle:UITextBorderStyleNone];
What do you exactly mean with border-radius? the border around it?
You can turn that off by clicking the button in xcode:
Or if you want to do it programmatically do:
myButton.bordered = false

How to change placeholder text color in xib?

How to change placeholder text color in xib ? I have tried key path thing but it is giving me NSException. Can anyone please help.
The easiest method to modify the placeholder text color is through the Xcode storyboard interface builder. Select the UITextField of interest and open the identity inspector on the right. Click on the plus symbol in the User Defined Runtime Attributes and add a new row with Key Path as placeholderLabel.textColor, Type as Color and Value to your desired color.
Navneils answer with screenshot ,You can set opacity also from here
use placeholderLabel.textColor instead of _placeholderLabel.textColor for swift 5.0 and iOS 13
We cannot change textcolor of placeholder text in storyboard. Manually we can change with the property name.
Addthis code in viewDidLoad
[nameTextField setValue:[UIColor colorWithRed:41.0/255.0 green:91.0/255.0 blue:106.0/255.0 alpha:1.0] forKeyPath:#"_placeholderLabel.textColor"];

iOS: URL link in UITextField with different text

I want to insert a URL hyperlink into a UITextField that has different display text.
This is super easy in html:
Go To Google
How can I do this in iOS?
You can change the text style inside your UITextField via an attributed string sent to the text field's "attributedText" property.
However, what I suspect you really want to do is have a link that's clickable. I would recommend using a UIButton with a custom type (i.e. no border) and you can set the color and the underline style.
But like Evan said, if you have multiple lines of text, it may be smarter to use a UITextField where you set "editable" to NO and turn on the LINK traits (both of these you can do from the object inspector in Xcode).
Alright, so here's what I did to get what I wanted. I used UIWebView, and simply linked it to an html page in the project that has the text, and hyperlink at the bottom with different text displayed.
Answer is here :
If you want it as clickable Hyperlink,
NSString *string = #"Go To Google";
You need to add "BACKWARD SLASH" before ". That's it.

Change the "search" keyboard button title

I am using the default UIKeyBoardType, and it contains a button with a Search title. Is there any way to change that title from Search to Dismiss for example?
If you are using IB you can select the UITextField that you want to change the keyboard for. Then under the Attribute Inspector there is an option "Return Key" You can change the title here.

Resources