Parcourir la source

添加默认字位置设置 属性

jsonwang il y a 3 ans
Parent
commit
1192207dab
1 fichiers modifiés avec 4 ajouts et 2 suppressions
  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])
     }