在 didEndEditing 中更改 UITextField 边框样式 [英] Changing UITextField borderstyle in didEndEditing

查看:29
本文介绍了在 didEndEditing 中更改 UITextField 边框样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在用户编辑时突出显示 uitextfield,因此我将文本字段的边框样式默认设置为 UITextBorderStyleNone 并使用 uitextfields 委托如下:

I want to highlight a uitextfield when a user is editing it, so I set my textfield's borderstyle default to UITextBorderStyleNone and use the uitextfields delegates as following:

- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    [textField setBorderStyle:UITextBorderStyleBezel];
}

- (void)textFieldDidEndEditing:(UITextField *)textField
{
    [textField setBorderStyle:UITextBorderStyleNone];
}

Bezel 样式被设置和渲染,但是当调用 endediting 时,没有应用 none 样式.我尝试将 none 更改为另一个(例如圆形矩形),但该渲染正确.

The Bezel style gets set and rendered, but when the endediting is called, the none style is not applied. I tried changing the none to another (say rounded rect), but that one does render properly.

有人知道我怎样才能让它工作吗?

Does anybody know how I can get this to work?

推荐答案

是的,这是一个错误.无论如何,我已经使用此代码解决了:

Yes, it is a bug. Anyway, I've solved by using this code:

textField.borderStyle = UITextBorderStyleLine;
textField.borderStyle = UITextBorderStyleNone;

这不是一个非常漂亮的方法,但在 Apple 修复此问题之前它会起作用.

This isn't a very beautiful method, but it does the work until Apple fixes this issue.

这篇关于在 didEndEditing 中更改 UITextField 边框样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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