jobandtalent / AnimatedTextInput

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

LineHeight only applies correctly to the first input in ViewController #106

Open PabloDomine opened 6 years ago

PabloDomine commented 6 years ago

Hi! I'm facing an issue with the lineHeight when I have multiple AnimatedTextInput in the same ViewController. As you can see in the following screenshot, all style parameters are applied to all inputs correctly, except the line height parameter, which is only applied to the first one.

img_6661 img_6662 img_6663

Code in ViewController (Called in viewDidLoad())

private func setupForm() {
        let style = Style.SilenceTextInputStyle()

        nameTextInput.placeHolderText = "SignUpName".localized
        nameTextInput.style = style
        nameTextInput.type = .standard
        nameTextInput.returnKeyType = .next
        nameTextInput.delegate = self

        surnameTextInput.placeHolderText = "SignUpSurname".localized
        surnameTextInput.style = style
        surnameTextInput.type = .standard
        surnameTextInput.returnKeyType = .next
        surnameTextInput.delegate = self

        phoneTextInput.placeHolderText = "SignUpMobile".localized
        phoneTextInput.style = style
        phoneTextInput.type = .phone
        phoneTextInput.returnKeyType = .next
        phoneTextInput.delegate = self

        passwordTextInput.placeHolderText = "SignUpPassword".localized
        passwordTextInput.style = style
        passwordTextInput.type = .password(toggleable: true)
        passwordTextInput.returnKeyType = .continue
        passwordTextInput.delegate = self
    }

They all have the exact same style SilenceTextInputStyle

extension Style {
    struct SilenceTextInputStyle: AnimatedTextInputStyle {
        let activeColor: UIColor = Color.inputActive
        let placeholderInactiveColor: UIColor = Color.inputInactive
        let inactiveColor: UIColor = Color.inputInactive
        let lineInactiveColor: UIColor = Color.inputInactive
        let lineActiveColor: UIColor = Color.inputActive
        let lineHeight: CGFloat = 4.0
        let errorColor: UIColor = Color.inputError
        let textInputFont: UIFont = Font.with(name: .gothamHTFBook, size: 17)
        let textInputFontColor: UIColor = Color.inputText
        let placeholderMinFontSize: CGFloat = 11
        let counterLabelFont: UIFont? = Font.with(name: .gothamHTFMedium, size: 11)
        let leftMargin: CGFloat = 0
        let topMargin: CGFloat = 20
        let rightMargin: CGFloat = 0
        let bottomMargin: CGFloat = 10
        let yHintPositionOffset: CGFloat = 0
        let yPlaceholderPositionOffset: CGFloat = 0
        let textAttributes: [String : Any]? = nil
    }
}

Here storyboard:

screen shot 2018-08-28 at 17 54 25

And lastly, here is a debugPrint of the style property in the surnameTextInput after style was setted: (The lineHeight is correct)

(lldb) po surnameTextInput.style
▿ SilenceTextInputStyle
  - lineHeight : 4.0
  - placeholderMinFontSize : 11.0
  ▿ counterLabelFont : Optional<UIFont>
  - leftMargin : 0.0
  - topMargin : 20.0
  - rightMargin : 0.0
  - bottomMargin : 10.0
  - yHintPositionOffset : 0.0
  - yPlaceholderPositionOffset : 0.0
  - textAttributes : nil

I tried a couple things like:

No luck.

Hope you can help me, Thanks!