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

                                                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                                                    용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

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