iOS实现经典登录页面,手机号自动格式化
核心
#define RGB(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
@implementation LJPhoneTextField
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.leftViewMode = UITextFieldViewModeAlways;
self.clearButtonMode = UITextFieldViewModeWhileEditing;
self.backgroundColor = [UIColor whiteColor];
self.textColor = RGB(51,51,51);
[self addTarget:self action:@selector(reformatAsPhoneNumber:) forControlEvents:UIControlEventEditingChanged];
}