#import "ViewController.h"
@interface ViewController ()<UITextFieldDelegate> {
UITextField *currentTextFeild;
UIButton *touchButton;
}
@end
@implementation ViewController
- ( void )viewDidLoad {
[ super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UITextField *textFields = [[UITextField alloc] initWithFrame:CGRectMake(15, 50, self .view.bounds.size.width-15*2, 40)];
textFields.backgroundColor = [UIColor brownColor];
textFields.layer.cornerRadius = 5;
textFields.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 40)];
textFields.leftViewMode = UITextFieldViewModeAlways; //这两行是为了不让Text太贴textField的左边
textFields.placeholder = @ "请输入手机号" ;
textFields.delegate = self ;
[ self .view addSubview:textFields];
currentTextFeild = textFields;
UIButton *enableButton = [UIButton buttonWithType:UIButtonTypeCustom];
enableButton.frame = CGRectMake(15, 100, self .view.bounds.size.width-15*2, 40);
enableButton.layer.cornerRadius = 5;
enableButton.backgroundColor = [UIColor grayColor];
[enableButton setTitle:@ "没内容不可点击" forState:UIControlStateNormal];
[enableButton setTitle:@ "可以按了" forState:UIControlStateSelected];
[enableButton setTitle:@ "按下去了" forState:UIControlStateHighlighted];
enableButton.enabled = NO ;
[enableButton addTarget: self action: @selector (btnClick) forControlEvents:UIControlEventTouchUpInside];
[ self .view addSubview:enableButton];
touchButton = enableButton;
}
- ( void )btnClick {
}
|