A custom implementation of UITextView with a placeholder and character count. This implementation contains the ability to customize top, left, and right insets individually. SMTextView is compatible with Interface Builder. SMTextView also contains a character count that can be enabled/disabled. To disable, simply set isCharacterCountEnabled to false.
NOTE: Due to character count label, bottomInset is currently no longer customizable. This may be re-enabled in the future. If character count is disabled, bottomInset = topInset.
To run the example project, clone the repo, and run pod install
from the Example directory first.
Instead of using Interface Builder, you can customize properties manually in code.
By default, SMTextView's character count is enabled. To hide the character count for SMTextView, simply set isCharacterCountEnabled = false
Optionally, you can set maxCharacterCount
. The default character count is 100.
@IBOutlet weak var textView: SMTextView!
...
override func viewDidLoad() {
super.viewDidLoad()
textView.placeholder = "Enter details about the event."
textView.placeholderColor = .purple
textView.topInset = 45
textView.leftInset = 15
textView.rightInset = 15
textView.maxCharacterCount = 200
}
SMTextView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "SMTextView"
Alternatively, you can simply add SMTextView.swift
to your project.
SMTextView is available under the MIT license. See the LICENSE file for more info.