开发者

Where the magnifying glass takes the color when editing a UITextField?

开发者 https://www.devze.com 2023-01-14 05:42 出处:网络
I have a UITextField with background color set to ClearColor and the text is white. The view has an image as background dark.

I have a UITextField with background color set to ClearColor and the text is white. The view has an image as background dark.

When I want to edit the text, the magnifying glass background is also white or very light color, and you can开发者_如何学Python't see the text.

What can I do to force the background of the magnifying glass to be darker ?

thanks!

r.


UITextField sets the magnifying glass background as the textfield's background color. So, set the backgroundColor property of your UITextField, like so:

myTextField.backgroundColor = [UIColor blackColor];

Substitute that UIColor with another dark color if you so wish.


Try to use little shadow for text:

// text shadow
text.layer.shadowRadius = 0.0f;
text.layer.shadowOffset = CGSizeMake(1.0f, 1.0f);
text.layer.shadowColor = [[UIColor colorWithRed:(255.0/255.0) green:(255.0/255.0) blue:(255.0/255.0) alpha:1.0f] CGColor];
text.layer.shadowOpacity = 1.0;

Than you can read text under the magnifying glass tint.


yakovlev has a good solution here, namely setting an appropriate backgroundColor and then programmatically creating a background of the UIView immediately behind the UITextView.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号