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) {
    //预留模块
    }
  • 相关阅读:
    Chat Icon
    docker 容器无root 权限,如何获得docker容器里面的root权限
    yolo训练自己的数据
    jetson nano(1-1) 系统烧录和备份
    jetson nano(2)软件环境开发
    jetson nano(1-2)配置VNC
    坐标映射(remap重映射)
    opencv图像格式
    matlab相机标定导出xml文件
    jupyter安装和链接aconda
  • 原文地址:https://www.cnblogs.com/xingchen/p/2169304.html
Copyright © 2011-2022 走看看