Swift TextView Placeholder封裝

ZY_FlyWay發表於2018-02-08

PlaceholderTextView

github地址:https://github.com/RainManGO/PlaceholderTextView

介紹

簡單的textView封裝,支援一些常用的功能

功能支援

  • Placeholder佔位字: 沒有內容的時候顯示的文字
  • 字數統計:顯示輸出字的個數 。
  • 字數限制: 輸入到限制字數不讓輸入。
  • retrun關閉鍵盤: 可選return關閉鍵盤。
  • 支援xib: xib storyBoard 建立直接對應類即可。

程式碼使用方法

      // 初始化placeholderTextView
       lazy var placeholderTextView = PlaceholerTextView(placeholder: "please input", placeholderColor: UIColor.lightGray, frame: CGRect(x: 40, y: 100, width: 320, height: 200))
    
        //設定是否顯示計算label
        placeholderTextView.isShowCountLabel = true
        //限制字數
        placeholderTextView.limitWords = 1000
        //是否return關閉鍵盤
        placeholderTextView.isReturnHidden = true

XIB程式碼使用方法

image

演示

image

相關文章