【发布时间】:2020-08-18 04:47:34
【问题描述】:
我创建了一个自定义键盘,它工作正常。我将高度约束设置为与默认键盘相同。问题是,当键盘第一次启动时,它从键盘下方开始,然后将自身定位到正确的高度。
有人知道为什么会这样吗?
我附上了两张启动时和启动后的图片:
我正在硬编码视图高度。
override func viewDidLayoutSubviews() {
if UIScreen.main.bounds.width < UIScreen.main.bounds.height {
if UIScreen.main.bounds.height == 667 ||
UIScreen.main.bounds.height == 812 {
viewHeight.constant = 216
} else {
viewHeight.constant = 226
}
} else if UIScreen.main.bounds.width > UIScreen.main.bounds.height {
if (UIScreen.main.bounds.height == 375 && UIScreen.main.bounds.width == 667) || UIScreen.main.bounds.height == 812 || (UIScreen.main.bounds.height == 414 && UIScreen.main.bounds.width == 736) {
viewHeight.constant = 158
} else {
viewHeight.constant = 168
}
}
}
【问题讨论】:
标签: ios swift autolayout nslayoutconstraint custom-keyboard