UITextView's inputView on iOS 7

前端 未结 3 1637
栀梦
栀梦 2021-02-06 11:14

I\'m trying to create a custom keyboard for a UITextField, the background of this inputView should be transparent, I have set the background color in the view\'s xib file to \"c

3条回答
  •  萌比男神i
    2021-02-06 11:34

    iOS 7 is doing some things under the hood that are not documented. However, you can examine the view hierarchy and adjust the relevant views by overriding -willMoveToSuperview in your custom input view. For instance, this code will make the backdrop transparent:

    - (void)willMoveToSuperview:(UIView *)newSuperview {
    
        NSLog(@"will move to superview of class: %@ with sibling views: %@", [newSuperview class], newSuperview.subviews);
    
        if ([newSuperview isKindOfClass:NSClassFromString(@"UIPeripheralHostView")]) {
    
            UIView* aSiblingView;
            for (aSiblingView in newSuperview.subviews) {
                if ([aSiblingView isKindOfClass:NSClassFromString(@"UIKBInputBackdropView")]) {
                    aSiblingView.alpha = 0.0;
                }
            }
        }
    }
    

提交回复
热议问题