使用系统方法 创建一个 自定义样式的button

来源:互联网 发布:exe软件修改教程 编辑:程序博客网 时间:2024/06/06 03:55


 self.aBtn = [UIButton buttonWithType:UIButtonTypeCustom];

        _aBtn.frame = CGRectMake(kScaleWidth(30.0),

                                 kRelateHeight(10.0),

                                 kScaleWidth(30.0),

                                 kRelateHeight(30.0));

        _aBtn.tag = kOriginBtnTag;

        

        [_aBtn setBackgroundImage:[self imageWithColor:kColor_White size:_aBtn.frame.size] forState:UIControlStateNormal];

        [_aBtn setBackgroundImage:[self imageWithColor:kColor_TopBtnSel size:_aBtn.frame.size] forState:UIControlStateSelected];

        _aBtn.clipsToBounds = YES;

        _aBtn.selected = YES;

        [_aBtn.layer setCornerRadius:15.0];

        [_aBtn.layer setBorderWidth:1];

        [_aBtn.layer setBorderColor:[[UIColor grayColor] CGColor]];

        [self addSubview:_aBtn];

1 0
原创粉丝点击