x xVC.view.backgroundColor = [UIColor clearColor];
self.definesPresentationContext = YES;
navList.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[self presentViewController:navList animated:YES completion:nil];
UITextView光標(biāo)不居中的問(wèn)題吩跋。設(shè)置內(nèi)邊距回俐。根據(jù)實(shí)際需求調(diào)整
_textView.textContainerInset = UIEdgeInsetsMake(2, 0, 0, 0);
問(wèn)題:1:漢字輸入,代理走兩遍的問(wèn)題。2:英文掏觉、漢字翎苫、數(shù)字混合輸入旺聚,會(huì)造成自動(dòng)換行沈贝。通過(guò)替換富文本解決
- (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;
}
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者