UIButton

来源:互联网 发布:矩阵可逆的条件 编辑:程序博客网 时间:2024/05/17 01:04
#pragma mark - 加载视图- (void)viewDidLoad {    [super viewDidLoad];    CGRect frame = CGRectMake(20, 20, 100, 100);    self.btn = [UIButton buttonWithType:UIButtonTypeSystem];    self.btn.frame = frame;    //设置标题    [self.btn setTitle:@"按钮" forState:UIControlStateNormal];    //    typedef enum {    //      UIButtonTypeCustom = 0,    //      UIButtonTypeSystem,    //      UIButtonTypeDetailDisclosure,  //  > 箭号    //      UIButtonTypeInfoLight,    //      UIButtonTypeInfoDark,     // i 号    //      UIButtonTypeContactAdd,   // + 号    //      UIButtonTypeRoundedRect,  // 圆矩形    //  } UIButtonType;    [self.btn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];    [self.view addSubview:self.btn];     }#pragma mark - 做todo事件- (void)didReceiveMemoryWarning {    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}#pragma mark --(IBAction)click:(id)sender{    UIButton *btn = (UIButton *)sender;    NSString *string = btn.titleLabel.text;    NSLog(@"%@",string);}

0 0
原创粉丝点击