zoukankan      html  css  js  c++  java
  • iOS-动态创建按钮

    //
    //  ViewController.m
    //  动态创建按钮
    //
    //  Created by YaguangZhu on 15/7/29.
    //  Copyright (c) 2015年 YaguangZhu. All rights reserved.
    //
    
    #import "ViewController.h"
    
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        //UIButton *button = [[UIButton alloc] init];
        UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
        [button setTitle:@"hdhdh" forState:UIControlStateNormal];
        [button setTitle:@"sss" forState:UIControlStateHighlighted];
        
        [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        [button setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];
        
        UIImage *imgNormal = [UIImage imageNamed:@"01"];
        UIImage *imgHigh = [UIImage imageNamed:@"02"];
        
        [button setBackgroundImage:(imgNormal ) forState:UIControlStateNormal];
        [button setBackgroundImage:(imgHigh) forState:UIControlStateHighlighted];
        
        button.frame = CGRectMake(50, 100, 100, 100);
        //单击事件
        [button addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];
        
        [self.view addSubview:button];
        // Do any additional setup after loading the view, typically from a nib.
    }
    
    - (void)buttonClick
    {
        NSLog(@"ssss");
    }
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    @end
  • 相关阅读:
    php数据类型
    php输出语句
    php学习知识点框架
    php变量
    php语法
    php 的开发工具
    搭建php环境的几种方法
    redis 的单机安装
    三、其他主机安装zabbix-agent加入到zabbix
    内核参数优化
  • 原文地址:https://www.cnblogs.com/zhuyaguang/p/4685769.html
Copyright © 2011-2022 走看看