zoukankan      html  css  js  c++  java
  • UIButton相关的知识点

    链接地址:http://blog.sina.com.cn/s/blog_793f11ce0100teyj.html

    在viewDidLoad 事件中绘制
    // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
    - (void)viewDidLoad {
        [super viewDidLoad];

    //绘制按钮
    UIButton *btn=[UIButton buttonWithType:UIButtonTypeRoundedRect]; //绘制形状
    //确定宽、高、X、Y坐标
    CGRect frame;
    frame.size.width=100;
    frame.size.height=30;
    frame.origin.x=320/2-50;
    frame.origin.y=480/2-30;
    [btn setFrame:frame];
    //设置Tag(整形)
    btn.tag=0;
    //设置标题
    [btn setTitle:@"按钮" forState:UIControlStateNormal];
    //设置未按下和按下的图片切换
    [btn setBackgroundImage:[UIImage imageNamed:@"bus.png"] forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:@"plane.png"] forState:UIControlStateHighlighted];
    //设置事件
    [btn addTarget:self action:@selector(btnPressed:) forControlEvents:UIControlEventTouchUpInside];
    //设置背景色和透明度
    //[btn setBackgroundColor:[UIColor blackColor]];
    //[btn setAlpha:0.8];
    [self.view addSubview:btn];
    //[btn release];
    }

    //按钮响应事件
    -(void) btnPressed:(id) sender{
    UIButton *myBtn=(UIButton *) sender;
    if (myBtn.tag==0) {
    //预留模块
    }
  • 相关阅读:
    js-url打开方式
    eclipse删除所有空行
    Oracle重启 error: ora-01034:oracle not available ora-27101:shared memory realm does not exist
    最近面试遇到了高阶函数的概念混乱了
    关于跨域的cookie问题
    二叉树 呜呜
    函数的尾递归
    react context
    二叉树
    dom3级事件
  • 原文地址:https://www.cnblogs.com/xingchen/p/2169304.html
Copyright © 2011-2022 走看看