彩色UITextview的自动更正问题 [英] Autocorrect issue with a colored UITextview

查看:134
本文介绍了彩色UITextview的自动更正问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用带有蓝色背景的textview。

I'm using in my app a textview with blue colored background.

启用自动更正后,无论何时更正单词,都会在单词周围形成一个白框文本的颜色也会发生变化。

When autocorrect is enabled, whenever it corrects a word a white box forms around the word and the text's color changes also.

关于如何阻止这种影响的任何想法?

Any ideas on how to stop this effect?

推荐答案

不,我认为你不能改变叠加的颜色或开箱即用的文本颜色..

Nope, I think you can't change the color of the overlay or the textcolor out of the box..

如果你在<您的视图的code> - (void)layoutSubviews {..} 您将看到UIKit在文本上方绘制了一个'UITextSelectionView'...

This is a hard one, if you put a breakpoint in - (void) layoutSubviews {..} of your view you'll see UIKit has drawn a 'UITextSelectionView' above the text...

我试图将UITextView子类化,以查看它的layoutSubviews是否被触发,它似乎就是这样!

I tried to subclass UITextView to see if its layoutSubviews get's fired and it seems it does!

所以我试图删除叠加层:

So I tried to remove the overlay:

- (void) layoutSubviews {
    [super layoutSubviews];

    for (UIView *subview in self.subviews) {
        if ([NSStringFromClass([subview class]) isEqualToString:@"UITextSelectionView"]) {
            DLog(@"Subview %@", [subview debugDescription]);
            [subview removeFromSuperview];
            break;
        }
    }
}

它有效..但导致错过光标,并禁用任何选择:(

And it worked.. but that results in missing the cursor, and disabling any selection :(

我认为你必须禁用自动更正..

I think you'll have to disable autocorrect..

如果有人找到真正的答案,我会重新开始赏金!

这篇关于彩色UITextview的自动更正问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