White Text in UITextField = Invisible text in iPhone copy/paste select. Fix?

后端 未结 5 1892
臣服心动
臣服心动 2020-12-15 15:20

If I have white text in my UITextField, the selection window (when selecting text) is invisible because the background on the little window is also white.

Any way to

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-15 15:49

    Glass takes color from textView.backgroundColor. So I made some dirty hack that works great:

    @interface FakeBgTextView : UITextView {
        UIColor *_fakeBackgroundColor;
    }
    
    - (UIColor *)backgroundColor;
    - (void)setFakeBackgroundColor:(UIColor *)color;
    @end
    
    @implementation FakeBgTextView
    ...
    - (UIColor *)backgroundColor {
        return _fakeBackgroundColor;
    }
    
    - (void)setFakeBackgroundColor:(UIColor *)color {
        [_fakeBackgroundColor release];
        _fakeBackgroundColor = [color retain];
    }
    ...
    @end
    

提交回复
热议问题