码迷,mamicode.com
首页 > 其他好文 > 详细

UIButton的圆角

时间:2016-05-29 12:15:16      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:

_interestedBtn = [UIButton buttonWithType:UIButtonTypeCustom];

    _interestedBtn.layer.cornerRadius = 8;

    _interestedBtn.layer.borderColor = [UIColor orangeColor].CGColor;

    _interestedBtn.layer.borderWidth = 1;

    _interestedBtn.layer.masksToBounds = YES;

    [_interestedBtn setTitle:@"感兴趣" forState:UIControlStateNormal];

    [_interestedBtn setTitle:@"已感兴趣" forState:UIControlStateSelected];

    [_interestedBtn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];

    [_interestedBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateSelected];

    [_interestedBtn addTarget:self action:@selector(interestedBtnAction:) forControlEvents:UIControlEventTouchUpInside];

    [self.contentView addSubview:_interestedBtn];

 

-(void)interestedBtnAction:(UIButton *)sender{

    sender.selected = !sender.selected;

    

    if (sender.selected) {

        _interestedBtn.layer.cornerRadius = 8;

        _interestedBtn.layer.borderColor = [UIColor lightGrayColor].CGColor;

        _interestedBtn.layer.borderWidth = 1;

        _interestedBtn.layer.masksToBounds = YES;

    }else{

        _interestedBtn.layer.cornerRadius = 8;

        _interestedBtn.layer.borderColor = [UIColor orangeColor].CGColor;

        _interestedBtn.layer.borderWidth = 1;

        _interestedBtn.layer.masksToBounds = YES;

    }

}

UIButton的圆角

标签:

原文地址:http://www.cnblogs.com/fantasy3588/p/5539166.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!