vendredi 8 mai 2015

Weird swift behaviour on UITextField

Scenario: I'm setting the text font and size for my UITextField. They also have placeholders.

        let font = UIFont(name: "FlamaSemicondensed-Book", size: 18)

        let attributesDictionary = [NSForegroundColorAttributeName: DefaultSystemColor.DarkRed]

        // Textfileds without borders (and placeholders)
        UsernameTextField.borderStyle = UITextBorderStyle.None
        UsernameTextField.font = font
        UsernameTextField.textColor = DefaultSystemColor.DarkRed
        UsernameTextField.attributedPlaceholder = NSAttributedString(string: "Email", attributes: attributesDictionary)

I'm configuring (in AppDelegate) a global UI setting, that formats all of my UILabels for a certain font size.

    let font = UIFont(name: "FlamaSemicondensed-Book", size: 13)!
    var labelAppearace = UILabel.appearance()
    labelAppearace.font = font

What's weird in here:

When this UITextField is selected and I'm typing the format is the one I set for the text field (the placeholder are OK too).

But when I leave the field it assumes the behaviour of the UILabel.

I know that because if I comment the UILabel format the textField works properly.

Does anybody have any idea why does it happens?

Aucun commentaire:

Enregistrer un commentaire