nagging

I’ve been writing business code for a long time, and I feel like I’m standing still. In order to make their career longer, but also in order to make their own progress, so there is a summary of the use of UITextField, of course, this is just a beginning, in the future, I will summarize more things, more in-depth study of the principle and essence, know how and why!! Efforts!!!!!!!!!

The UI display

portal

Forgot to put the address before, hee hee!! GitHub

className

LCLTextField version 0.1

New features

  1. Empty empty color: an empty color
  2. MaxLength: indicates the maximum text input length
  3. IsHiddenKeyboardIfEditing: when clicking the textField, if the keyboard is hidden, shows the keyboard; If the keyboard is displayed, hide the keyboard
  4. TextInsets: Add padding
  5. AddBorderAll: All borders
  6. AddBorderLeft: Adds a left border
  7. AddBorderRight: Adds the right border
  8. AddBorderTop: Adds an upper border
  9. AddBorderBottom: Adds the bottom border
  10. AddCornerAll: All rounded corners
  11. AddCorner: Adds the specified rounded corner

The code shown

  • 1

        let width = UIScreen.main.bounds.width
        
        lettextField = LCLTextField() textField.frame = CGRect(x: 40, y: 100, width: width - 80, height: 40); TextField. TextAlignment =.left self.view.addSubView (textField) // Cursor color textField. TintColor =.green // Text color TextField. TextColor =. Green. / / the clues color textField placeholderColor =. The blue textField. The placeholder ="Please enter". / / the biggest text length textField maxLength = 10 / / click textField, if handled editor state, hidden keyboard textField. IsHiddenKeyboardIfEditing =trueTextField. TextInsets = UIedgeInsets. init(top: 0, left: 10, bottom: 0, right: 0) TextField. AddCornerAll (color:.red, borderWidth: 2)Copy the code
  • Show 2

        let width = UIScreen.main.bounds.width
        
        lettextField = LCLTextField() textField.frame = CGRect(x: 40, y: 160, width: width - 80, height: 40); Textfield-textalignment =.center self.view.addSubView (textField) // Cursor color textfield-TintColor =.orange // Text color TextField. TextColor =. Orange. / / the clues color textField placeholderColor =. Green textField. The placeholder ="Please enter". / / the biggest text length textField maxLength = 10 / / click textField, if handled editor state, hidden keyboard textField. IsHiddenKeyboardIfEditing =trueTextField. TextInsets = UIedgeInsets. init(top: 0, left: 10, bottom: 0, right: 0) AddBorderLeft (color:.red, borderWidth: 2) textField. AddBorderRight (color:.red, borderWidth: 2) .orange, borderWidth: 2) textField.addBorderTop(color: .yellow, borderWidth: 2) textField.addBorderBottom(color: .green, borderWidth: 2)Copy the code
  • Show three

        let width = UIScreen.main.bounds.width
        
        lettextField = LCLTextField() textField.frame = CGRect(x: 40, y: 220, width: width - 80, height: 40); TextField. BackgroundColor =. Cyan textField. TextAlignment =. The right self. The addSubview (textField) / / the cursor color TextField. TintColor =. White / / text color textField textColor =. The white/color/clues textField. PlaceholderColor =. LightGray textField.placeholder ="Please enter". / / the biggest text length textField maxLength = 10 / / click textField, if handled editor state, hidden keyboard textField. IsHiddenKeyboardIfEditing =trueTextField. TextInsets = UIedgeInsets. init(top: 0, left: 10, bottom: 0, right: 0) 10) // textField.AddCorner(isTopLeft:true, isTopRight: false, isBottomLeft: false, isBottomRight: true, radius: 20)
Copy the code

Afterword.

In fact, UITextField needs to meet a lot of business needs, to pass the test also needs a lot of consideration and restrictions, of course, I was also our product sister and test sister staring at the improvement of one by one, are tears!! So, there is still a lot to write, I will add slowly!

By the way, I actually have a blog: The Cloud Breeze blog