How to change placeHolder text of UItextField programmatically if I have designed textField in XIBAdd Placeholder to UITextField, how to set the placeholder text programmatically in swift?How do you load custom UITableViewCells from Xib files?iPhone UITextField - Change placeholder text colorUITextField text change eventhow to create a multiline UITextfield with multiple placeholders programmatically?How to change Status Bar text color in iOSChanging Placeholder Text Color with SwiftChanging text of UIButton programmatically swiftNeed to get placeholder text of UITextFieldAdd Placeholder to UITextField, how to set the placeholder text programmatically in swift?textfield placeholder centered and also change color
Impossible darts scores
How can my android "die" permanently?
How would modern naval warfare have to have developed differently for battleships to still be relevant in the 21st century?
Do I have any obligations to my PhD supervisor's requests after I have graduated?
Loss of power when I remove item from the outlet
Is my Rep in Stack-Exchange Form?
Find the diameter of a word graph
How do I set an alias to a terminal line?
Java TreeMap.floorKey() equivalent for std::map
Output of "$OSTYPE:6" on old releases of Mac OS X
Should my manager be aware of the proposals I receive? How to politely have this happen?
How long would it take to cross the Channel in 1890's?
What does "play with your toy’s toys" mean?
Folding basket - is there such a thing?
Strongest topology that makes vector space locally convex
Can humans ever directly see a few photons at a time? Can a human see a single photon?
How much will studying magic in an academy cost?
Is this one of the engines from the 9/11 aircraft?
Are all instances of trolls turning to stone ultimately references back to Tolkien?
Why did pressing the joystick button spit out keypresses?
A STL-like vector implementation in C++
In the Marvel universe, can a human have a baby with any non-human?
expiry or manufactured date?
Does Marvel have an equivalent of the Green Lantern?
How to change placeHolder text of UItextField programmatically if I have designed textField in XIB
Add Placeholder to UITextField, how to set the placeholder text programmatically in swift?How do you load custom UITableViewCells from Xib files?iPhone UITextField - Change placeholder text colorUITextField text change eventhow to create a multiline UITextfield with multiple placeholders programmatically?How to change Status Bar text color in iOSChanging Placeholder Text Color with SwiftChanging text of UIButton programmatically swiftNeed to get placeholder text of UITextFieldAdd Placeholder to UITextField, how to set the placeholder text programmatically in swift?textfield placeholder centered and also change color
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have to make a custom class to design textField in XIB and reuse it multiple times in my viewController. I want to change each placeholder name programmatically.
ios swift swift4
add a comment |
I have to make a custom class to design textField in XIB and reuse it multiple times in my viewController. I want to change each placeholder name programmatically.
ios swift swift4
provide code that you tried
– Jaydeep
Mar 25 at 9:30
@IBInspectable var placeHolderText: String = "" didSet rsFloatingView.placeHolderStringKey = placeHolderText
– vikas patidar
Mar 25 at 9:32
1
Possible duplicate of Add Placeholder to UITextField, how to set the placeholder text programmatically in swift?
– Amir Khan
Mar 25 at 9:33
add a comment |
I have to make a custom class to design textField in XIB and reuse it multiple times in my viewController. I want to change each placeholder name programmatically.
ios swift swift4
I have to make a custom class to design textField in XIB and reuse it multiple times in my viewController. I want to change each placeholder name programmatically.
ios swift swift4
ios swift swift4
edited Mar 25 at 10:14
iPeter
1,0496 silver badges22 bronze badges
1,0496 silver badges22 bronze badges
asked Mar 25 at 9:29
vikas patidarvikas patidar
36 bronze badges
36 bronze badges
provide code that you tried
– Jaydeep
Mar 25 at 9:30
@IBInspectable var placeHolderText: String = "" didSet rsFloatingView.placeHolderStringKey = placeHolderText
– vikas patidar
Mar 25 at 9:32
1
Possible duplicate of Add Placeholder to UITextField, how to set the placeholder text programmatically in swift?
– Amir Khan
Mar 25 at 9:33
add a comment |
provide code that you tried
– Jaydeep
Mar 25 at 9:30
@IBInspectable var placeHolderText: String = "" didSet rsFloatingView.placeHolderStringKey = placeHolderText
– vikas patidar
Mar 25 at 9:32
1
Possible duplicate of Add Placeholder to UITextField, how to set the placeholder text programmatically in swift?
– Amir Khan
Mar 25 at 9:33
provide code that you tried
– Jaydeep
Mar 25 at 9:30
provide code that you tried
– Jaydeep
Mar 25 at 9:30
@IBInspectable var placeHolderText: String = "" didSet rsFloatingView.placeHolderStringKey = placeHolderText
– vikas patidar
Mar 25 at 9:32
@IBInspectable var placeHolderText: String = "" didSet rsFloatingView.placeHolderStringKey = placeHolderText
– vikas patidar
Mar 25 at 9:32
1
1
Possible duplicate of Add Placeholder to UITextField, how to set the placeholder text programmatically in swift?
– Amir Khan
Mar 25 at 9:33
Possible duplicate of Add Placeholder to UITextField, how to set the placeholder text programmatically in swift?
– Amir Khan
Mar 25 at 9:33
add a comment |
5 Answers
5
active
oldest
votes
If you want to change the placeholder you can use the below code
yourTextField.attributedPlaceholder =
NSAttributedString(string: "YourText", attributes: [NSForegroundColorAttributeName : UIColor.white])
add a comment |
try making a custom uitextfield class
@IBDesignable
class CustomTextField: UITextField
@IBInspectable var TFPlaceholder: String?
willSet
self.placeholder = newValue

