// // TPCustomButton.m // ThePaperDemo // // Created by scar1900 on 14/12/4. // Copyright (c) 2014年 scar1900. All rights reserved. // #import "TPCustomButton.h" @interface TPCustomButton() @end @implementation TPCustomButton @synthesize title = _title; - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.layer.cornerRadius = 4.f; self.clipsToBounds = YES; [self setBackgroundImage:imageWithUIColor([UIColor colorWithHexString:BLUECOLOR]) forState:UIControlStateNormal]; [self setBackgroundImage:imageWithUIColor([UIColor colorWithHexString:BUTTONSELECTBACK]) forState:UIControlStateHighlighted]; [self setBackgroundImage:imageWithUIColor([UIColor colorWithHexString:BUTTONDISABLEBACK]) forState:UIControlStateDisabled]; } return self; } - (void)setTitle:(NSString *)titleStr { _title = titleStr; [self setTitle:titleStr forState:UIControlStateNormal]; [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; self.titleLabel.textAlignment = NSTextAlignmentCenter; } - (void)layoutSubviews { [super layoutSubviews]; self.titleLabel.font = appFont(18, NO); } @end