iOS学习交流iOS Developer

iOS 中TextField改变secureTextEntry改

2016-06-03  本文已影响709人  jy__Lu

默认状态下TextField字体是这个样子的

QQ20160603-0@2x.png

但是当切换到密文状态再切换回来之后,就变成了下面的样子


QQ20160603-1@2x.png

不知道为什么苹果默认在切换secure状态是要改变TextField的字体,其实在切换完secure状态变为非密文状态的时候默认给TextField设置下字体就好可以解决了,大概就是这样

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UITextField *textField;
@property (weak, nonatomic) IBOutlet UIButton *changeBtn;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.textField.font = [UIFont fontWithName:@"System" size:15];
}

- (IBAction)changeSecure:(id)sender {
    self.textField.secureTextEntry = !self.textField.secureTextEntry;
    self.textField.font = [UIFont fontWithName:@"System" size:15];
}
上一篇 下一篇

猜你喜欢

热点阅读