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;








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.










share|improve this question
























  • 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

















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.










share|improve this question
























  • 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













0












0








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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












5 Answers
5






active

oldest

votes


















0














If you want to change the placeholder you can use the below code



yourTextField.attributedPlaceholder =
NSAttributedString(string: "YourText", attributes: [NSForegroundColorAttributeName : UIColor.white])





share|improve this answer






























    0














    try making a custom uitextfield class



    @IBDesignable
    class CustomTextField: UITextField

    @IBInspectable var TFPlaceholder: String?
    willSet
    self.placeholder = newValue





    enter image description here



    Goodluck!! :)






    share|improve this answer






























      0














      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])








      share|improve this answer
































        0














        Declare an open variable of type string in your textfield custom class. Access that variable to change a placeholder name where ever implemented.






        share|improve this answer
































          0














          You can change by following two way



          1) yourTextField.placeholder = "some string"



          2) yourTextField.attributedPlaceholder = NSAttributedString(string: "some string")






          share|improve this answer



























            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
            );



            );













            draft saved

            draft discarded


















            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









            0














            If you want to change the placeholder you can use the below code



            yourTextField.attributedPlaceholder =
            NSAttributedString(string: "YourText", attributes: [NSForegroundColorAttributeName : UIColor.white])





            share|improve this answer



























              0














              If you want to change the placeholder you can use the below code



              yourTextField.attributedPlaceholder =
              NSAttributedString(string: "YourText", attributes: [NSForegroundColorAttributeName : UIColor.white])





              share|improve this answer

























                0












                0








                0







                If you want to change the placeholder you can use the below code



                yourTextField.attributedPlaceholder =
                NSAttributedString(string: "YourText", attributes: [NSForegroundColorAttributeName : UIColor.white])





                share|improve this answer













                If you want to change the placeholder you can use the below code



                yourTextField.attributedPlaceholder =
                NSAttributedString(string: "YourText", attributes: [NSForegroundColorAttributeName : UIColor.white])






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 25 at 10:05









                Hairsh KuramsettyHairsh Kuramsetty

                811 silver badge4 bronze badges




                811 silver badge4 bronze badges























                    0














                    try making a custom uitextfield class



                    @IBDesignable
                    class CustomTextField: UITextField

                    @IBInspectable var TFPlaceholder: String?
                    willSet
                    self.placeholder = newValue





                    enter image description here



                    Goodluck!! :)






                    share|improve this answer



























                      0














                      try making a custom uitextfield class



                      @IBDesignable
                      class CustomTextField: UITextField

                      @IBInspectable var TFPlaceholder: String?
                      willSet
                      self.placeholder = newValue





                      enter image description here



                      Goodluck!! :)






                      share|improve this answer

























                        0












                        0








                        0







                        try making a custom uitextfield class



                        @IBDesignable
                        class CustomTextField: UITextField

                        @IBInspectable var TFPlaceholder: String?
                        willSet
                        self.placeholder = newValue





                        enter image description here



                        Goodluck!! :)






                        share|improve this answer













                        try making a custom uitextfield class



                        @IBDesignable
                        class CustomTextField: UITextField

                        @IBInspectable var TFPlaceholder: String?
                        willSet
                        self.placeholder = newValue





                        enter image description here



                        Goodluck!! :)







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Mar 25 at 10:16









                        Sanad BarjawiSanad Barjawi

                        12012 bronze badges




                        12012 bronze badges





















                            0














                            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])








                            share|improve this answer





























                              0














                              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])








                              share|improve this answer



























                                0












                                0








                                0







                                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])








                                share|improve this answer















                                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])









                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Mar 25 at 11:13

























                                answered Mar 25 at 10:20









                                Raj SharmaRaj Sharma

                                819 bronze badges




                                819 bronze badges





















                                    0














                                    Declare an open variable of type string in your textfield custom class. Access that variable to change a placeholder name where ever implemented.






                                    share|improve this answer





























                                      0














                                      Declare an open variable of type string in your textfield custom class. Access that variable to change a placeholder name where ever implemented.






                                      share|improve this answer



























                                        0












                                        0








                                        0







                                        Declare an open variable of type string in your textfield custom class. Access that variable to change a placeholder name where ever implemented.






                                        share|improve this answer















                                        Declare an open variable of type string in your textfield custom class. Access that variable to change a placeholder name where ever implemented.







                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        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





















                                            0














                                            You can change by following two way



                                            1) yourTextField.placeholder = "some string"



                                            2) yourTextField.attributedPlaceholder = NSAttributedString(string: "some string")






                                            share|improve this answer





























                                              0














                                              You can change by following two way



                                              1) yourTextField.placeholder = "some string"



                                              2) yourTextField.attributedPlaceholder = NSAttributedString(string: "some string")






                                              share|improve this answer



























                                                0












                                                0








                                                0







                                                You can change by following two way



                                                1) yourTextField.placeholder = "some string"



                                                2) yourTextField.attributedPlaceholder = NSAttributedString(string: "some string")






                                                share|improve this answer















                                                You can change by following two way



                                                1) yourTextField.placeholder = "some string"



                                                2) yourTextField.attributedPlaceholder = NSAttributedString(string: "some string")







                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                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



























                                                    draft saved

                                                    draft discarded
















































                                                    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.




                                                    draft saved


                                                    draft discarded














                                                    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





















































                                                    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







                                                    Popular posts from this blog

                                                    How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

                                                    155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

                                                    Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?