瀏覽代碼

添加默认字位置设置 属性

jsonwang 3 年之前
父節點
當前提交
1192207dab
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      BFFramework/Classes/Base/View/PQTextView.swift

+ 4 - 2
BFFramework/Classes/Base/View/PQTextView.swift

@@ -16,6 +16,8 @@ open class PQTextView: UITextView {
     public  var maxTextLength : Int?
     // 输入个数超过时提示
     public  var maxTextLengthRemind : String?
+    // add by ak 默认字的起点位置
+    public  var placeHolderDefultPoint = CGPoint.init(x: 5, y: 7)
     /// setNeedsDisplay调用drawRect
     public  var placeHolder: String = "" {
         didSet {
@@ -87,8 +89,8 @@ open class PQTextView: UITextView {
             newRect.origin.x = (rect.width - size.width) / 2
             newRect.origin.y = (rect.height - size.height) / 2
         } else {
-            newRect.origin.x = placeHolder.contains("未识别到文字") ? 0 : 5
-            newRect.origin.y = placeHolder.contains("未识别到文字") ? 0 : 7
+            newRect.origin.x = placeHolder.contains("未识别到文字") ? 0 : placeHolderDefultPoint.x
+            newRect.origin.y = placeHolder.contains("未识别到文字") ? 0 : placeHolderDefultPoint.y
         }
         (placeHolder as NSString).draw(in: newRect, withAttributes: [NSAttributedString.Key.font: font ?? UIFont.systemFont(ofSize: 14), NSAttributedString.Key.foregroundColor: placeHolderColor])
     }