这是一个添加了占位符支持的轻量级 UITextView 子类。
安装
Swift Package Manager
使用-
要将
RSKPlaceholderTextView
包添加到您的Xcode项目中,请选择“文件”>“Swift包”>“添加包依赖”,并输入仓库URL。https://github.com/ruslanskorb/RSKPlaceholderTextView.git
CocoaPods
使用-
将pod
RSKPlaceholderTextView
添加到您的 Podfile。pod 'RSKPlaceholderTextView'
-
在终端中运行
pod install
,然后打开您的应用的.xcworkspace
文件以打开Xcode。
Carthage
使用-
将
ruslanskorb/RSKPlaceholderTextView
项目添加到您的 Cartfile。github "ruslanskorb/RSKPlaceholderTextView"
-
运行
carthage update
,然后按照添加iOS和/或Mac框架所需额外的步骤来将框架添加到您的项目中。
基本使用
导入模块。
import RSKPlaceholderTextView
只需创建一个文本视图并设置占位符。
override func viewDidLoad() {
super.viewDidLoad()
self.textView = RSKPlaceholderTextView(frame: CGRect(x: 0, y: 20, width: self.view.frame.width, height: 100))
self.textView.placeholder = "What do you want to say about this event?"
self.view.addSubview(self.textView)
}
演示
在Xcode中构建和运行 RSKPlaceholderTextViewExample
项目以查看 RSKPlaceholderTextView
的实际效果。尽情享受,找出定制钩子。
联系
Ruslan Skorb
许可协议
本项目遵循Apache许可协议,版本2.0。有关更多信息,请参阅LICENSE文件。