Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MKTextField attributed placeholder support #7

Open
siggb opened this issue Dec 3, 2014 · 0 comments
Open

MKTextField attributed placeholder support #7

siggb opened this issue Dec 3, 2014 · 0 comments

Comments

@siggb
Copy link

siggb commented Dec 3, 2014

Here code for attributed placeholder support:

override var attributedPlaceholder: NSAttributedString! {
        didSet {
            floatingLabel.text = attributedPlaceholder.string
            floatingLabel.sizeToFit()
            setFloatingLabelOverlapTextField()
        }
    }

I also wrote wrapped method for setting attributed placeholder:

func setAttributedPlaceholder(text : NSString) {
        var attrs = [NSFontAttributeName : self.font, NSForegroundColorAttributeName : UIColor.grayColor()]
        var str = NSAttributedString(string: text, attributes: attrs)

        self.attributedPlaceholder = str
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant