jobandtalent / AnimatedTextInput

Animated UITextField and UITextView replacement for iOS
MIT License
760 stars 128 forks source link

Underlyne style #102

Open zvjerka24 opened 6 years ago

zvjerka24 commented 6 years ago

If you put two AnimatedTextInput controls on the same screen and if all has the same custom style

        textinput2.style = LoginTextInputStyle()
        textInput1.style = LoginTextInputStyle()
        textInput1.backgroundColor = .yellow
        textinput2.backgroundColor = .green
        textInput3.style = LoginTextInputStyle()
        textInput3.backgroundColor = .red

where line height is defined in LoginTextInputStyle.

struct LoginTextInputStyle: AnimatedTextInputStyle {
   ...
    var lineHeight: CGFloat = 3
}

Style has been applied, but line height is correct only for the first text input, on others it is 0,5.

1

If apply custom style is moved to viewDidAppear, all of the text inputs has line height 0,5.

2
zvjerka24 commented 6 years ago

Just notice main reason for such behavior. It seems that layout constraints are not create right way, or not cleaned before new are created.

[LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. ( "<NSLayoutConstraint:0x60c0002809b0 AnimatedTextInput.AnimatedLine:0x7fc82580f2b0.height == 0.5 (active)>", "<NSLayoutConstraint:0x60800009fb30 AnimatedTextInput.AnimatedLine:0x7fc82580f2b0.height == 1 (active)>" )

Will attempt to recover by breaking constraint <NSLayoutConstraint:0x60800009fb30 AnimatedTextInput.AnimatedLine:0x7fc82580f2b0.height == 1 (active)>