ScreeningButton.m 1.39 KB
Newer Older
勾芒's avatar
勾芒 committed
1
//
2
//  ScreeningButton.m
勾芒's avatar
勾芒 committed
3 4 5 6 7 8
//  Lighting
//
//  Created by 曹云霄 on 16/5/13.
//  Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//

9
#import "ScreeningButton.h"
勾芒's avatar
勾芒 committed
10

11
@implementation ScreeningButton
勾芒's avatar
勾芒 committed
12 13 14 15 16 17 18 19 20



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

勾芒's avatar
勾芒 committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
    }
    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