Goodluck!! :)
add a comment |
Create subclass as:
class CustomTextField: UITextField
override func awakeFromNib()
super.awakeFromNib()
func placeHolderColor(pColor: UIColor, pText: String)
self.attributedPlaceholder = NSAttributedString(string: pText,
attributes: [NSAttributedStringKey.foregroundColor: pColor])
add a comment |
Declare an open variable of type string in your textfield custom class. Access that variable to change a placeholder name where ever implemented.
add a comment |
You can change by following two way
1) yourTextField.placeholder = "some string"
2) yourTextField.attributedPlaceholder = NSAttributedString(string: "some string")
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55334748%2fhow-to-change-placeholder-text-of-uitextfield-programmatically-if-i-have-designe%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you want to change the placeholder you can use the below code
yourTextField.attributedPlaceholder =
NSAttributedString(string: "YourText", attributes: [NSForegroundColorAttributeName : UIColor.white])
add a comment |
If you want to change the placeholder you can use the below code
yourTextField.attributedPlaceholder =
NSAttributedString(string: "YourText", attributes: [NSForegroundColorAttributeName : UIColor.white])
add a comment |
If you want to change the placeholder you can use the below code
yourTextField.attributedPlaceholder =
NSAttributedString(string: "YourText", attributes: [NSForegroundColorAttributeName : UIColor.white])
If you want to change the placeholder you can use the below code
yourTextField.attributedPlaceholder =
NSAttributedString(string: "YourText", attributes: [NSForegroundColorAttributeName : UIColor.white])
answered Mar 25 at 10:05
Hairsh KuramsettyHairsh Kuramsetty
811 silver badge4 bronze badges
811 silver badge4 bronze badges
add a comment |
add a comment |
try making a custom uitextfield class
@IBDesignable
class CustomTextField: UITextField
@IBInspectable var TFPlaceholder: String?
willSet
self.placeholder = newValue

Goodluck!! :)
add a comment |
try making a custom uitextfield class
@IBDesignable
class CustomTextField: UITextField
@IBInspectable var TFPlaceholder: String?
willSet
self.placeholder = newValue

Goodluck!! :)
add a comment |
try making a custom uitextfield class
@IBDesignable
class CustomTextField: UITextField
@IBInspectable var TFPlaceholder: String?
willSet
self.placeholder = newValue

