// 按钮
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
// 设置大小
btn.frame = KFrame(10, 120, 100, 30);
// 给按钮设置标题
[btn setTitle:@"play" forState:UIControlStateNormal];
btn.backgroundColor =[UIColor blackColor];
// 设置背景图片
// [btn setBackgroundImage:[UIImage imageNamed:@"/Users/ibokan/Desktop/I3K8)IOKR@]FG4M2K[S_]0E.gif"] forState:UIControlStateNormal];
// 为按钮添加事件
[btn addTarget:self
action:@selector(click)
forControlEvents:UIControlEventTouchUpInside];// 触摸按钮触发(点击触发)
UITextField *textfield = [[UITextField alloc]initWithFrame:CGRectMake(0, 20, 150, 30)];
// 设置提示文字
textfield.placeholder = @"请输入用户名...";// 思考改变提示文字颜色
textfield.borderStyle = UITextBorderStyleLine;
[self.window addSubview:textfield];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(0, 60, 80, 30);
// 设置图片,标题不可见
//[btn setImage:[UIImage imageNamed:@"btnBG.png"] // 占有内存少,适用于apple
// forState:UIControlStateNormal];
//[btn setTitleColor:[UIColor redColor] forState:0];
//[btn setTitle:@"123" forState:0];
//[btn setTitle:@"[123]" forState:UIControlStateHighlighted];
// 设置背景图片,标题可见
[btn setBackgroundImage:[UIImage imageNamed:@"btnBG.png"] forState:0];
[btn setTitleColor:[UIColor redColor] forState:0];
//不同类型的button 标题不同
[btn setTitle:@"123" forState:0];
[btn setTitle:@"[123]" forState:UIControlStateHighlighted];
[self.window addSubview:btn];