NYSKeyboardHelper
示例
要运行示例项目,首先克隆仓库,然后从 Example 目录运行 pod install
要求
安装
Cocoapods
NYSKeyboardHelper 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile
pod 'NYSKeyboardHelper'
Carthage
NYSKeyboardHelper可通过Carthage获取。要安装它,只需将以下行添加到您的Cartfile中。
github "matthiasnys/NYSKeyboardHelper"
使用
Storyboard
只需将约束设置到视图底部以及包裹文本输入的scrollview。将NSLayoutconstraint重写为'NYSKeyboardHelper'。这样,scrollview就会自动缩小,不会超出键盘。
在约束的属性中添加一些'额外缩进',以便在containerview和视图之间有一定的间距。
代码
let keyboardConstraint = NYSKeyboardHelper(item: self.view, attribute: .bottom, relatedBy: .equal, toItem: scrollView, attribute: .bottom, multiplier: 1.0, constant: 0.0)
keyboardConstraint.extraIndent = 10.0
self.view.addConstraint(keyboardConstraint)
将'extraIndent'属性设置为更大的间距。
作者
matthiasnys,[email protected]
许可证
NYSKeyboardHelper遵循MIT许可证。更多信息请参见LICENSE文件。