Goodluck!! :)
try making a custom uitextfield class
@IBDesignable
class CustomTextField: UITextField
@IBInspectable var TFPlaceholder: String?
willSet
self.placeholder = newValue

Goodluck!! :)
answered Mar 25 at 10:16
Sanad BarjawiSanad Barjawi
12012 bronze badges
12012 bronze badges
add a comment |
add a comment |
Create subclass as:
class CustomTextField: UITextField
override func awakeFromNib()
super.awakeFromNib()
func placeHolderColor(pColor: UIColor, pText: String)
self.attributedPlaceholder = NSAttributedString(string: pText,
attributes: [NSAttributedStringKey.foregroundColor: pColor])
add a comment |
Create subclass as:
class CustomTextField: UITextField
override func awakeFromNib()
super.awakeFromNib()
func placeHolderColor(pColor: UIColor, pText: String)
self.attributedPlaceholder = NSAttributedString(string: pText,
attributes: [NSAttributedStringKey.foregroundColor: pColor])
add a comment |
Create subclass as:
class CustomTextField: UITextField
override func awakeFromNib()
super.awakeFromNib()
func placeHolderColor(pColor: UIColor, pText: String)
self.attributedPlaceholder = NSAttributedString(string: pText,
attributes: [NSAttributedStringKey.foregroundColor: pColor])
Create subclass as:
class CustomTextField: UITextField
override func awakeFromNib()
super.awakeFromNib()
func placeHolderColor(pColor: UIColor, pText: String)
self.attributedPlaceholder = NSAttributedString(string: pText,
attributes: [NSAttributedStringKey.foregroundColor: pColor])
edited Mar 25 at 11:13
answered Mar 25 at 10:20
Raj SharmaRaj Sharma
819 bronze badges
819 bronze badges
add a comment |
add a comment |
Declare an open variable of type string in your textfield custom class. Access that variable to change a placeholder name where ever implemented.
add a comment |
Declare an open variable of type string in your textfield custom class. Access that variable to change a placeholder name where ever implemented.
add a comment |
Declare an open variable of type string in your textfield custom class. Access that variable to change a placeholder name where ever implemented.
Declare an open variable of type string in your textfield custom class. Access that variable to change a placeholder name where ever implemented.
edited Mar 25 at 11:35
jogshardik
8901 gold badge9 silver badges20 bronze badges
8901 gold badge9 silver badges20 bronze badges
answered Mar 25 at 9:33
Vaishak IyerVaishak Iyer
814 bronze badges
814 bronze badges
add a comment |
add a comment |
You can change by following two way
1) yourTextField.placeholder = "some string"
2) yourTextField.attributedPlaceholder = NSAttributedString(string: "some string")
add a comment |
You can change by following two way
1) yourTextField.placeholder = "some string"
2) yourTextField.attributedPlaceholder = NSAttributedString(string: "some string")
add a comment |
You can change by following two way
1) yourTextField.placeholder = "some string"
2) yourTextField.attributedPlaceholder = NSAttributedString(string: "some string")
You can change by following two way
1) yourTextField.placeholder = "some string"
2) yourTextField.attributedPlaceholder = NSAttributedString(string: "some string")
edited Mar 25 at 14:34
jogshardik
8901 gold badge9 silver badges20 bronze badges
8901 gold badge9 silver badges20 bronze badges
answered Mar 25 at 9:37
TommyTommy
192 bronze badges
192 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55334748%2fhow-to-change-placeholder-text-of-uitextfield-programmatically-if-i-have-designe%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
provide code that you tried
– Jaydeep
Mar 25 at 9:30
@IBInspectable var placeHolderText: String = "" didSet rsFloatingView.placeHolderStringKey = placeHolderText
– vikas patidar
Mar 25 at 9:32
1
Possible duplicate of Add Placeholder to UITextField, how to set the placeholder text programmatically in swift?
– Amir Khan
Mar 25 at 9:33