分享

IOS UIButton

 Sunny_Gql 2012-08-30

/*冬天添加自定义UIButton*/

- (void) customBtn{

    

    //设定背景色为透明的按钮处理,注意BUttonTypeUIButtonTypeCustom

    myBtn = [UIButton buttonWithType:UIButtonTypeCustom];

    myBtn.backgroundColor = [UIColor clearColor];

    

    myBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];//选择圆矩形外观

    myBtn.frame = CGRectMake(100, 100, 100, 100);//设定button坐标宽高

    [myBtn setTitle:@" 动态添加BUtton" forState:UIControlStateNormal];//选择正常外观

    [myBtn addTarget:self action:@selector(btnDownAction:) forControlEvents:UIControlEventTouchDown];//添加按钮按下事件处理

    [myBtn addTarget:self action:@selector(btnUpAction:) forControlEvents:UIControlEventTouchUpInside];//添加按钮离开

    

    [self.view addSubview:myBtn];

    

}


/*按钮添加事件处理*/

- (IBAction) btnDownAction:(id)sender{

    NSLog(@"按钮按下事件处理======");

    //这里在按下的进行一个修改背景色的处理

    

}


/*按钮添加事件处理*/

- (IBAction) btnUpAction:(id)sender{

    NSLog(@"按钮按下事件处理======");

    //这里进行一个按钮背景色透明的处理

    

}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多