SMFloatingLabelTextField icon indicating copy to clipboard operation
SMFloatingLabelTextField copied to clipboard

Constraints are wrong if text property is set prior to layout

Open andreasmpet opened this issue 9 years ago • 0 comments

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 :)

andreasmpet avatar Sep 19 '16 14:09 andreasmpet