Skip to content

Commit d4a8449

Browse files
committed
Merge branch 'MojtabaHs-master'
2 parents f1ccc59 + 94c3547 commit d4a8449

5 files changed

Lines changed: 22 additions & 22 deletions

File tree

Example/GrowingTextView/Base.lproj/Main.storyboard

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
<userDefinedRuntimeAttribute type="number" keyPath="maxHeight">
140140
<real key="value" value="70"/>
141141
</userDefinedRuntimeAttribute>
142-
<userDefinedRuntimeAttribute type="string" keyPath="placeHolder" value="Say something..."/>
142+
<userDefinedRuntimeAttribute type="string" keyPath="placeholder" value="Say something..."/>
143143
</userDefinedRuntimeAttributes>
144144
<connections>
145145
<outlet property="delegate" destination="MoA-Hl-V8R" id="oZX-Qv-oXj"/>
@@ -216,13 +216,13 @@
216216
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
217217
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
218218
<subviews>
219-
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="KoN-fe-F8s" customClass="GrowingTextView" customModule="GrowingTextView">
219+
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="KoN-fe-F8s" customClass="GrowingTextView" customModule="GrowingTextView">
220220
<rect key="frame" x="8" y="144" width="359" height="33"/>
221221
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
222222
<fontDescription key="fontDescription" type="system" pointSize="14"/>
223223
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
224224
<userDefinedRuntimeAttributes>
225-
<userDefinedRuntimeAttribute type="string" keyPath="placeHolder" value="Say something..."/>
225+
<userDefinedRuntimeAttribute type="string" keyPath="placeholder" value="Say something..."/>
226226
<userDefinedRuntimeAttribute type="number" keyPath="maxLength">
227227
<integer key="value" value="200"/>
228228
</userDefinedRuntimeAttribute>

Example/GrowingTextView/Example1.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ class Example1: UIViewController {
3131
textView.maxLength = 200
3232
textView.maxHeight = 70
3333
textView.trimWhiteSpaceWhenEndEditing = true
34-
textView.placeHolder = "Say something..."
35-
textView.placeHolderColor = UIColor(white: 0.8, alpha: 1.0)
34+
textView.placeholder = "Say something..."
35+
textView.placeholderColor = UIColor(white: 0.8, alpha: 1.0)
3636
textView.font = UIFont.systemFont(ofSize: 15)
3737
textView.translatesAutoresizingMaskIntoConstraints = false
3838
inputToolbar.addSubview(textView)

Example/GrowingTextView/Example3.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Example3: UIViewController {
1818

1919
// *** Customize GrowingTextView ***
2020
textView.layer.cornerRadius = 4.0
21-
textView.placeHolder = "Say something..."
21+
textView.placeholder = "Say something..."
2222
textView.font = UIFont.systemFont(ofSize: 15)
2323
textView.minHeight = 30
2424
textView.maxHeight = 100

Pod/Classes/GrowingTextView.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ open class GrowingTextView: UITextView {
3333
@IBInspectable open var maxHeight: CGFloat = 0 {
3434
didSet { forceLayoutSubviews() }
3535
}
36-
@IBInspectable open var placeHolder: String? {
36+
@IBInspectable open var placeholder: String? {
3737
didSet { setNeedsDisplay() }
3838
}
39-
@IBInspectable open var placeHolderColor: UIColor = UIColor(white: 0.8, alpha: 1.0) {
39+
@IBInspectable open var placeholderColor: UIColor = UIColor(white: 0.8, alpha: 1.0) {
4040
didSet { setNeedsDisplay() }
4141
}
42-
@IBInspectable open var attributedPlaceHolder: NSAttributedString? {
42+
@IBInspectable open var attributedPlaceholder: NSAttributedString? {
4343
didSet { setNeedsDisplay() }
4444
}
4545

@@ -144,24 +144,24 @@ open class GrowingTextView: UITextView {
144144
let yValue = textContainerInset.top
145145
let width = rect.size.width - xValue - textContainerInset.right
146146
let height = rect.size.height - yValue - textContainerInset.bottom
147-
let placeHolderRect = CGRect(x: xValue, y: yValue, width: width, height: height)
147+
let placeholderRect = CGRect(x: xValue, y: yValue, width: width, height: height)
148148

149-
if let attributedPlaceholder = attributedPlaceHolder {
150-
// Prefer to use attributedPlaceHolder
151-
attributedPlaceholder.draw(in: placeHolderRect)
152-
} else if let placeHolder = placeHolder {
153-
// Otherwise user placeHolder and inherit `text` attributes
149+
if let attributedPlaceholder = attributedPlaceholder {
150+
// Prefer to use attributedPlaceholder
151+
attributedPlaceholder.draw(in: placeholderRect)
152+
} else if let placeholder = placeholder {
153+
// Otherwise user placeholder and inherit `text` attributes
154154
let paragraphStyle = NSMutableParagraphStyle()
155155
paragraphStyle.alignment = textAlignment
156156
var attributes: [NSAttributedStringKey: Any] = [
157-
.foregroundColor: placeHolderColor,
157+
.foregroundColor: placeholderColor,
158158
.paragraphStyle: paragraphStyle
159159
]
160160
if let font = font {
161161
attributes[.font] = font
162162
}
163163

164-
placeHolder.draw(in: placeHolderRect, withAttributes: attributes)
164+
placeholder.draw(in: placeholderRect, withAttributes: attributes)
165165
}
166166
}
167167
}

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ override func viewDidLoad() {
7777
| ------------------------------ | ------------------- | ---------------------------------------- | ------------------------------- |
7878
| *maxLength* | Int | Maximum text length. Exceeded text will be trimmed. 0 means no limit. | *0* |
7979
| *trimWhiteSpaceWhenEndEditing* | Bool | Trim white space and new line characters when textview did end editing. | *true* |
80-
| *placeHolder* | String? | PlaceHolder text. | *nil* |
81-
| *placeHolderColor* | UIColor | PlaceHolder text color. | UIColor(white: 0.8, alpha: 1.0) |
82-
| *attributedPlaceHolder* | NSAttributedString? | Attributed PlaceHolder text. | *nil* |
80+
| *placeholder* | String? | Placeholder text. | *nil* |
81+
| *placeholderColor* | UIColor | Placeholder text color. | UIColor(white: 0.8, alpha: 1.0) |
82+
| *attributedPlaceholder* | NSAttributedString? | Attributed Placeholder text. | *nil* |
8383
| *minHeight* | CGFloat | Minimum height of textview. | *0.0* |
8484
| *maxHeight* | CGFloat | Maximum height of textview. | *0.0* |
8585

@@ -88,8 +88,8 @@ override func viewDidLoad() {
8888
```swift
8989
textView.maxLength = 140
9090
textView.trimWhiteSpaceWhenEndEditing = false
91-
textView.placeHolder = "Say something..."
92-
textView.placeHolderColor = UIColor(white: 0.8, alpha: 1.0)
91+
textView.placeholder = "Say something..."
92+
textView.placeholderColor = UIColor(white: 0.8, alpha: 1.0)
9393
textView.minHeight = 25.0
9494
textView.maxHeight = 70.0
9595
textView.backgroundColor = UIColor.whiteColor()

0 commit comments

Comments
 (0)