边框颜色为 tintColor 的 UIButton

创建一个 UIButton 的子类,重写其方法:

- (void)drawRect:(CGRect)rect
{
    [[self layer] setCornerRadius:CORNER_RADIUS];
    [[self layer] setMasksToBounds:YES];   
    [[self layer] setBorderWidth:1];
    [[self layer] setBorderColor:self.tintColor.CGColor];
    [self.imageView setTintColor:self.tintColor];
}

- (void)tintColorDidChange {
    [super tintColorDidChange];
    [self setNeedsDisplay];
//    [[self layer] setBorderColor:self.tintColor.CGColor];
}

posted @ 2014-04-21 14:26  有妄想症的猫zz  阅读(2064)  评论(0编辑  收藏  举报