//
//  ScreeningButton.m
//  Lighting
//
//  Created by 曹云霄 on 16/5/13.
//  Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//

#import "ScreeningButton.h"

@implementation ScreeningButton



- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.titleLabel.font = [UIFont systemFontOfSize:13];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self setImage:TCImage(@"down_arr") forState:UIControlStateNormal];
        self.layer.masksToBounds = YES;
        self.layer.cornerRadius = 10;
        self.backgroundColor = RGB(131, 131, 131,1);

    }
    return self;
}



- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
    return CGRectMake((self.frame.size.width-[self ReturnCGsize:self.currentTitle].width)/2, -2, [self ReturnCGsize:self.currentTitle].width, 35);
}


- (CGRect)imageRectForContentRect:(CGRect)contentRect
{
    return CGRectMake((self.frame.size.width-[self ReturnCGsize:self.currentTitle].width)/2+[self ReturnCGsize:self.currentTitle].width, (self.frame.size.height-6)/2, 11, 6);
}


- (CGSize)ReturnCGsize:(NSString *)string
{
    CGSize S = [string boundingRectWithSize:CGSizeMake(999, 35) options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18]} context:nil].size;
    return S;
}


@end
