【发布时间】:2018-09-29 20:31:29
【问题描述】:
在我的键盘扩展中,有一个特定的 viewController 我想让键盘增加高度。在呈现这个 viewController 之前,主 UIInputViewController 自己调用这个方法,传递一个值 400.0:
- (void)setKeyboardHeight:(CGFloat)height {
if (self.heightConstraint) {
[self.view removeConstraint:self.heightConstraint];
self.heightConstraint = nil;
}
self.heightConstraint = [NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:height];
[self.view addConstraint:self.heightConstraint];
[UIView animateWithDuration:0.5 animations:^{
[self.view layoutIfNeeded];
}];
}
键盘的高度确实更改为指定值,但没有动画。这是不可能完成的,还是我只是在键盘扩展中使用了错误的方法?
【问题讨论】:
标签: ios autolayout ios-autolayout ios-keyboard-extension