zoukankan      html  css  js  c++  java
  • ios 初体验<UIButton 控件>

    1.创建UIButton 跟其他方式不同,不是直接alloc,init 创建 用工厂化方式创建

      UIButton *sureBtn = [UIButton buttonWithType:UIButtonTypeSystem];//选择Button 的样式 系统给定的

    //按钮的位置

        sureBtn.frame = CGRectMake(60, 600, 300, 30);

        //设在按钮背景颜色

        sureBtn.backgroundColor = [UIColor blueColor];    

        //设置按钮正常状态的文字

        [sureBtn setTitle:@"点击了" forState:UIControlStateNormal];

        //设置正常状态的颜色

        [sureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

        //按钮选中状态

        [sureBtn setTitle:@"被点击了" forState:UIControlStateSelected];

        [sureBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];

         // 设置圆角的半径

        sureBtn.layer.cornerRadius = 10;

        sureBtn.clipsToBounds = YES;

        // 按钮所要做的事件

        [sureBtn addTarget:self action:@selector(sureButtonPressed:) forControlEvents:UIControlEventTouchUpInside];

        //添加到视图控制区

        [self.view addSubview:sureBtn];

     

     

  • 相关阅读:
    模块:标准库Shelve
    模块:标准库shutil
    模块:标准库sys
    关于html中的文本节点问题
    MVVM
    iOS 检测有没有安装其它应用 和ios9下要注意的地方
    iOS9对SDK的影响(iOS9适配必看)
    CircleLayout
    MapSearch 阅读随笔
    苹果官网 demo The Elements 阅读随笔
  • 原文地址:https://www.cnblogs.com/tanglie/p/6438148.html
Copyright © 2011-2022 走看看