-
-
Save lborgav/4832807aa5c10c4868bd to your computer and use it in GitHub Desktop.
A custom UITextField that allows you to easily set the placeholder color from your storyboard!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
@IBDesignable class CustomTextField: UITextField { | |
@IBInspectable var placeholderColor: UIColor = UIColor.lightGrayColor() { | |
didSet { | |
let canEditPlaceholderColor = self.respondsToSelector(Selector("setAttributedPlaceholder:")) | |
if (canEditPlaceholderColor) { | |
self.attributedPlaceholder = NSAttributedString(string: placeholder, attributes:[NSForegroundColorAttributeName: placeholderColor]); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment