FunctionView.m 2.31 KB
//
//  FunctionView.m
//  TencentPushDemo
//
//  Created by iOS on 16/11/8.
//  Copyright © 2016年 zhulin. All rights reserved.
//

#import "FunctionView.h"

#define ICON_SIZE 40
#define SPACE ([UIScreen mainScreen].bounds.size.width - ICON_SIZE*5)/6

@implementation FunctionView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.startBtn];
        [self addSubview:self.cameraBtn];
        [self addSubview:self.beautyBtn];
        [self addSubview:self.flashBtn];
        [self addSubview:self.closeBtn];

    }
    return self;
}

#pragma mark - ****************getter******

- (UIButton *)startBtn
{
    if (!_startBtn) {
        _startBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _startBtn.frame = CGRectMake(SPACE, 0, ICON_SIZE, ICON_SIZE);
        [_startBtn setImage:[UIImage imageNamed:@"start"] forState:UIControlStateNormal];
        [_startBtn setImage:[UIImage imageNamed:@"suspend"] forState:UIControlStateSelected];

    }
    return _startBtn;
}

- (UIButton *)cameraBtn
{
    if (!_cameraBtn) {
        _cameraBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _cameraBtn.frame = CGRectMake(_startBtn.right+SPACE, 0, ICON_SIZE, ICON_SIZE);
        [_cameraBtn setImage:[UIImage imageNamed:@"camera"] forState:UIControlStateNormal];
    }
    return _cameraBtn;
}

- (UIButton *)beautyBtn
{
    if (!_beautyBtn) {
        _beautyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _beautyBtn.frame = CGRectMake(_cameraBtn.right+SPACE, 0, ICON_SIZE, ICON_SIZE);
        [_beautyBtn setImage:[UIImage imageNamed:@"beauty"] forState:UIControlStateNormal];
    }
    return _beautyBtn;
}
- (UIButton *)flashBtn
{
    if (!_flashBtn) {
        _flashBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _flashBtn.frame = CGRectMake(_beautyBtn.right+SPACE, 0, ICON_SIZE, ICON_SIZE);
        [_flashBtn setImage:[UIImage imageNamed:@"flash_on"] forState:UIControlStateNormal];
    }
    return _flashBtn;
}

- (UIButton *)closeBtn
{
    if (!_closeBtn) {
        _closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _closeBtn.frame = CGRectMake(_flashBtn.right+SPACE, 0, ICON_SIZE, ICON_SIZE);
        [_closeBtn setImage:[UIImage imageNamed:@"cancel"] forState:UIControlStateNormal];
    }
    return _closeBtn;
}
@end