UIButton

  // 按钮
    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];


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值