设置present出的控制器透明

x xVC.view.backgroundColor = [UIColor clearColor];
self.definesPresentationContext = YES;
navList.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[self presentViewController:navList animated:YES completion:nil];
UITextView光标不居中的问题。设置内边距。根据实际需求调整
 _textView.textContainerInset = UIEdgeInsetsMake(2, 0, 0, 0);

问题:1:汉字输入,代理走两遍的问题。2:英文、汉字、数字混合输入,会造成自动换行。通过替换富文本解决

- (void)textViewDidChange:(UITextView *)textView {

    UITextRange *selectedRange = [textView markedTextRange];
    NSString *newText = [textView textInRange:selectedRange];//获取高亮部分
    if(newText.length>0){return;}
    
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    paragraphStyle.lineBreakMode = NSLineBreakByCharWrapping;
    NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:16],
                                 NSParagraphStyleAttributeName:paragraphStyle,
                                 NSForegroundColorAttributeName : RGBHexGm(0x999999)
                                 };
    textView.attributedText = [[NSAttributedString alloc] initWithString:textView.text attributes:attributes];
    
    if (textView.attributedText.length > 0) {
        self.sendMsgBtn.selected = YES;
    }else{
        self.sendMsgBtn.selected = NO;
    }

    CGFloat newHeight = textView.contentSize.height;
    
    //70的高度,保证最多显示3行。一行文字20高度左右。20x3<70
    if (newHeight < 70 && self.inputTextHeight < 70 && textView.contentOffset.y != 0) {
        textView.contentOffset = CGPointMake(0, 0);
    }
    
    if (newHeight < 70 && self.inputTextHeight < 70 && self.inputTextHeight != newHeight) {//改变了高度
        
        if (self.inputTextHeight < newHeight) {
            textView.contentOffset = CGPointMake(0, 16.6);//???偏移量减去次前textView高度。
        }
        
        self.inputTextHeight = newHeight;
        
        [self.keyboardView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.mas_equalTo(0);
            make.height.mas_equalTo(self.inputTextHeight+28);
        }];
        
        UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREENWIDTH, self.inputTextHeight+28) byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(15, 15)];
        self.tvShape.path = path.CGPath;
        _keyboardView.layer.mask = self.tvShape;
    }
}

你可能感兴趣的:(设置present出的控制器透明)