zoukankan      html  css  js  c++  java
  • 0118——UIButtton

    1.Button的定义

      UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];

    Button有六种类型

          enum {

      UIButtonTypeCustom = 0, 自定义风格

      UIButtonTypeRoundedRect, 圆角矩形

      UIButtonTypeDetailDisclosure, 蓝色小箭头按钮,主要做详细说明用

      UIButtonTypeInfoLight, 亮色感叹号

      UIButtonTypeInfoDark, 暗色感叹号

      UIButtonTypeContactAdd, 十字加号按钮

      } UIButtonType;

    2.设置尺寸

      btn.frame = CGRectMake(0, 0, 100, 100);

      [btn setFrame:CGRectMake(0,0,100,100)];

    3.设置背景

      button1.backgroundColor = [UIColor clearColor];

      [button setBackgroundColor:[UIColor blueColor]];

    4.state状态

      enum {

      UIControlStateNormal = 0, 常规状态显现

      UIControlStateHighlighted = 1 << 0, 高亮状态显现

      UIControlStateDisabled = 1 << 1, 禁用的状态才会显现

      };

         [btn setTitle:@"cancel" forState:UIControlStateNormal];

    5.设置button填充图片和背景图片

      [btn setImage:[UIImageimageNamed:@"aaa"]forState:UIControlStateNormal];

      [btn setBackgroundImage:[UIImageimageNamed:@"aaa"]forState:UIControlStateNormal];

    6.添加或删除事件处理

      [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];

      [btn removeTarget:nil action:nil forControlEvents:UIControlEventTouchUpInside];

    7.按钮是否可以响应

      btn.enabled = NO;

  • 相关阅读:
    Solution -「USACO 2020.12 P」Spaceship
    Solution -「USACO 2020.12 P」Sleeping Cows
    Solution -「HDU #6566」The Hanged Man
    Solution -「JOISC 2019」「LOJ #3036」指定城市
    HTML5 之required修改默认提示
    Js 之内容加密
    小程序 之生成接口签名
    Js 之Api接口验签
    View.js 之加载动画
    View.js 之跳转动画
  • 原文地址:https://www.cnblogs.com/damonWq/p/5140253.html
Copyright © 2011-2022 走看看