Skyscanner / SkyFloatingLabelTextField

A beautiful and flexible text field control implementation of "Float Label Pattern". Written in Swift.
Apache License 2.0
4.09k stars 540 forks source link

How to have placeholder with mandatory symbol * #343

Open arishanapalli opened 1 year ago

arishanapalli commented 1 year ago

How to have SkyFloatingLabelTextField with mandatory symbols with red colour. Placeholder text is "Enter your password ", The * should be in different colour?

ronak-selldo commented 10 months ago

You can use this

        let placeholderAttriburedString = NSMutableAttributedString(string: "Email")
        if let isRequired = dataSource["required"] as? Bool, isRequired {
            let asterix = NSAttributedString(string: " *", attributes: [.foregroundColor: UIColor.red])
            placeholderAttriburedString.append(asterix)
        }
        self.textField.attributedPlaceholder = placeholderAttriburedString