GiGaMaskTime/GIGA/Modules/Mask/Exercises/View/MaskResultViews/MaskResultMinViewCell.m

199 lines
6.3 KiB
Objective-C

//
// MaskResultMinViewCell.m
// GIGA
//
// Created by lianxiang on 2018/9/20.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import "MaskResultMinViewCell.h"
@interface MaskResultMinViewCell()
@property(nonatomic,strong) UILabel *twoLabel;
@property(nonatomic,strong) UIView *colorView;
@end
@implementation MaskResultMinViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self creatUI];
//self.backgroundColor = [UIColor blueColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
}
return self;
}
-(void)creatUI{
UILabel *twoLabel = [[UILabel alloc] init];
twoLabel.text = @"2";
twoLabel.textColor = GIGARGB(240, 147, 147, 0.1);
twoLabel.alpha = 0.6;
twoLabel.font = GIGA_TEXTFONTMEDIUM(200);
//oneLabel.backgroundColor = [UIColor redColor];
[self addSubview:twoLabel];
self.twoLabel = twoLabel;
[twoLabel sizeToFit];
[twoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.mas_left).offset(-40);
//纯数字上下有留白
make.size.mas_equalTo(CGSizeMake(twoLabel.frame.size.width, 145));
make.bottom.mas_equalTo(self.mas_bottom);
}];
//左侧红色梯形区域
UIView *colorView = [[UIView alloc] init];
[self addSubview:colorView];
self.colorView = colorView;
[colorView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(KMainW - 82);
make.height.mas_equalTo(self.mas_height);
make.centerY.mas_equalTo(self.mas_centerY);
make.right.mas_equalTo(self.mas_right);
}];
//沙漏
UIImageView *satckImageVIew = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"result_time"]];
satckImageVIew.contentMode = UIViewContentModeScaleAspectFit;
[self addSubview:satckImageVIew];
[satckImageVIew mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(121);
make.height.mas_equalTo(self.mas_height);
make.centerY.mas_equalTo(self.mas_centerY);
make.right.mas_equalTo(self.mas_right).offset(-30);
}];
UIImageView *jianyiImageView = [[UIImageView alloc] init];
jianyiImageView.contentMode = UIViewContentModeScaleAspectFit;
jianyiImageView.image = [UIImage imageNamed:@"share_tim"];
[self addSubview:jianyiImageView];
[jianyiImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(colorView.mas_left).offset((KMainW - 82)*0.424);
make.top.mas_equalTo(self.mas_top).offset(36);
if (KMainW < 375) {
make.size.mas_equalTo(CGSizeMake(139, 30));
}else{
make.size.mas_equalTo(CGSizeMake(179, 30));
}
}];
//分钟图片
UIImageView *minueImageview = [[UIImageView alloc] init];
minueImageview.image = [UIImage imageNamed:@"share_minute"];
minueImageview.contentMode = UIViewContentModeScaleAspectFit;
[self addSubview:minueImageview];
[minueImageview mas_makeConstraints:^(MASConstraintMaker *make) {
//make.left.mas_equalTo(colorView.mas_left).offset(20);
if (KMainW == 375) {
//x
make.left.mas_equalTo(colorView.mas_left).offset(30);
make.size.mas_equalTo(CGSizeMake(54, 49));
}
else if (KMainW < 375){
make.left.mas_equalTo(colorView.mas_left).offset(18);
make.size.mas_equalTo(CGSizeMake(48, 49));
}else if (KMainW == 414){
make.left.mas_equalTo(colorView.mas_left).offset(28);
make.size.mas_equalTo(CGSizeMake(54, 49));
}
else{
make.left.mas_equalTo(colorView.mas_left).offset(28);
make.size.mas_equalTo(CGSizeMake(72, 49));
}
make.top.mas_equalTo(jianyiImageView.mas_bottom).offset(20);
}];
//时间⌚️
UILabel *timeLabel = [[UILabel alloc] init];
timeLabel.textColor = [UIColor blackColor];
if (KMainW == 375) {
timeLabel.font = GIGA_TEXTFONTBOLD(26);
}else if (KMainW == 414){
timeLabel.font = GIGA_TEXTFONTBOLD(30);
}
else if (KMainW < 375){
timeLabel.font = GIGA_TEXTFONTBOLD(24);
}
else{
timeLabel.font = GIGA_TEXTFONTBOLD(35);
}
timeLabel.text = @"17";
self.timeLabel = timeLabel;
[self addSubview:timeLabel];
[timeLabel sizeToFit];
[timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(minueImageview.mas_left).offset(0);
make.centerY.mas_equalTo(minueImageview.mas_centerY);
}];
[self bringSubviewToFront:jianyiImageView];
[self bringSubviewToFront:minueImageview];
[self bringSubviewToFront:timeLabel];
}
- (void)layoutSubviews{
[super layoutSubviews];
[self drawViewInView:self.colorView backColor:GIGA_MAIN_BGCOLOR];
}
-(void)drawViewInView:(UIView *)view backColor:(UIColor *)color{
CGSize finalSize = CGSizeMake(CGRectGetWidth(view.bounds), CGRectGetHeight(view.bounds));
CAShapeLayer *layer = [CAShapeLayer layer];
UIBezierPath *bezier = [UIBezierPath bezierPath];
[bezier moveToPoint:CGPointMake(0,finalSize.height)];
[bezier addLineToPoint:CGPointMake(finalSize.width, finalSize.height)];
[bezier addLineToPoint:CGPointMake(finalSize.width,0)];
[bezier addLineToPoint:CGPointMake(finalSize.width*0.424, 0)];
[bezier addLineToPoint:CGPointMake(0,finalSize.height)];
layer.path = bezier.CGPath;
layer.fillColor = color.CGColor;
layer.shadowPath = bezier.CGPath;
layer.shadowColor = [UIColor blackColor].CGColor;
layer.shadowOffset = CGSizeMake(1, 1);
layer.shadowOpacity = 0.6;
[view.layer addSublayer:layer];
}
-(void)loadMineWith:(NSString *)minute{
if ([minute isKindOfClass:[NSNull class]]) {
minute = @"17";
}
NSString *time = [NSString stringWithFormat:@"%@",minute];
self.timeLabel.text = time;
}
-(void)laoutSettings{
}
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end