How to hide the placeholder of TextField programmatically using Swift 3x ?
            Asked
            
        
        
            Active
            
        
            Viewed 1,358 times
        
    0
            
            
         
    
    
        Nirav D
        
- 71,513
- 12
- 161
- 183
 
    
    
        Anurag Sharma
        
- 4,276
- 2
- 28
- 44
1 Answers
2
            You can not hide the placeholder of UITextField, but you can set it to empty String.
self.textField.placeholder = ""
Now textField doesn't show any placeholder later on if you want to show the placeholder simply set it with String that you want.
self.textField.placeholder = "Enter name"
 
    
    
        Nirav D
        
- 71,513
- 12
- 161
- 183
- 
                    1If you're using `UITextView` the solution becomes quite different. Here are a couple of solutions. [Floating Placeholder](http://stackoverflow.com/a/28271069/2079103) and [Fake Native Placeholders](http://stackoverflow.com/questions/27652227/text-view-placeholder-swift/41081244#41081244) – clearlight Jan 08 '17 at 00:58
- 
                    @clearlight Thanks for link, but OP already specify he want this functionality for `UITextField` not for `UITextView`. – Nirav D Jan 08 '17 at 05:35
- 
                    But visitors to the question may be interested in a related solution. Remember it's just a comment, not posted as an answer. – clearlight Jan 08 '17 at 05:36
- 
                    2@clearlight I know and that's why I have written *Thanks for link* – Nirav D Jan 08 '17 at 09:29