vrw*_*wim 5 uitextfield inputview nslayoutconstraint
我有一个UITextField我设置inputView为自定义视图的位置.它的标准高度为216.我想将其设置为300或者屏幕的一半.
使用约束不是一种选择,因为它与默认值216冲突并且它会丢弃我的约束.
设置框架也不起作用.
有没有办法将其设置为更高的值?
vrw*_*wim 10
我通过设置autoResizingMask为None,并将其设置frame为所需的帧(使用UIScreen.mainScreen获取屏幕的宽度)来使其工作.在layoutSubviews被叫之前我做了这两件事.
EvG*_*yin 10
你需要子类化UIInputView和覆盖allowsSelfSizing返回值true,就像这样
class MyInputView: UIInputView {
// ... other code
override var inputViewStyle: UIInputViewStyle { get { return .default } }
override var allowsSelfSizing: Bool { get { return true } set{} }
// ... other code
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3737 次 |
| 最近记录: |