本帖最后由 sabjiang 于 2014-4-26 22:07 编辑
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- UIButton *btn=[[UIButton alloc] init];
- [btn setFrame:CGRectMake(10,10, 100, 100)];
- [btn setImage:[UIImage imageNamed:@"btn_01.png"] forState:UIControlStateNormal];
- //设置按钮上的文字
- [btn setTitle:@"点我呀!" forState:UIControlStateNormal];
- [btn setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
-
- [btn setImage:[UIImage imageNamed:@"btn_02.png"] forState:UIControlStateHighlighted];
- //设置按钮上的文字
- [btn setTitle:@"摸我干啥!" forState:UIControlStateHighlighted];
- [btn setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
- [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:btn];
-
- UITextField *text = [[UITextField alloc] init];
- [text setFrame:CGRectMake(10, 120, 300, 40)];
- [text setText:@"luseike"];
- [text setBorderStyle:UITextBorderStyleLine];
- [self.view addSubview:text];
- }
复制代码
|
|