gpt4 book ai didi

iphone - iOS 7 上的 UITextView 的 inputView

转载 作者:可可西里 更新时间:2023-11-01 03:54:42 24 4
gpt4 key购买 nike

我正在尝试为 UITextField 创建自定义键盘,此 inputView 的背景应该是透明的,我已将 View 的 xib 文件中的背景颜色设置为“清晰颜色”。它在 iOS 6 和更早版本上运行良好。但在 iOS 7 上它不起作用知道如何让它工作吗?我希望它是完全透明的

最佳答案

这将在显示自定义键盘时将背景不透明度设置为零,并在显示普通键盘时将其重置回 1。

+ (void)updateKeyboardBackground {
UIView *peripheralHostView = [[[[[UIApplication sharedApplication] windows] lastObject] subviews] lastObject];

UIView *backdropView;
CustomKeyboard *customKeyboard;

if ([peripheralHostView isKindOfClass:NSClassFromString(@"UIPeripheralHostView")]) {
for (UIView *view in [peripheralHostView subviews]) {
if ([view isKindOfClass:[CustomKeyboard class]]) {
customKeyboard = (CustomKeyboard *)view;
} else if ([view isKindOfClass:NSClassFromString(@"UIKBInputBackdropView")]) {
backdropView = view;
}
}
}

if (customKeyboard && backdropView) {
[[backdropView layer] setOpacity:0];
} else if (backdropView) {
[[backdropView layer] setOpacity:1];
}
}

+ (void)keyboardWillShow {
[self performSelector:@selector(updateKeyboardBackground) withObject:nil afterDelay:0];
}

+ (void)load {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(keyboardWillShow) name:UIKeyboardWillShowNotification object:nil];
}

关于iphone - iOS 7 上的 UITextView 的 inputView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18984525/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com