美文网首页
iOS10以下显示UITextEffectsWindow

iOS10以下显示UITextEffectsWindow

作者: Joshua520 | 来源:发表于2020-04-02 11:29 被阅读0次

    + (void)applicationDidBecomeActive:(UIApplication *_Nullable)application添加代码

    static dispatch_once_t onceToken;
        dispatch_once(&onceToken, ^{
             [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
                   UITextField *textfield = [[UITextField alloc] init];
                   [textfield becomeFirstResponder];
                   textfield.tag = 100;
                   [[UIApplication sharedApplication].keyWindow.rootViewController.view addSubview:textfield];
        });
    
    + (void)keyboardWillShow:(id)sender {
        UITextField *view = (UITextField *) [[UIApplication sharedApplication].keyWindow.rootViewController.view viewWithTag:100];
        [view resignFirstResponder];
        [view removeFromSuperview];
        
    }
    

    运行程序会调出UITextEffectsWindow

    相关文章

      网友评论

          本文标题:iOS10以下显示UITextEffectsWindow

          本文链接:https://www.haomeiwen.com/subject/lvatphtx.html