Last active
August 31, 2015 06:06
-
-
Save appyaaron/9d7a09d33b173ec49ca1 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 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