Skip to content

Constraints are wrong if text property is set prior to layout #2

@andreasmpet

Description

@andreasmpet

Hi! I noticed that if I set the .text property of the text field to a value prior to the view being laid out, the first time the placeholder animates, it will animate based on a very wrong location. My fix is to also update the constraints when the bounds of the view changes. Here's some code you can add to the class:

- (void)setBounds:(CGRect)bounds
{
    BOOL boundsChanged = !CGRectEqualToRect(self.bounds, bounds);
    [super setBounds:bounds];
    if (boundsChanged) {
        [self updateConstraintsToCurrentState];
    }
}

Thanks for the nice pod :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions