美文网首页iOS~ 贝塞尔曲线:UIBezierPath和CAShapeLayer
ios ~ 贝塞尔曲线:天气预报(包含温度、渐变色块、风力)

ios ~ 贝塞尔曲线:天气预报(包含温度、渐变色块、风力)

作者: 阳光下的叶子呵 | 来源:发表于2022-03-25 15:48 被阅读0次

    原理:画渐变色块的两种方法:
    ① 使用UIBezierPathCAShapeLayer、设置mask遮罩层一个个的画出渐变色块,只是path的各个端点的坐标比较麻烦。
    ② 下边代码中的方法:将一个个渐变色块先画出来,再根据UIBezierPath描绘的path路径,将整个view分成上、下两部分,再将上面的部分遮盖,就好了。
    还有这个方法:iOS 画折线图(包括平滑曲线和渐变阴影)

    天气折线图📈

    直接上代码:

    //
    //  GWCW_NewClubWeatherCell.m
    
    #import "GWCW_NewClubWeatherCell.h"
    #import "CWNew_TimerAbnormalWeatherImgView.h" // 异常天气
    #import "GWCW_ClubWeatherSunriseView.h"
    //#import "GWCW_ClubWeatherChildCell.h"
    #import "GWCW_NewClubWeatherChildCell.h"
    
    @interface GWCW_NewClubWeatherCell () <UIScrollViewDelegate, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
    
    /** 闭合时:50 */
    @property (nonatomic, strong) UIView    *smallBackView;
    @property (nonatomic, strong) UILabel   *dateL;
    @property (nonatomic, strong) UILabel   *timeL;
    @property (nonatomic, strong) UIImageView *abnormalWeatherImg; // 异常天气
    @property (nonatomic, strong) CWNew_TimerAbnormalWeatherImgView *abnormalWeatherImgView;
    
    
    @property (nonatomic, strong) UIImageView   *dayImg;  // 白天
    @property (nonatomic, strong) UIImageView   *nightImg;// 夜晚
    @property (nonatomic, strong) UILabel   *dayTempL;  // 白天温度
    @property (nonatomic, strong) UILabel   *nightTempL;// 夜晚温度
    @property (nonatomic, strong) UIView    *tempView;  // 温度条
    @property (nonatomic, strong) UIImageView   *isOPenImg; // 展开闭合图标
    
    /** 展开时:330 */
    @property (nonatomic, strong) UIView    *bigBackView;
    @property (nonatomic, strong) UILabel   *big_TimeL; // 时间
    @property (nonatomic, strong) UILabel   *big_tempL; // 温度: 19°/15°
    
    @property (nonatomic, strong) UIImageView *big_weatherImg;// 天气图片
    @property (nonatomic, strong) UILabel   *big_weatherTextL;// 天气描述
    @property (nonatomic, strong) UILabel   *big_winpL;     // 风力级别
    @property (nonatomic, strong) UIView    *lineWinpView;  // 天气描述 | 风力级别,“|”
    @property (nonatomic, strong) UIImageView *big_isOPenImg; // 展开闭合图标
    
    @property (nonatomic, strong) UIImageView   *big_dayImg;
    @property (nonatomic, strong) UIImageView   *big_nightImg;
    @property (nonatomic, strong) UILabel   *big_dayTimeL;  // 日出时间
    @property (nonatomic, strong) UILabel   *big_noghtTimeL;// 日落时间
    // 太阳☀️曲线
    @property (nonatomic, strong) UIView    *big_toSunsetBackView; // 曲线背景:(99) x 28
    @property (nonatomic, strong) CAShapeLayer *big_toSunsetBackViewLayer; // 设置父layer
    @property (nonatomic, strong) UIImageView  *toSunsetImg;
    //@property (nonatomic, strong) UIImageView    *big_toSunsetImg;
    //@property (nonatomic, strong) GWCW_ClubWeatherSunriseView *big_toSunsetBackView;
    
    
    /** 展开时:折线图📈 */
    @property (nonatomic, strong) UIView        *chartBackView; // 背景view
    @property (nonatomic, strong) UIScrollView  *chartContentScrollView;
    @property (nonatomic, strong) UIView        *chartContentView; // 折线图的view
    @property (nonatomic, strong) CALayer       *chartContentView_Backlayer; //  self.chartContentView.layer
    
    @property (nonatomic, strong) CAShapeLayer  *chartLayer; // 添加一个父layer
    @property (nonatomic, strong) UIView        *lineFatherView; // 在chartLayer之后,chartContentView上添加一个UIview,作为渐变色块和画虚线的父视图(在set方法中创建)
    @property (nonatomic, strong) UIView        *LineRangeView; // 折线图📈的范围父view,比渐变色块的lineFatherView高度要小一些
    @property (nonatomic, strong) UIView        *windRangeView; // 风:方向箭头 + 风向 + 风力级别(一个色块范围时,只有方向箭头和风力级别,两个色块范围和以上范围,展示全部三个)
    //@property (nonatomic, strong) CAShapeLayer  *tempLayer; // 添加一个父layer
    
    @property (nonatomic, strong) UICollectionView *collectionView;
    
    // 滑动进度条
    @property (nonatomic, strong) UIView    *progressBackView;
    @property (nonatomic, strong) UIView    *progressView;
    
    @end
    
    @implementation GWCW_NewClubWeatherCell
    
    - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
        self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
        if (self) {
            self.selectionStyle = UITableViewCellSelectionStyleNone;
            self.backgroundColor = [UIColor clearColor];
            [self setupUI];
            
        }
        return self;
    }
    
    - (void)prepareForReuse {
        [super prepareForReuse];
        
        self.dateL.text = nil;
        self.timeL.text = nil;
        self.abnormalWeatherImgView.hidden = YES;
        self.dayImg.image = nil;
        self.nightImg.image = nil;
        self.dayTempL.text = nil;
        self.nightTempL.text = nil;
        self.tempView.hidden = YES;
        self.isOPenImg.image = nil;
        
        // 展开
        self.bigBackView.hidden = YES;
        self.big_TimeL.text = nil;
        self.big_tempL.text = nil;
        self.big_weatherImg.image = nil;
        self.big_weatherTextL.text = nil;
        self.big_winpL.text = nil;
        self.big_isOPenImg.image = nil;
        
        self.big_dayImg.image = nil;
        self.big_nightImg.image = nil;
        self.big_dayTimeL.text = nil;
        self.big_noghtTimeL.text = nil;
        self.big_toSunsetBackView.hidden = YES;
        [self.big_toSunsetBackViewLayer removeFromSuperlayer]; // 去掉父layer上的所有子layer
        self.toSunsetImg.image = nil;
        
        /** 将 set方法中的创建的  子layer 或 子view删掉,重新创建,列表时类似重用 */
        [self.chartLayer removeFromSuperlayer];
        [self.lineFatherView removeFromSuperview];
        [self.LineRangeView removeFromSuperview];
        [self.windRangeView removeFromSuperview];
        self.collectionView.hidden = YES;
        
        self.progressBackView.hidden = YES;
        self.progressView.hidden = YES;
        
    }
    
    - (void)setDailyModel:(GWCW_ClubWeather_DailyWeatherModel *)dailyModel {
        _dailyModel = dailyModel;
        
        if (_dailyModel.isOpen) { /** 展开 内容 */
            self.smallBackView.hidden = YES;
            self.bigBackView.hidden = NO;
            self.big_toSunsetBackView.hidden = NO;
    //        [self.big_toSunsetBackViewLayer removeFromSuperlayer]; // 去掉父layer上的所有子layer
            
            if (self.indexCell == 0) {
                self.big_TimeL.text = [NSString stringWithFormat:@"今天   %@", _dailyModel.date];
            } else if (self.indexCell == 1) {
                self.big_TimeL.text = [NSString stringWithFormat:@"明天   %@", _dailyModel.date];
            } else {
                self.big_TimeL.text = [NSString stringWithFormat:@"%@   %@", _dailyModel.week, _dailyModel.date];
            }
            [self.big_weatherImg sd_setImageWithURL:[NSURL URLWithString:_dailyModel.dayUrl] placeholderImage:[UIImage imageNamed:@""]];
            self.big_tempL.text = _dailyModel.temp;
            self.big_weatherTextL.text = _dailyModel.weatherText;
            self.lineWinpView.backgroundColor = RGBA(105, 104, 108, 1);
            self.big_winpL.text = _dailyModel.wind;
            
            if (_dailyModel.isOpen) {
                self.big_isOPenImg.image = [UIImage imageNamed:@"new_weatherCell_收起_icon"];
            } else {
                self.big_isOPenImg.image = [UIImage imageNamed:@"new_weatherCell_展开_icon"];
            }
            
            self.big_dayImg.image = [UIImage imageNamed:@"new_weather_Black日出_icon"];
            self.big_nightImg.image = [UIImage imageNamed:@"new_weather_Black日落_icon"];
            self.big_dayTimeL.text = _dailyModel.sunrise;
            self.big_noghtTimeL.text = _dailyModel.sunset;
            
            // 太阳☀️曲线
            [self SunriseAndSunset:_dailyModel.toSunset];
            
            
            /** 1、创建父layer */
            _chartLayer = [[CAShapeLayer alloc] init];
            _chartLayer.strokeColor = [UIColor clearColor].CGColor;
            
            UIBezierPath *bezierPath = [UIBezierPath
                                            bezierPathWithRoundedRect:CGRectMake(0, 0, self.chartContentScrollView.contentSize.width, [UIScreen mainScreen].bounds.size.width/375*85)
                                            byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
                                            cornerRadii:CGSizeMake([UIScreen mainScreen].bounds.size.width/375*0, [UIScreen mainScreen].bounds.size.width/375*0)];
    
            _chartLayer.lineWidth = [UIScreen mainScreen].bounds.size.width/375*0.01;
            // 颜色
            _chartLayer.strokeColor = [UIColor clearColor].CGColor;
            // 背景填充色
            _chartLayer.fillColor = [UIColor clearColor].CGColor;
            _chartLayer.path = [bezierPath CGPath];
            [self.chartContentView.layer addSublayer:self.chartLayer];
            
            
            /**!!! 设置背景色(渐变色),首先获取每个色块的path,发到数组中24个(24小时)  !!!*/
            
            _lineFatherView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.chartContentScrollView.contentSize.width, [UIScreen mainScreen].bounds.size.width/375*85)];
            self.lineFatherView.backgroundColor = [UIColor clearColor];
            [self.chartContentView addSubview:self.lineFatherView];
            
            NSMutableArray *lineX_Array = [NSMutableArray arrayWithCapacity:0]; // 虚线的位置:X轴坐标(处理:天气描述的宽度 = 下一个虚线坐标.X - 上一个虚线坐标.X,天气描述的center.X = (下一个虚线坐标.X - 上一个虚线坐标.X)/2 + 上一个虚线坐标.X )
            
            NSInteger sixHour = 0; // 相同天气时,最大6个小时,天气描述内容使用同一个,大于6小时,需要虚线做间隔(初始值为1)
            for (int k = 0; k < self.hourlyModels.count; k++) {
                
                GWCW_ClubWeather_HourlyWeatherModel *hourModel = self.hourlyModels[k];
                
                
                /** 添加渐变色:设置色块,再遮挡path之上的区域 */
                CAGradientLayer *gradient = [CAGradientLayer layer];
                
                gradient.frame = CGRectMake([UIScreen mainScreen].bounds.size.width/375*42 * k, [UIScreen mainScreen].bounds.size.width/375*0, [UIScreen mainScreen].bounds.size.width/375*42, [UIScreen mainScreen].bounds.size.width/375*85);
                
                gradient.colors = [self returnGradientColors:hourModel.weatherCode];
                 /**
                  三、设计图中9种颜色分类和对应天气描述编号: weatherCode // 天气代码:code
                  晴:1 18
                  多云:2
                  雾:11
                  霾:4 5 6
                  沙尘:16 17
                  阴:3
                  雨:7 8 9 10
                  雷阵雨:19 20
                  雪:12 13 14 15 21
                  */
                
                gradient.startPoint = CGPointMake(0, 0);
                gradient.endPoint = CGPointMake(0, 1);
                
                [self.chartLayer addSublayer:gradient];
                
                
                /** 虚线 图片位置 */
                if (k == 0) {
                    // 第一个色块先不画虚线,从画第二个色块开始,相比较之后,再画第一个和第二个色块之间的虚线
                    
                } else {
                    
                    GWCW_ClubWeather_HourlyWeatherModel *lastHourModel = self.hourlyModels[k-1];
                    
                    if (lastHourModel.weatherCode == hourModel.weatherCode) { // 6小时为最大间隔(初始值为1)
                        sixHour = sixHour + 1;
                    } else {
                        sixHour = 0; // 复位
                    }
    //                NSLog(@"😆😆sixHour = %ld", sixHour);
                    
                    // 前一个hourModel(用于和当前的hourModel对比天气的weatherCode,不一样时)
                    if (lastHourModel.weatherCode != hourModel.weatherCode) {
                        
                        // 画虚线
                        UIImageView *lineImg = [[UIImageView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/375*(42 * k -1), 0, [UIScreen mainScreen].bounds.size.width/375*2, [UIScreen mainScreen].bounds.size.width/375*85)];
                        lineImg.image = [UIImage imageNamed:@"weather_clubYellowLine_icon"];
                        [self.lineFatherView addSubview:lineImg];
                        [lineImg sizeToFit];
                        
                        
                        CGFloat pointX = lineImg.frame.origin.x;
                        NSString *weatherText = self.hourlyModels[k-1].weatherText;
                        NSDictionary *pointDic = @{
                            @"pointX":[NSString stringWithFormat:@"%.2f", pointX],
                            @"weatherText":weatherText
                        };
                        [lineX_Array addObject:pointDic];
                        
                        if (k == self.hourlyModels.count-1) { // 如果这是最后一个渐变色块(添加一个天气描述的位置)
                            
                            CGFloat endPointX = [UIScreen mainScreen].bounds.size.width/375*(42*24);
                            NSString *endWeatherText = self.hourlyModels[k].weatherText;
                            NSDictionary *endPointDic = @{
                                @"pointX":[NSString stringWithFormat:@"%.2f", endPointX],
                                @"weatherText":endWeatherText
                            };
                            [lineX_Array addObject:endPointDic];
                        }
                        
                        
                    } else {
                        if (sixHour >= 6) {
                            UIImageView *lineImg = [[UIImageView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/375*(42 * k -1), 0, [UIScreen mainScreen].bounds.size.width/375*2, [UIScreen mainScreen].bounds.size.width/375*85)];
                            lineImg.image = [UIImage imageNamed:@"weather_clubYellowLine_icon"];
                            [self.lineFatherView addSubview:lineImg];
                            [lineImg sizeToFit];
                            
                            CGFloat pointX = lineImg.frame.origin.x;
                            NSString *weatherText = self.hourlyModels[k-1].weatherText;
                            NSDictionary *pointDic = @{
                                @"pointX":[NSString stringWithFormat:@"%.2f", pointX],
                                @"weatherText":weatherText
                            };
                            [lineX_Array addObject:pointDic];
                            
                            sixHour = 0; // 复位
                        }
                        
                        if (k == self.hourlyModels.count-1) { // 如果这是最后一个渐变色块(添加一个天气描述的位置)
                            
                            CGFloat endPointX = [UIScreen mainScreen].bounds.size.width/375*(42*24);
                            NSString *endWeatherText = self.hourlyModels[k].weatherText;
                            NSDictionary *endPointDic = @{
                                @"pointX":[NSString stringWithFormat:@"%.2f", endPointX],
                                @"weatherText":endWeatherText
                            };
                            [lineX_Array addObject:endPointDic];
                        }
                        
                    }
                }
                
            }
            
            /** 判断天气描述 放在哪个位置 */
            /// 虚线的位置:X轴坐标(处理:天气描述的宽度 = 当前一个虚线坐标.X - 上一个虚线坐标.X,天气描述的center.X = (当前一个虚线坐标.X - 上一个虚线坐标.X)/2 + 上一个虚线坐标.X ), 第一个 和最后一个需要单独特殊处理
            if (lineX_Array.count > 0) {
                
                for (int X = 0; X < lineX_Array.count; X++) {
                    
                    NSDictionary *lineX_Dic = lineX_Array[X];
                    CGFloat pointX = [[NSString stringWithFormat:@"%@", lineX_Dic[@"pointX"]] floatValue];
                    NSString *pointWeatherText = [NSString stringWithFormat:@"%@", lineX_Dic[@"weatherText"]];
                    
                    if (X == 0) {
                        
                        UILabel *weatherTextL = [[UILabel alloc] initWithFrame:CGRectMake(0, [UIScreen mainScreen].bounds.size.width/375*(85 - 13 - 13), pointX, [UIScreen mainScreen].bounds.size.width/375*13)];
                        
                        weatherTextL.text = pointWeatherText;
                        weatherTextL.textColor = RGBA(102, 102, 102, 1);
                        weatherTextL.textAlignment = NSTextAlignmentCenter;
                        weatherTextL.font = [UIFont systemFontOfSize:[UIScreen mainScreen].bounds.size.width/375*12 weight:UIFontWeightRegular];
                        [self.lineFatherView addSubview:weatherTextL];
                        
                    } else if (X == lineX_Array.count-1) {
                        
                        NSDictionary *lastLineX_Dic = lineX_Array[X-1];
                        CGFloat lastPointX = [[NSString stringWithFormat:@"%@", lastLineX_Dic[@"pointX"]] floatValue];
                        
                        UILabel *weatherTextL = [[UILabel alloc] initWithFrame:CGRectMake(lastPointX, [UIScreen mainScreen].bounds.size.width/375*(85 - 13 - 13), (pointX - lastPointX), [UIScreen mainScreen].bounds.size.width/375*13)];
    
                        weatherTextL.text = pointWeatherText;
                        weatherTextL.textColor = RGBA(102, 102, 102, 1);
                        weatherTextL.textAlignment = NSTextAlignmentCenter;
                        weatherTextL.font = [UIFont systemFontOfSize:[UIScreen mainScreen].bounds.size.width/375*12 weight:UIFontWeightRegular];
                        [self.lineFatherView addSubview:weatherTextL];
                         
                    } else {
                        
                        NSDictionary *lastLineX_Dic = lineX_Array[X-1];
                        CGFloat lastPointX = [[NSString stringWithFormat:@"%@", lastLineX_Dic[@"pointX"]] floatValue]; // 上一个:X-1
                        
    //                    UILabel *weatherTextL = [[UILabel alloc] initWithFrame:CGRectMake((pointX - lastPointX)/2 + lastPointX, [UIScreen mainScreen].bounds.size.width/375*(85 - 13 - 13), pointX, [UIScreen mainScreen].bounds.size.width/375*13)];
                        UILabel *weatherTextL = [[UILabel alloc] initWithFrame:CGRectMake(lastPointX, [UIScreen mainScreen].bounds.size.width/375*(85 - 13 - 13), (pointX - lastPointX), [UIScreen mainScreen].bounds.size.width/375*13)];
    
                        weatherTextL.text = pointWeatherText;
                        weatherTextL.textColor = RGBA(102, 102, 102, 1);
                        weatherTextL.textAlignment = NSTextAlignmentCenter;
                        weatherTextL.font = [UIFont systemFontOfSize:[UIScreen mainScreen].bounds.size.width/375*12 weight:UIFontWeightRegular];
                        [self.lineFatherView addSubview:weatherTextL];
                        
                    }
                    
                    
                }
                
            }
            
            // 📈path范围
            _LineRangeView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.chartContentScrollView.contentSize.width, [UIScreen mainScreen].bounds.size.width/375*45)];
            self.LineRangeView.backgroundColor = [UIColor clearColor];
            self.LineRangeView.layer.masksToBounds = YES;
            [self.chartContentView addSubview:self.LineRangeView];
            
            
            /** 天气贝塞尔曲线📈path路径 */
            UIBezierPath *weatherPath = [UIBezierPath bezierPath];
            /// 先找到最大温度和最低温度,在这个范围内设置温度的最大范围:height:45 (折线+小圆点,单折线时,范围40)
            CGFloat maxTemp = 0;
            CGFloat minTemp = 0;
            for (int j = 0; j < self.hourlyModels.count; j++) {
                
                GWCW_ClubWeather_HourlyWeatherModel *hourModel = self.hourlyModels[j];
                CGFloat i_temp = [hourModel.temp floatValue];
                
    //            NSLog(@"一天的温度😆😆 %.2f 😆😆", i_temp);
                if (j == 0) {
                    maxTemp = i_temp;
                    minTemp = i_temp;
                }
                
                if (maxTemp > i_temp) {
                    maxTemp = maxTemp;
                } else {
                    maxTemp = i_temp;
                }
                if (minTemp > i_temp) {
                    minTemp = i_temp;
                } else {
                    minTemp = minTemp;
                }
            }
            
            // 温度之差 的 温度范围:温度三种情况都是这个减法获取温度的范围
            CGFloat maxTempRange = maxTemp - minTemp;
            
            // 小圆点的中心点坐标 point数组:
            NSMutableArray *circleArray = [NSMutableArray arrayWithCapacity:0];
            
            // 设置path的 起始点 和 其他点
            for (int i = 0; i < self.hourlyModels.count; i++) {
                
                GWCW_ClubWeather_HourlyWeatherModel *hourModel = self.hourlyModels[i];
                CGFloat temp = [hourModel.temp floatValue];
                
    //            NSLog(@"一天的温度😆😆 %.2f 😆😆", temp);
                // 温度折线图📈,最高温60摄氏度,最低温-40 度℃,(temp - minTemp) = 当前的温度,减去最小的温度,载乘以等份
                if (i == 0) {
                    
                    // 起始点:
                    [weatherPath moveToPoint:CGPointMake([UIScreen mainScreen].bounds.size.width/375*(-4), [UIScreen mainScreen].bounds.size.width/375*(45+4))];
                    
                    [weatherPath addLineToPoint:CGPointMake([UIScreen mainScreen].bounds.size.width/375*(-4), [UIScreen mainScreen].bounds.size.width/375*(45 - 2.5  - 40/maxTempRange * (temp - minTemp)))];
                    
                    [weatherPath addLineToPoint:CGPointMake([UIScreen mainScreen].bounds.size.width/375*(42/2), [UIScreen mainScreen].bounds.size.width/375*(45 - 2.5  - 40/maxTempRange * (temp - minTemp)))];
                    
                    // 端点位置CGPoint
                    CGPoint circlePoint = CGPointMake([UIScreen mainScreen].bounds.size.width/375*(42/2), [UIScreen mainScreen].bounds.size.width/375*(45 - 2.5  - 40/maxTempRange * (temp - minTemp)));
                    
                    NSValue* circleValue = [NSValue valueWithCGPoint:circlePoint];
                    [circleArray addObject:circleValue];
                    
                    self.hourlyModels[i].heightY = [UIScreen mainScreen].bounds.size.width/375*((194 -62-85) + 40 + 2.5 + 40/maxTempRange * (temp - minTemp) + 10);
                    
                    /**
                     /// 因为CGPoint不是对象,所以不能存到数组,需要转成NSValue
                    // CGPoint 转 NSValue
                    NSValue* value = [NSValue valueWithCGPoint:CGPointMake(10, 50)];
                    // NSValue 转 CGPoint
                    CGPoint pt = [value CGPointValue];
                     */
                    
                } else if (i == self.hourlyModels.count-1) {
                  
                    [weatherPath addLineToPoint:CGPointMake([UIScreen mainScreen].bounds.size.width/375*(42/2 + (42*i)), [UIScreen mainScreen].bounds.size.width/375*(45 - 2.5 - 40/maxTempRange * (temp - minTemp)))];
                    
                    // 端点位置CGPoint
                    CGPoint circlePoint = CGPointMake([UIScreen mainScreen].bounds.size.width/375*(42/2+ (42*i)), [UIScreen mainScreen].bounds.size.width/375*(45 - 2.5 - 40/maxTempRange * (temp - minTemp)));
                    
                    NSValue* circleValue = [NSValue valueWithCGPoint:circlePoint];
                    [circleArray addObject:circleValue];
                    
                    self.hourlyModels[i].heightY = [UIScreen mainScreen].bounds.size.width/375*((194 -62-85) + 40 + 2.5 + 40/maxTempRange * (temp - minTemp) + 10);
                    
                    // 最后一个需要特殊处理(下面两步):
                    [weatherPath addLineToPoint:CGPointMake([UIScreen mainScreen].bounds.size.width/375*(42/2+ (42*i) + 42/2 + 4), [UIScreen mainScreen].bounds.size.width/375*(45 - 2.5 - 40/maxTempRange * (temp - minTemp)))];
                    // 终点
                    [weatherPath addLineToPoint:CGPointMake([UIScreen mainScreen].bounds.size.width/375*(42/2+ (42*i) + 42/2 + 4), [UIScreen mainScreen].bounds.size.width/375*(45 + 4))];
                    
                    
                } else {
                    [weatherPath addLineToPoint:CGPointMake([UIScreen mainScreen].bounds.size.width/375*(42/2 + (42*i)), [UIScreen mainScreen].bounds.size.width/375*(45 - 2.5 - 40/maxTempRange * (temp - minTemp)))];
                    
                    // 端点位置CGPoint
                    CGPoint circlePoint = CGPointMake([UIScreen mainScreen].bounds.size.width/375*(42/2+ (42*i)), [UIScreen mainScreen].bounds.size.width/375*(45 - 2.5 - 40/maxTempRange * (temp - minTemp)));
                    
                    NSValue* circleValue = [NSValue valueWithCGPoint:circlePoint];
                    [circleArray addObject:circleValue];
                    
                    self.hourlyModels[i].heightY = [UIScreen mainScreen].bounds.size.width/375*((194 -62-85) + 40 + 2.5 + 40/maxTempRange * (temp - minTemp) + 10);
                }
            }
            
            CAShapeLayer *lineLayer = [[CAShapeLayer alloc] init];
            // 线宽
            lineLayer.lineWidth = [UIScreen mainScreen].bounds.size.width/375*2;
            // 线条的颜色
            lineLayer.strokeColor = RGBA(255, 196, 15, 1).CGColor;
            // 背景填充色
            lineLayer.fillColor = [UIColor clearColor].CGColor;
            // 起始点和终点,连接起来。(可以先添加”起始点“和”终点“的y轴为0,加上这句之后,范围内的填充颜色。)
            [weatherPath closePath];
            // 将UIBezierPath类转换成CGPath,类似于UIColor的CGColor
            lineLayer.path = [weatherPath CGPath];
            [self.LineRangeView.layer addSublayer:lineLayer];
            
            /** 将折线图📈上面的部分使用背景色遮盖 **/
            
            UIBezierPath *topBackWeatherPath = [UIBezierPath bezierPath];
            for (int i = 0; i < self.hourlyModels.count; i++) {
                
                GWCW_ClubWeather_HourlyWeatherModel *hourModel = self.hourlyModels[i];
                CGFloat temp = [hourModel.temp floatValue];
                
                // 温度折线图📈,最高温60摄氏度,最低温-40 度℃,(temp - minTemp) = 当前的温度,减去最小的温度,载乘以等份
                if (i == 0) {
                    
                    // 起始点:
                    [topBackWeatherPath moveToPoint:CGPointMake([UIScreen mainScreen].bounds.size.width/375*(-4), [UIScreen mainScreen].bounds.size.width/375*(-4))];
                    
                    [topBackWeatherPath addLineToPoint:CGPointMake([UIScreen mainScreen].bounds.size.width/375*(-4), [UIScreen mainScreen].bounds.size.width/375*(45 - 2.5  - 40/maxTempRange * (temp - minTemp)))];
                    
                    [topBackWeatherPath addLineToPoint:CGPointMake([UIScreen mainScreen].bounds.size.width/375*(42/2), [UIScreen mainScreen].bounds.size.width/375*(45 - 2.5  - 40/maxTempRange * (temp - minTemp)))];
                    
                    
                } else if (i == self.hourlyModels.count-1) {
                  
                    [topBackWeatherPath addLineToPoint:CGPointMake([UIScreen mainScreen].bounds.size.width/375*(42/2 + (42*i)), [UIScreen mainScreen].bounds.size.width/375*(45 - 2.5 - 40/maxTempRange * (temp - minTemp)))];
                    
                    
                    // 最后一个需要特殊处理(下面两步):
                    [topBackWeatherPath addLineToPoint:CGPointMake([UIScreen mainScreen].bounds.size.width/375*(42/2+ (42*i) + 42/2 + 4), [UIScreen mainScreen].bounds.size.width/375*(45 - 2.5 - 40/maxTempRange * (temp - minTemp)))];
                    // 终点
                    [topBackWeatherPath addLineToPoint:CGPointMake([UIScreen mainScreen].bounds.size.width/375*(42/2+ (42*i) + 42/2 + 4), [UIScreen mainScreen].bounds.size.width/375*(-4))];
                    
                    
                } else {
                    [topBackWeatherPath addLineToPoint:CGPointMake([UIScreen mainScreen].bounds.size.width/375*(42/2 + (42*i)), [UIScreen mainScreen].bounds.size.width/375*(45 - 2.5 - 40/maxTempRange * (temp - minTemp)))];
                }
            }
            CAShapeLayer *topBackWeatherLayer = [[CAShapeLayer alloc] init];
            // 线宽
            topBackWeatherLayer.lineWidth = [UIScreen mainScreen].bounds.size.width/375*2;
            // 线条的颜色
            topBackWeatherLayer.strokeColor = [UIColor clearColor].CGColor;
            // 背景填充色
            topBackWeatherLayer.fillColor = RGBA(248, 247, 245, 1).CGColor;
            // 起始点和终点,连接起来。(可以先添加”起始点“和”终点“的y轴为0,加上这句之后,范围内的填充颜色。)
            [topBackWeatherPath closePath];
            // 将UIBezierPath类转换成CGPath,类似于UIColor的CGColor
            topBackWeatherLayer.path = [topBackWeatherPath CGPath];
            [self.LineRangeView.layer addSublayer:topBackWeatherLayer];
            
            
            /** 折线图📈中的小圆点 */
            for (NSValue *circleValue in circleArray) {
                /** 折线图📈中的小圆点 */
                CGPoint circlePoint = [circleValue CGPointValue];
                
                CAShapeLayer *circleLayer = [CAShapeLayer layer];
                // 线宽
                circleLayer.lineWidth = [UIScreen mainScreen].bounds.size.width/375*1; // 10 - 6 = 4
                circleLayer.lineCap = kCALineCapRound;  // 端点样式
                circleLayer.lineJoin = kCALineCapRound; // 终点处理
                // 线条的颜色
                circleLayer.strokeColor = RGBA(255, 196, 15, 1).CGColor;
                // 背景填充色
                circleLayer.fillColor = [UIColor whiteColor].CGColor;
                // 设置线宽、线间距(虚线)
    //            [circleLayer setLineDashPattern:[NSArray arrayWithObjects:[NSNumber numberWithInt:2], [NSNumber numberWithInt:2], nil]];
    
                // 设置半径
                CGFloat circleRadius = [UIScreen mainScreen].bounds.size.width/375*2;
                // bezierPathWithArcCenter 中心点,下面就让addSublayer了,那么就设置self.bezierBackImg.layer的 中心点就好了,宽/2,高/2
                UIBezierPath *circlePath = [UIBezierPath bezierPathWithArcCenter:circlePoint radius:circleRadius startAngle:(0*M_PI) endAngle:(2*M_PI) clockwise:YES]; // 终止点(60%几率时):(2*0.6 - 0.25)*M_PI,clockwise 顺时针 YES, 逆时针 NO
                circleLayer.path = [circlePath CGPath];
                [self.LineRangeView.layer addSublayer:circleLayer]; // 这行代码之前,将执行[self.tempLayer
            }
            
            
            /**  风向 + 风力 : 使用一块内容,就是一个UIButton(判断根据:1 风向、2 风力级别、3 六小时及以上) */
            _windRangeView = [[UIView alloc] initWithFrame:CGRectMake(0, [UIScreen mainScreen].bounds.size.width/375*(62+85), self.chartContentScrollView.contentSize.width, [UIScreen mainScreen].bounds.size.width/375*(194 - 62 - 85))];
            self.windRangeView.backgroundColor = [UIColor clearColor];
            self.windRangeView.layer.masksToBounds = YES;
            [self.chartContentScrollView addSubview:self.windRangeView];
            
            NSInteger sixWindHour = 0; // 相同 风向和风力级别(当换下一个风力描述时,置0) 时,最大6个小时,风描述内容使用同一个,大于6小时,需要添加风的描述(初始值为1)
            NSMutableArray *windPointX_array = [NSMutableArray arrayWithCapacity:0];// 每个风力描述的最右边的X轴坐标
            // 获取风力描述坐标
            for (int w = 0; w < self.hourlyModels.count; w++) {
                
                GWCW_ClubWeather_HourlyWeatherModel *hourModel = self.hourlyModels[w];
                
                /** 风的描述 位置 */
                if (w == 0) {
                    // 第一个色块先不画虚线,从画第二个色块开始,相比较之后,再画第一个和第二个色块之间的虚线
                } else {
                    GWCW_ClubWeather_HourlyWeatherModel *lastHourModel = self.hourlyModels[w-1];
                    
                    if ([lastHourModel.windDir isEqualToString:hourModel.windDir]) { // 风向相同
                        
                        if ([lastHourModel.winp integerValue] == [hourModel.winp integerValue]) { // 风力级别相同
                            // 6小时为最大间隔(初始值为1)
                            sixWindHour = sixWindHour + 1;
                        } else {
                            sixWindHour = 0;
                        }
                    } else {
                        sixWindHour = 0; // 复位
                    }
                    
                    if (![lastHourModel.windDir isEqualToString:hourModel.windDir]) { // 风向不同
                        
                        UIView *redView = [[UIView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/375*(42*w)-2, 0, 4, [UIScreen mainScreen].bounds.size.width/375*(194 - 62 - 85))];
                        redView.backgroundColor = [UIColor greenColor];
                        [self.windRangeView addSubview:redView];
                        
                        
                        CGFloat pointX = [UIScreen mainScreen].bounds.size.width/375*(42 * w);
                        NSString *windDir = self.hourlyModels[w-1].windDir;
                        NSString *winp = self.hourlyModels[w-1].winp;
                        NSDictionary *windPointDic = @{
                            @"pointX":[NSString stringWithFormat:@"%.2f", pointX],
                            @"windDir":windDir,
                            @"winp":winp
                        };
                        
                        [windPointX_array addObject:windPointDic];
                        
                        if (w == self.hourlyModels.count-1) { // 如果这是最后一个渐变色块(添加一个风力描述的位置)
                            
                            CGFloat endPointX = [UIScreen mainScreen].bounds.size.width/375*(42*24);
                            NSString *windDir = self.hourlyModels[w].windDir;
                            NSString *winp = self.hourlyModels[w].winp;
                            NSDictionary *endPointDic = @{
                                @"pointX":[NSString stringWithFormat:@"%.2f", endPointX],
                                @"windDir":windDir,
                                @"winp":winp
                            };
                            [windPointX_array addObject:endPointDic];
                        }
    
                    } else { // 风向相同
                        
                        if ([lastHourModel.winp integerValue] != [hourModel.winp integerValue]) { // 风力级别不同
                            
                            UIView *redView = [[UIView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/375*(42*w)-2, 0, 4, [UIScreen mainScreen].bounds.size.width/375*(194 - 62 - 85))];
                            redView.backgroundColor = [UIColor greenColor];
                            [self.windRangeView addSubview:redView];
                            
                            CGFloat pointX = [UIScreen mainScreen].bounds.size.width/375*(42 * w);
                            NSString *windDir = self.hourlyModels[w-1].windDir;
                            NSString *winp = self.hourlyModels[w-1].winp;
                            NSDictionary *windPointDic = @{
                                @"pointX":[NSString stringWithFormat:@"%.2f", pointX],
                                @"windDir":windDir,
                                @"winp":winp
                            };
                            
                            [windPointX_array addObject:windPointDic];
                            
                            sixWindHour = 0; // 复位
                            
                            if (w == self.hourlyModels.count-1) { // 如果这是最后一个渐变色块(添加一个风力描述的位置)
                                
                                CGFloat endPointX = [UIScreen mainScreen].bounds.size.width/375*(42*24);
                                NSString *windDir = self.hourlyModels[w].windDir;
                                NSString *winp = self.hourlyModels[w].winp;
                                NSDictionary *endPointDic = @{
                                    @"pointX":[NSString stringWithFormat:@"%.2f", endPointX],
                                    @"windDir":windDir,
                                    @"winp":winp
                                };
                                [windPointX_array addObject:endPointDic];
                            }
                            
                        } else { // 风力级别 相同 (风向、风力级别 都相同)
                            
                            if (sixWindHour >= 6) {
                                
                                UIView *redView = [[UIView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/375*(42*w)-2, 0, 4, [UIScreen mainScreen].bounds.size.width/375*(194 - 62 - 85))];
                                redView.backgroundColor = [UIColor greenColor];
                                [self.windRangeView addSubview:redView];
                                
                                CGFloat pointX = [UIScreen mainScreen].bounds.size.width/375*(42 * w);
                                NSString *windDir = self.hourlyModels[w-1].windDir;
                                NSString *winp = self.hourlyModels[w-1].winp;
                                NSDictionary *windPointDic = @{
                                    @"pointX":[NSString stringWithFormat:@"%.2f", pointX],
                                    @"windDir":windDir,
                                    @"winp":winp
                                };
                                
                                [windPointX_array addObject:windPointDic];
                                
                                sixWindHour = 0; // 复位
                                
                                if (w == self.hourlyModels.count-1) { // 如果这是最后一个渐变色块(添加一个风力描述的位置)
                                    
                                    CGFloat endPointX = [UIScreen mainScreen].bounds.size.width/375*(42*24);
                                    NSString *windDir = self.hourlyModels[w].windDir;
                                    NSString *winp = self.hourlyModels[w].winp;
                                    NSDictionary *endPointDic = @{
                                        @"pointX":[NSString stringWithFormat:@"%.2f", endPointX],
                                        @"windDir":windDir,
                                        @"winp":winp
                                    };
                                    [windPointX_array addObject:endPointDic];
                                }
                            } else {
                                
                                if (w == self.hourlyModels.count-1) { // 如果这是最后一个渐变色块(添加一个风力描述的位置)
                                    
    //                                UIView *redView = [[UIView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/375*(42*24)-2, 0, 4, [UIScreen mainScreen].bounds.size.width/375*(194 - 62 - 85))];
    //                                redView.backgroundColor = [UIColor redColor];
    //                                [self.windRangeView addSubview:redView];
                                    
                                    
                                    CGFloat endPointX = [UIScreen mainScreen].bounds.size.width/375*(42*24);
                                    NSString *windDir = self.hourlyModels[w].windDir;
                                    NSString *winp = self.hourlyModels[w].winp;
                                    NSDictionary *endPointDic = @{
                                        @"pointX":[NSString stringWithFormat:@"%.2f", endPointX],
                                        @"windDir":windDir,
                                        @"winp":winp
                                    };
                                    [windPointX_array addObject:endPointDic];
                                }
                                
                            }
                            
                        }
                    }
                }
            }
            /** 判断风力描述 放在哪个位置 使用UIButton */
            /// 风力描述块的最右边 的位置:X轴坐标(处理:风力描述的宽度 = 当前一个虚线坐标.X - 上一个虚线坐标.X -4*2,天气描述的center.X = (当前一个虚线坐标.X - 上一个虚线坐标.X)/2 + 上一个虚线坐标.X ), 第一个 和最后一个需要单独特殊处理
            if (windPointX_array.count > 0) {
    
                for (int X = 0; X < windPointX_array.count; X++) {
    
                    NSDictionary *windPointX_Dic = windPointX_array[X];
                    CGFloat pointX = [[NSString stringWithFormat:@"%@", windPointX_Dic[@"pointX"]] floatValue];
                    NSString *windDir = [NSString stringWithFormat:@"%@", windPointX_Dic[@"windDir"]];
                    NSInteger winp = [[NSString stringWithFormat:@"%@", windPointX_Dic[@"winp"]] integerValue];
    
                    if (X == 0) {
                        
                        UIButton *windBut = [[UIButton alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/375*4, [UIScreen mainScreen].bounds.size.width/375*17, pointX - [UIScreen mainScreen].bounds.size.width/375*(4*2), [UIScreen mainScreen].bounds.size.width/375*17)];
                        windBut.enabled = NO;
                        windBut.backgroundColor = RGBA(0, 0, 0, 0.05);
                        windBut.layer.masksToBounds = YES;
                        windBut.layer.cornerRadius = [UIScreen mainScreen].bounds.size.width/375*3;
                        [windBut setImage:[self returnWindImg_withWinp:winp withDirection:windDir] forState:UIControlStateNormal];
                        
                        // 1、判断 风力级别,显示颜色的深、浅
                        if (winp >= 6) { // 风力级别 >= 6级,颜色 深
                            [windBut setTitleColor:RGBA(9, 9, 9, 1) forState:UIControlStateNormal];
                        } else { // 颜色 浅
                            [windBut setTitleColor:RGBA(153, 153, 153, 1) forState:UIControlStateNormal];
                        }
                        
                        // 2、判断:宽度 => (两个色块的距离-4),保险一点需要减去4
                        if (pointX >= ([UIScreen mainScreen].bounds.size.width/375*42*2 - 4)) { // 大于两个色块(即大于两个小时),“风力描述” 和 “风力级别” 全部显示
                            
                            [windBut setTitle:[NSString stringWithFormat:@" %@%ld级", windDir, winp] forState:UIControlStateNormal];
                            
                        } else { // 1、小于两个色块(即小于两个小时),只显示 “风力级别”
                            [windBut setTitle:[NSString stringWithFormat:@" %ld级", winp] forState:UIControlStateNormal];
                        }
                        
                        windBut.titleLabel.font = [UIFont systemFontOfSize:[UIScreen mainScreen].bounds.size.width/375*10 weight:UIFontWeightRegular];
                        [self.windRangeView addSubview:windBut];
    
                    } else if (X == windPointX_array.count-1) {
                        
                        NSDictionary *lastWindPointX_Dic = windPointX_array[X-1];
                        CGFloat lastPointX = [[NSString stringWithFormat:@"%@", lastWindPointX_Dic[@"pointX"]] floatValue];
                        
                        UIButton *windBut = [[UIButton alloc] initWithFrame:CGRectMake(lastPointX + [UIScreen mainScreen].bounds.size.width/375*4, [UIScreen mainScreen].bounds.size.width/375*17, (pointX - lastPointX) - [UIScreen mainScreen].bounds.size.width/375*(4*2), [UIScreen mainScreen].bounds.size.width/375*17)];
                        windBut.enabled = NO;
                        windBut.backgroundColor = RGBA(0, 0, 0, 0.05);
    //                    windBut.backgroundColor = [UIColor redColor];
                        windBut.layer.masksToBounds = YES;
                        windBut.layer.cornerRadius = [UIScreen mainScreen].bounds.size.width/375*3;
                        [windBut setImage:[self returnWindImg_withWinp:winp withDirection:windDir] forState:UIControlStateNormal];
                        
                        // 1、判断 风力级别,显示颜色的深、浅
                        if (winp >= 6) { // 风力级别 >= 6级,颜色 深
                            [windBut setTitleColor:RGBA(9, 9, 9, 1) forState:UIControlStateNormal];
                        } else { // 颜色 浅
                            [windBut setTitleColor:RGBA(153, 153, 153, 1) forState:UIControlStateNormal];
                        }
                        
                        // 2、判断:宽度 => (两个色块的距离-4),保险一点需要减去4
                        if ((pointX - lastPointX) >= ([UIScreen mainScreen].bounds.size.width/375*42*2 - 4)) { // 大于两个色块(即大于两个小时),“风力描述” 和 “风力级别” 全部显示
                            
                            [windBut setTitle:[NSString stringWithFormat:@" %@%ld级", windDir, winp] forState:UIControlStateNormal];
                            
                        } else { // 1、小于两个色块(即小于两个小时),只显示 “风力级别”
                            [windBut setTitle:[NSString stringWithFormat:@" %ld级", winp] forState:UIControlStateNormal];
                        }
                        
                        windBut.titleLabel.font = [UIFont systemFontOfSize:[UIScreen mainScreen].bounds.size.width/375*10 weight:UIFontWeightRegular];
                        [self.windRangeView addSubview:windBut];
                        
    
    
                    } else {
                        
                        NSDictionary *lastWindPointX_Dic = windPointX_array[X-1];
                        CGFloat lastPointX = [[NSString stringWithFormat:@"%@", lastWindPointX_Dic[@"pointX"]] floatValue];
    
                        UIButton *windBut = [[UIButton alloc] initWithFrame:CGRectMake(lastPointX + [UIScreen mainScreen].bounds.size.width/375*4, [UIScreen mainScreen].bounds.size.width/375*17, (pointX - lastPointX) - [UIScreen mainScreen].bounds.size.width/375*(4*2), [UIScreen mainScreen].bounds.size.width/375*17)];
                        windBut.enabled = NO;
                        windBut.backgroundColor = RGBA(0, 0, 0, 0.05);
                        windBut.layer.masksToBounds = YES;
                        windBut.layer.cornerRadius = [UIScreen mainScreen].bounds.size.width/375*3;
                        [windBut setImage:[self returnWindImg_withWinp:winp withDirection:windDir] forState:UIControlStateNormal];
                        
                        // 1、判断 风力级别,显示颜色的深、浅
                        if (winp >= 6) { // 风力级别 >= 6级,颜色 深
                            [windBut setTitleColor:RGBA(9, 9, 9, 1) forState:UIControlStateNormal];
                        } else { // 颜色 浅
                            [windBut setTitleColor:RGBA(153, 153, 153, 1) forState:UIControlStateNormal];
                        }
                        
                        // 2、判断:宽度 => (两个色块的距离-4),保险一点需要减去4
                        if ((pointX - lastPointX) >= ([UIScreen mainScreen].bounds.size.width/375*42*2 - 4)) { // 大于两个色块(即大于两个小时),“风力描述” 和 “风力级别” 全部显示
                            
                            [windBut setTitle:[NSString stringWithFormat:@" %@%ld级", windDir, winp] forState:UIControlStateNormal];
                            
                        } else { // 1、小于两个色块(即小于两个小时),只显示 “风力级别”
                            [windBut setTitle:[NSString stringWithFormat:@" %ld级", winp] forState:UIControlStateNormal];
                        }
                        
                        windBut.titleLabel.font = [UIFont systemFontOfSize:[UIScreen mainScreen].bounds.size.width/375*10 weight:UIFontWeightRegular];
                        [self.windRangeView addSubview:windBut];
    
                    }
    
    
                }
    
            }
            
            
            
            
            
            self.collectionView.hidden = NO;
            [self refreshCollectionView];
            self.progressBackView.hidden = NO;
            self.progressView.hidden = NO;
            
            
        } else { /** 闭合 内容 */
            
            self.smallBackView.hidden = NO;
            self.bigBackView.hidden = YES;
    
            self.tempView.hidden = NO;
            
            if (self.indexCell == 0) {
                self.dateL.text = @"今天";
            } else if (self.indexCell == 1) {
                self.dateL.text = @"明天";
            } else {
                self.dateL.text = _dailyModel.week;
            }
    //        self.abnormalWeatherImg.image = [UIImage imageNamed:@"weather_abnormal_降雪_icon"];
            if (_dailyModel.alert.count > 0) {
                
                self.abnormalWeatherImgView.hidden = NO;
                
    //            _dailyModel.alert = @[@1,@2,@3,@4,@5];
                
                self.abnormalWeatherImgView.alertArray = _dailyModel.alert; 
                [self.abnormalWeatherImgView refreshCollectionView];
                
                
            } else {
                self.abnormalWeatherImgView.hidden = YES;
            }
            
            self.timeL.text = _dailyModel.date;
            [self.dayImg sd_setImageWithURL:[NSURL URLWithString:_dailyModel.dayUrl] placeholderImage:[UIImage imageNamed:@""]];
            [self.nightImg sd_setImageWithURL:[NSURL URLWithString:_dailyModel.nightUrl] placeholderImage:[UIImage imageNamed:@""]];
            
            NSString *temp = _dailyModel.temp;
            NSArray *tempArr = [temp componentsSeparatedByString:@"/"];
            if (tempArr.count >= 2) {
                self.dayTempL.text = [NSString stringWithFormat:@"%@", tempArr[0]];
                self.nightTempL.text = [NSString stringWithFormat:@"%@", tempArr[1]];
            } else {
                self.dayTempL.text = @"";
                self.nightTempL.text = @"";
            }
            
            if (_dailyModel.isOpen) {
                self.isOPenImg.image = [UIImage imageNamed:@"new_weatherCell_收起_icon"];
            } else {
                self.isOPenImg.image = [UIImage imageNamed:@"new_weatherCell_展开_icon"];
            }
            
            CAGradientLayer *gradient = [CAGradientLayer layer];
            // 写成固定的大小(和self.tempView的frame一样)
            gradient.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width/375*75, [UIScreen mainScreen].bounds.size.width/375*4);
            gradient.colors = [NSArray arrayWithObjects:
                                   (id)[UIColor colorWithRed:255/255.0 green:196/255.0 blue:15/255.0 alpha:1.0].CGColor,
                                   (id)[UIColor colorWithRed:139/255.0 green:192/255.0 blue:246/255.0 alpha:1.0].CGColor,
                                    nil];
            gradient.startPoint = CGPointMake(0, 0.49);
            gradient.endPoint = CGPointMake(1, 0.49);
            gradient.masksToBounds = YES;
            gradient.cornerRadius = [UIScreen mainScreen].bounds.size.width/375*4/2;
            [self.tempView.layer addSublayer:gradient];
            
        }
        
    }
    
    - (void)setupUI {
        
        /** 闭合 内容 */
        
        _smallBackView = [[UIView alloc] init];
        _smallBackView.backgroundColor = [UIColor whiteColor];
        self.smallBackView.layer.cornerRadius = [UIScreen mainScreen].bounds.size.width/375*12;
        self.smallBackView.layer.shadowColor = RGBA(0, 0, 0, 0.05).CGColor;
        self.smallBackView.layer.shadowOffset = CGSizeMake(0, 5);
        self.smallBackView.layer.shadowRadius = [UIScreen mainScreen].bounds.size.width/375*6;
        self.smallBackView.layer.shadowOpacity = 1;
        [self.contentView addSubview:self.smallBackView];
        [self.smallBackView makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.mas_top).offset([UIScreen mainScreen].bounds.size.width/375*5);
            make.left.mas_equalTo(self.mas_left).offset([UIScreen mainScreen].bounds.size.width/375*20);
            make.right.mas_equalTo(self.mas_right).offset(-[UIScreen mainScreen].bounds.size.width/375*20);
            make.bottom.mas_equalTo(self.mas_bottom).offset(-[UIScreen mainScreen].bounds.size.width/375*10);
        }];
        
        _dateL = [[UILabel alloc] init];
        _dateL.textColor = RGBA(9, 9, 9, 1);
        _dateL.textAlignment = NSTextAlignmentLeft;
        _dateL.font = [UIFont systemFontOfSize:[UIScreen mainScreen].bounds.size.width/375*15 weight:UIFontWeightRegular];
        [self.smallBackView addSubview:self.dateL];
        [self.dateL makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.smallBackView.mas_top).offset([UIScreen mainScreen].bounds.size.width/375*10);
            make.left.mas_equalTo(self.smallBackView.mas_left).offset([UIScreen mainScreen].bounds.size.width/375*15);
        }];
        
        _timeL = [[UILabel alloc] init];
        _timeL.textColor = RGBA(153, 153, 153, 1);
        _timeL.textAlignment = NSTextAlignmentLeft;
        _timeL.font = [UIFont systemFontOfSize:[UIScreen mainScreen].bounds.size.width/375*10 weight:UIFontWeightRegular];
        [self.smallBackView addSubview:self.timeL];
        [self.timeL makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(self.smallBackView.mas_bottom).offset(-[UIScreen mainScreen].bounds.size.width/375*9.5);
            make.left.mas_equalTo(self.smallBackView.mas_left).offset([UIScreen mainScreen].bounds.size.width/375*15);
        }];
        
    //    _abnormalWeatherImg = [[UIImageView alloc] init];
    //    [self.smallBackView addSubview:self.abnormalWeatherImg];
    //    [self.abnormalWeatherImg makeConstraints:^(MASConstraintMaker *make) {
    //        make.centerY.equalTo(self.dateL);
    //        make.left.equalTo(self.dateL.mas_right).offset([UIScreen mainScreen].bounds.size.width/375*5);
    //        make.width.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*32);
    //        make.height.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*15);
    //    }];
        // 异常天气
        _abnormalWeatherImgView = [[CWNew_TimerAbnormalWeatherImgView alloc] init];
        [self.smallBackView addSubview:self.abnormalWeatherImgView];
        [self.abnormalWeatherImgView makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.dateL);
            make.left.equalTo(self.dateL.mas_right).offset([UIScreen mainScreen].bounds.size.width/375*5);
            make.width.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*33); // 32
            make.height.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*15);// 17
        }];
        
        _tempView = [[UIView alloc] init];
        self.tempView.layer.masksToBounds = YES;
        self.tempView.layer.cornerRadius = [UIScreen mainScreen].bounds.size.width/375*4/2;
        [self addSubview:self.tempView];
        [self.tempView makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self);
            make.left.mas_equalTo(self.smallBackView.mas_left).offset([UIScreen mainScreen].bounds.size.width/375*177);
    //        make.right.mas_equalTo(self.smallBackView.mas_right).offset(-[UIScreen mainScreen].bounds.size.width/375*106);
            make.width.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*50);
            make.height.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*4);
        }];
        
        _dayImg = [[UIImageView alloc] init];
        [self.smallBackView addSubview:self.dayImg];
        [self.dayImg makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.smallBackView);
            make.right.mas_equalTo(self.tempView.mas_left).offset(-[UIScreen mainScreen].bounds.size.width/375*45);
            make.width.height.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*23);
        }];
        
        _nightImg = [[UIImageView alloc] init];
        [self.smallBackView addSubview:self.nightImg];
        [self.nightImg makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.smallBackView);
            make.left.mas_equalTo(self.tempView.mas_right).offset([UIScreen mainScreen].bounds.size.width/375*45);
            make.width.height.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*23);
        }];
        
        _dayTempL = [[UILabel alloc] init];
        _dayTempL.textColor = RGBA(64, 64, 64, 1);
        _dayTempL.textAlignment = NSTextAlignmentRight;
        _dayTempL.font = [UIFont systemFontOfSize:[UIScreen mainScreen].bounds.size.width/375*16 weight:UIFontWeightMedium];
        [self.smallBackView addSubview:self.dayTempL];
        [self.dayTempL makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.smallBackView);
            make.right.mas_equalTo(self.tempView.mas_left).offset(-[UIScreen mainScreen].bounds.size.width/375*10);
        }];
        
        _nightTempL = [[UILabel alloc] init];
        _nightTempL.textColor = RGBA(64, 64, 64, 1);
        _nightTempL.textAlignment = NSTextAlignmentRight;
        _nightTempL.font = [UIFont systemFontOfSize:[UIScreen mainScreen].bounds.size.width/375*16 weight:UIFontWeightMedium];
        [self.smallBackView addSubview:self.nightTempL];
        [self.nightTempL makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.smallBackView);
            make.left.mas_equalTo(self.tempView.mas_right).offset([UIScreen mainScreen].bounds.size.width/375*10);
        }];
        
        _isOPenImg = [[UIImageView alloc] init];
        [self.smallBackView addSubview:self.isOPenImg];
        [self.isOPenImg makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.smallBackView);
            make.right.mas_equalTo(self.smallBackView.mas_right).offset(-[UIScreen mainScreen].bounds.size.width/375*6);
            make.width.height.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*25);
        }];
        
        
        /** 展开 内容 */
        _bigBackView = [[UIView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/375*20, [UIScreen mainScreen].bounds.size.width/375*5, [UIScreen mainScreen].bounds.size.width/375*335, [UIScreen mainScreen].bounds.size.width/375*330)];
        _bigBackView.backgroundColor = [UIColor whiteColor];
        self.bigBackView.layer.cornerRadius = [UIScreen mainScreen].bounds.size.width/375*12;
        self.bigBackView.layer.shadowColor = RGBA(0, 0, 0, 0.05).CGColor;
        self.bigBackView.layer.shadowOffset = CGSizeMake(0, 5);
        self.bigBackView.layer.shadowRadius = [UIScreen mainScreen].bounds.size.width/375*6;
        self.bigBackView.layer.shadowOpacity = 1;
        [self.contentView addSubview:self.bigBackView];
        
        _big_TimeL = [[UILabel alloc] init];
        _big_TimeL.textColor = RGBA(99, 102, 106, 1);
        _big_TimeL.textAlignment = NSTextAlignmentLeft;
        _big_TimeL.font = [UIFont systemFontOfSize:[UIScreen mainScreen].bounds.size.width/375*15 weight:UIFontWeightRegular];
        [self.bigBackView addSubview:self.big_TimeL];
        [self.big_TimeL makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.bigBackView.mas_top).offset([UIScreen mainScreen].bounds.size.width/375*20);
            make.left.mas_equalTo(self.bigBackView.mas_left).offset([UIScreen mainScreen].bounds.size.width/375*15);
        }];
        
        _big_weatherImg = [[UIImageView alloc] init];
        [self.bigBackView addSubview:self.big_weatherImg];
        [self.big_weatherImg makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.big_TimeL.mas_bottom).offset([UIScreen mainScreen].bounds.size.width/375*20);
            make.left.mas_equalTo(self.bigBackView.mas_left).offset([UIScreen mainScreen].bounds.size.width/375*15);
            make.width.height.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*19);
        }];
        
        _big_tempL = [[UILabel alloc] init];
        _big_tempL.textColor = RGBA(64, 64, 64, 1);
        _big_tempL.textAlignment = NSTextAlignmentLeft;
        _big_tempL.font = [UIFont systemFontOfSize:[UIScreen mainScreen].bounds.size.width/375*20 weight:UIFontWeightMedium];
        [self.bigBackView addSubview:self.big_tempL];
        [self.big_tempL makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.big_weatherImg);
            make.left.mas_equalTo(self.big_weatherImg.mas_right).offset([UIScreen mainScreen].bounds.size.width/375*5);
        }];
        
        _big_weatherTextL = [[UILabel alloc] init];
        _big_weatherTextL.textColor = RGBA(105, 104, 108, 1);
        _big_weatherTextL.textAlignment = NSTextAlignmentLeft;
        _big_weatherTextL.font = [UIFont systemFontOfSize:[UIScreen mainScreen].bounds.size.width/375*13 weight:UIFontWeightRegular];
        [self.bigBackView addSubview:self.big_weatherTextL];
        [self.big_weatherTextL makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.big_weatherImg.mas_bottom).offset([UIScreen mainScreen].bounds.size.width/375*10);
            make.left.mas_equalTo(self.bigBackView.mas_left).offset([UIScreen mainScreen].bounds.size.width/375*15);
        }];
        
        _lineWinpView = [[UIView alloc] init];
        self.lineWinpView.backgroundColor = RGBA(105, 104, 108, 1);
        [self.bigBackView addSubview:self.lineWinpView];
        [self.lineWinpView makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.big_weatherTextL);
            make.left.mas_equalTo(self.big_weatherTextL.mas_right).offset([UIScreen mainScreen].bounds.size.width/375*3);
            make.width.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*1);
            make.height.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*13);
        }];
        
        _big_winpL = [[UILabel alloc] init];
        _big_winpL.textColor = RGBA(105, 104, 108, 1);
        _big_winpL.textAlignment = NSTextAlignmentLeft;
        _big_winpL.font = [UIFont systemFontOfSize:[UIScreen mainScreen].bounds.size.width/375*13 weight:UIFontWeightRegular];
        [self.bigBackView addSubview:self.big_winpL];
        [self.big_winpL makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.big_weatherTextL);
            make.left.mas_equalTo(self.big_weatherTextL.mas_right).offset([UIScreen mainScreen].bounds.size.width/375*7);
        }];
        
        _big_isOPenImg = [[UIImageView alloc] init];
        [self.bigBackView addSubview:self.big_isOPenImg];
        [self.big_isOPenImg makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.bigBackView.mas_top).offset([UIScreen mainScreen].bounds.size.width/375*22);
            make.right.mas_equalTo(self.bigBackView.mas_right).offset(-[UIScreen mainScreen].bounds.size.width/375*6);
            make.width.height.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*25);
        }];
        
        _big_dayImg = [[UIImageView alloc] init];
        [self.bigBackView addSubview:self.big_dayImg];
        [self.big_dayImg makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(self.big_weatherTextL);
            make.right.mas_equalTo(self.bigBackView.mas_right).offset(-[UIScreen mainScreen].bounds.size.width/375*134);
            make.width.height.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*14);
        }];
        
        _big_nightImg = [[UIImageView alloc] init];
        [self.bigBackView addSubview:self.big_nightImg];
        [self.big_nightImg makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.big_dayImg);
            make.right.mas_equalTo(self.bigBackView.mas_right).offset(-[UIScreen mainScreen].bounds.size.width/375*55);
            make.width.height.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*14);
        }];
        
        _big_dayTimeL = [[UILabel alloc] init];
        _big_dayTimeL.textColor = RGBA(105, 104, 108, 1);
        _big_dayTimeL.textAlignment = NSTextAlignmentLeft;
        _big_dayTimeL.font = [UIFont systemFontOfSize:[UIScreen mainScreen].bounds.size.width/375*13 weight:UIFontWeightRegular];
        [self.bigBackView addSubview:self.big_dayTimeL];
        [self.big_dayTimeL makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.big_dayImg);
            make.left.mas_equalTo(self.big_dayImg.mas_right).offset([UIScreen mainScreen].bounds.size.width/375*6);
        }];
        
        _big_noghtTimeL = [[UILabel alloc] init];
        _big_noghtTimeL.textColor = RGBA(105, 104, 108, 1);
        _big_noghtTimeL.textAlignment = NSTextAlignmentLeft;
        _big_noghtTimeL.font = [UIFont systemFontOfSize:[UIScreen mainScreen].bounds.size.width/375*13 weight:UIFontWeightRegular];
        [self.bigBackView addSubview:self.big_noghtTimeL];
        [self.big_noghtTimeL makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.big_nightImg);
            make.left.mas_equalTo(self.big_nightImg.mas_right).offset([UIScreen mainScreen].bounds.size.width/375*6);
        }];
        
        _big_toSunsetBackView = [[UIView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/375*(335 - 23 - (10 + 99 + 10)), [UIScreen mainScreen].bounds.size.width/375*(81 - 30), [UIScreen mainScreen].bounds.size.width/375*(10 + 99 + 10), [UIScreen mainScreen].bounds.size.width/375*30)];
        _big_toSunsetBackView.backgroundColor = [UIColor clearColor];
        self.big_toSunsetBackView.layer.masksToBounds = YES;
        [self.bigBackView addSubview:self.big_toSunsetBackView];
    //    [self.big_toSunsetBackView makeConstraints:^(MASConstraintMaker *make) {
    //        make.bottom.mas_equalTo(self.big_dayImg.mas_top).offset(-[UIScreen mainScreen].bounds.size.width/375*5);
    //        make.right.mas_equalTo(self.bigBackView.mas_right).offset(-[UIScreen mainScreen].bounds.size.width/375*(23));
    //        make.width.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*(10 + 99 + 10));
    //        make.height.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*30);
    //    }];
        
         
        self.bigBackView.hidden = YES;
        
        
        /** 展开时:折线图 42 * 24 */
        
        _chartBackView = [[UIView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/375*12, [UIScreen mainScreen].bounds.size.width/375*115, [UIScreen mainScreen].bounds.size.width/375*(375-20-20-12-12), [UIScreen mainScreen].bounds.size.width/375*194)];
        self.chartBackView.backgroundColor = RGBA(248, 247, 245, 1);
        self.chartBackView.layer.masksToBounds = YES;
        self.chartBackView.layer.cornerRadius = [UIScreen mainScreen].bounds.size.width/375*5;
        [self.bigBackView addSubview:self.chartBackView];
        
        
        _chartContentScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width/375*(375-20-20-12-12), [UIScreen mainScreen].bounds.size.width/375*194)];
        self.chartContentScrollView.backgroundColor = [UIColor clearColor];
        self.chartContentScrollView.delegate = self;
        self.chartContentScrollView.showsHorizontalScrollIndicator = NO;
        self.chartContentScrollView.scrollEnabled = YES;
        [self.chartBackView addSubview:self.chartContentScrollView];
        
        if (!self.chartContentScrollView.contentSize.width) {
            self.chartContentScrollView.contentSize = CGSizeMake([UIScreen mainScreen].bounds.size.width/375*(42*24), self.chartContentScrollView.frame.size.height);
        }
        
        // 折线📈 范围view
        _chartContentView = [[UIView alloc] initWithFrame:CGRectMake(0, [UIScreen mainScreen].bounds.size.width/375*(62), self.chartContentScrollView.contentSize.width, [UIScreen mainScreen].bounds.size.width/375*85)];
        self.chartContentView.layer.masksToBounds = YES;
        [self.chartContentScrollView addSubview:self.chartContentView];
        self.chartContentView.backgroundColor = RGBA(248, 247, 245, 1);
    //    self.chartContentView.backgroundColor = RGBA(213, 175, 255, 1);
    //    self.chartContentView.backgroundColor = RGBA(204, 204, 204, 1);
        
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        layout.sectionHeadersPinToVisibleBounds = NO;
        layout.sectionFootersPinToVisibleBounds = NO;
        
        UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.chartContentScrollView.contentSize.width, self.chartContentScrollView.frame.size.height) collectionViewLayout:layout];
        collectionView.backgroundColor = [UIColor clearColor];
    //    collectionView.backgroundColor = RGBA(176, 100, 200, 0.3);
        collectionView.delegate = self;
        collectionView.dataSource = self;
        collectionView.showsVerticalScrollIndicator = NO;
        collectionView.scrollEnabled = NO;
        [self.chartContentScrollView addSubview:collectionView];
        [collectionView registerClass:[GWCW_NewClubWeatherChildCell class] forCellWithReuseIdentifier:NSStringFromClass([GWCW_NewClubWeatherChildCell class])];
        self.collectionView = collectionView;
        
        // 滑动 进度:
        _progressBackView = [[UIView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/375*(335-136)/2, [UIScreen mainScreen].bounds.size.width/375*317, [UIScreen mainScreen].bounds.size.width/375*136, [UIScreen mainScreen].bounds.size.width/375*3)];
        _progressBackView.backgroundColor = RGBA(248, 247, 245, 1);
        self.progressBackView.layer.masksToBounds = YES;
        self.progressBackView.layer.cornerRadius = [UIScreen mainScreen].bounds.size.width/375*3/2;
        [self.bigBackView addSubview:self.progressBackView];
        
        _progressView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width/375*18, [UIScreen mainScreen].bounds.size.width/375*3)];
        self.progressView.backgroundColor = RGBA(255, 196, 15, 1);
        self.progressView.layer.masksToBounds = YES;
        self.progressView.layer.cornerRadius = [UIScreen mainScreen].bounds.size.width/375*3/2;
        [self.progressBackView addSubview:self.progressView];
        
        self.progressBackView.hidden = YES;
        self.progressView.hidden = YES;
        
    }
    
    - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
        
        if (scrollView == self.chartContentScrollView) {
            
            if (self.chartContentScrollView.contentOffset.x <= 0) {
                self.progressView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width/375*18, [UIScreen mainScreen].bounds.size.width/375*3);
            } else if (self.chartContentScrollView.contentOffset.x >= [UIScreen mainScreen].bounds.size.width/375*(42*24 - 311)) {
                
                self.progressView.frame = CGRectMake([UIScreen mainScreen].bounds.size.width/375*(136-18), 0, [UIScreen mainScreen].bounds.size.width/375*18, [UIScreen mainScreen].bounds.size.width/375*3);
            } else {
                
                CGFloat contentOffsetX = ([UIScreen mainScreen].bounds.size.width/375*(136-18)) * self.chartContentScrollView.contentOffset.x / ([UIScreen mainScreen].bounds.size.width/375*(42*24 - 311));
                
                self.progressView.frame = CGRectMake(contentOffsetX, 0, [UIScreen mainScreen].bounds.size.width/375*18, [UIScreen mainScreen].bounds.size.width/375*3);
            }
        }
    }
    
    - (void)refreshCollectionView {
        [self.collectionView reloadData];
    }
    
    #pragma mark -- -- < UICollectionViewDelegate, UICollectionViewDataSource >
    - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
        return 1;
    }
    
    - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
        return self.hourlyModels.count;
    }
    
    -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
        return CGSizeMake([UIScreen mainScreen].bounds.size.width/375*41.9, [UIScreen mainScreen].bounds.size.width/375*193);
        
    }
    
    - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
        // 水平上下
        return [UIScreen mainScreen].bounds.size.width/375*0;
    }
    
    - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
        // 垂直左右
        return [UIScreen mainScreen].bounds.size.width/375*1;
    }
    
    - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
        // section 边界
        return UIEdgeInsetsMake([UIScreen mainScreen].bounds.size.width/375*0, [UIScreen mainScreen].bounds.size.width/375*0, [UIScreen mainScreen].bounds.size.width/375*0, [UIScreen mainScreen].bounds.size.width/375*0);
    }
    
    - (nonnull __kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
        GWCW_NewClubWeatherChildCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([GWCW_NewClubWeatherChildCell class]) forIndexPath:indexPath];
        
        if (self.hourlyModels.count) {
            cell.itemCell = indexPath.row;
            cell.hourlyModel = self.hourlyModels[indexPath.row];
        }
        return cell;
    }
    
    - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
        GWCW_NewClubWeatherChildCell *cell = (GWCW_NewClubWeatherChildCell *)[collectionView cellForItemAtIndexPath:indexPath];
        
    }
    
    
    #pragma mark -- -- 太阳☀️曲线
    - (void)SunriseAndSunset:(CGFloat)toSunset { // 日落:太阳☀️ _dailyModel.toSunset(圆弧曲线)0~1(0 日出,1 日落)
        
        _big_toSunsetBackViewLayer = [[CAShapeLayer alloc] init];
        _big_toSunsetBackViewLayer.strokeColor = [UIColor clearColor].CGColor;
        UIBezierPath *bezierPath = [UIBezierPath
                                        bezierPathWithRoundedRect:CGRectMake(0, 0, self.big_toSunsetBackView.frame.size.width, self.big_toSunsetBackView.frame.size.height)
                                        byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
                                        cornerRadii:CGSizeMake([UIScreen mainScreen].bounds.size.width/375*0, [UIScreen mainScreen].bounds.size.width/375*0)];
        
        _big_toSunsetBackViewLayer.lineWidth = [UIScreen mainScreen].bounds.size.width/375*0.01;
        // 颜色
        _big_toSunsetBackViewLayer.strokeColor = [UIColor clearColor].CGColor;
        // 背景填充色
        _big_toSunsetBackViewLayer.fillColor = [UIColor clearColor].CGColor;
        _big_toSunsetBackViewLayer.path = [bezierPath CGPath];
        
        [self.big_toSunsetBackView.layer addSublayer:self.big_toSunsetBackViewLayer];
        
        
        // 圆弧虚线
        CAShapeLayer *toSunsetBackLineLayer = [CAShapeLayer layer];
        // 线宽
        toSunsetBackLineLayer.lineWidth = [UIScreen mainScreen].bounds.size.width/375*1; // 10 - 6 = 4
        toSunsetBackLineLayer.lineCap = kCALineCapButt;  // 端点样式
        toSunsetBackLineLayer.lineJoin = kCALineCapButt; // 终点处理
        // 线条的颜色
        toSunsetBackLineLayer.strokeColor = RGBA(221, 221, 221, 1).CGColor;
        // 背景填充色
        toSunsetBackLineLayer.fillColor = [UIColor clearColor].CGColor;
        // 设置线宽、线间距(虚线)
        [toSunsetBackLineLayer setLineDashPattern:[NSArray arrayWithObjects:[NSNumber numberWithInt:2], [NSNumber numberWithInt:2], nil]];
        // 设置半径
        CGFloat backRadius = [UIScreen mainScreen].bounds.size.width/375*132/2;
        
        // 初始化一个路径:创建圆弧 ,startAngle:起始点,endAngle:终止点,clockwise:顺时针方向 ,M_PI == π:3.1415926
        // bezierPathWithArcCenter 中心点,下面就让addSublayer了,那么就设置self.bezierBackImg.layer的 中心点就好了,宽/2,高/2
        UIBezierPath *backPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.big_toSunsetBackView.frame.size.width/2, [UIScreen mainScreen].bounds.size.width/375*132/2 + 9) radius:backRadius startAngle:(1.25*M_PI) endAngle:(1.75*M_PI) clockwise:YES]; // 终止点(60%几率时):(2*0.6 - 0.25)*M_PI,clockwise 顺时针 YES, 逆时针 NO
        
        // 将UIBezierPath类转换成CGPath,类似于UIColor的CGColor
        toSunsetBackLineLayer.path = [backPath CGPath];
        [self.big_toSunsetBackViewLayer addSublayer:toSunsetBackLineLayer];
    
        /// 贝塞尔曲线(进度)
        CAShapeLayer *progressLineLayer = [CAShapeLayer layer];
        // 线宽
        progressLineLayer.lineWidth = [UIScreen mainScreen].bounds.size.width/375*2; // 10 - 6 = 4
        progressLineLayer.lineCap = kCALineCapSquare;  // 端点样式
        progressLineLayer.lineJoin = kCALineCapSquare; // 终点处理
        // 线条的颜色
        progressLineLayer.strokeColor = RGBA(255, 196, 15, 1).CGColor;
        // 背景填充色
        progressLineLayer.fillColor = [UIColor clearColor].CGColor;
        // 设置线宽、线间距(虚线)
    //        [progressLineLayer setLineDashPattern:[NSArray arrayWithObjects:[NSNumber numberWithInt:2], [NSNumber numberWithInt:2], nil]];
        // 设置半径
        CGFloat progressRadius = [UIScreen mainScreen].bounds.size.width/375*132/2;
        
        // 初始化一个路径:创建圆弧 ,startAngle:起始点,endAngle:终止点,clockwise:顺时针方向 ,M_PI == π:3.1415926
        // bezierPathWithArcCenter 中心点,下面就让addSublayer了,那么就设置self.bezierBackImg.layer的 中心点就好了,宽/2,高/2
        UIBezierPath *progressPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.big_toSunsetBackView.frame.size.width/2, [UIScreen mainScreen].bounds.size.width/375*132/2 + 9) radius:progressRadius startAngle:(1.25*M_PI) endAngle:((1.25 + 0.5*(_dailyModel.toSunset))*M_PI) clockwise:YES]; // 终止点(60%几率时):(2*0.6 - 0.25)*M_PI,clockwise 顺时针 YES, 逆时针 NO
    
        // 将UIBezierPath类转换成CGPath,类似于UIColor的CGColor
        progressLineLayer.path = [progressPath CGPath];
        [self.big_toSunsetBackViewLayer addSublayer:progressLineLayer];
    
        // 当前path的位置,可以理解为path的终点:
        UIBezierPath *sunPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.big_toSunsetBackView.frame.size.width/2, [UIScreen mainScreen].bounds.size.width/375*132/2 + 9) radius:progressRadius startAngle:(1.25*M_PI) endAngle:((1.25 + 0.5*(_dailyModel.toSunset))*M_PI) clockwise:YES];
        CGPoint currentPoint = sunPath.currentPoint;
        _toSunsetImg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width/375*20, [UIScreen mainScreen].bounds.size.width/375*20)];
        self.toSunsetImg.center = currentPoint;
        self.toSunsetImg.backgroundColor = [UIColor clearColor];
        self.toSunsetImg.image = [UIImage imageNamed:@"club_sun"];
        [self.big_toSunsetBackView addSubview:self.toSunsetImg];
        
    //    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    //    // 设置动画的路径为心形路径
    //    animation.path = sunPath.CGPath;
    //    // 动画时间间隔
    //    animation.duration = 3.0f;
    //    // 重复次数为最大值
    //    animation.repeatCount = FLT_MAX;
    //    animation.removedOnCompletion = NO;
    //    animation.fillMode = kCAFillModeForwards;
    //    // 将动画添加到动画视图上
    //    [self.big_toSunsetBackViewLayer addAnimation:animation forKey:nil];
        
        
    //    UIBezierPath *sunStartPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.big_toSunsetBackView.frame.size.width/2, [UIScreen mainScreen].bounds.size.width/375*132/2 + 9) radius:progressRadius startAngle:(1.25*M_PI) endAngle:((1.25)*M_PI) clockwise:YES];
    //    CGPoint startPoint = sunStartPath.currentPoint;
    //    self.toSunsetImg.center = startPoint;
    //    [UIView animateWithDuration:2 animations:^{
    //        self.toSunsetImg.center = currentPoint;
    //    } completion:^(BOOL finished) {
    //        self.toSunsetImg.center = currentPoint;
    //    }];
        
    }
    
    #pragma mark -- -- 24小时 渐变色CAGradientLayer 色块的颜色色值:
    - (NSArray *)returnGradientColors:(NSInteger)weatherCode {
        /**
         三、设计图中9种颜色分类和对应天气描述编号: weatherCode // 天气代码:code
         晴:1 18
         多云:2
         雾:11
         霾:4 5 6
         沙尘:16 17
         阴:3
         雨:7 8 9 10
         雷阵雨:19 20
         雪:12 13 14 15 21
         */
        NSArray *colors = [NSArray array];
        if (weatherCode == 1 || weatherCode == 18) { // 晴☀️
            colors = [NSArray arrayWithObjects:
                               (id)[UIColor colorWithRed:255/255.0 green:196/255.0 blue:15/255.0 alpha:0.3].CGColor,
                               (id)[UIColor colorWithRed:255/255.0 green:196/255.0 blue:15/255.0 alpha:0.2].CGColor,
                               (id)[UIColor colorWithRed:255/255.0 green:196/255.0 blue:15/255.0 alpha:0.0].CGColor,
                                    nil];
            return colors;
        } else if (weatherCode == 2) { // 多云⛅️
            colors = [NSArray arrayWithObjects:
                               (id)[UIColor colorWithRed:144/255.0 green:220/255.0 blue:255/255.0 alpha:0.3].CGColor,
                               (id)[UIColor colorWithRed:144/255.0 green:220/255.0 blue:255/255.0 alpha:0.2].CGColor,
                               (id)[UIColor colorWithRed:144/255.0 green:220/255.0 blue:255/255.0 alpha:0.0].CGColor,
                                    nil];
            return colors;
        } else if (weatherCode == 11) { // 雾🌫
            colors = [NSArray arrayWithObjects:
                               (id)[UIColor colorWithRed:196/255.0 green:215/255.0 blue:220/255.0 alpha:0.3].CGColor,
                               (id)[UIColor colorWithRed:196/255.0 green:215/255.0 blue:220/255.0 alpha:0.2].CGColor,
                               (id)[UIColor colorWithRed:196/255.0 green:215/255.0 blue:220/255.0 alpha:0.0].CGColor,
                                    nil];
            return colors;
        } else if (weatherCode == 4 || weatherCode == 5 || weatherCode == 6) { // 霾🌫
            
            colors = [NSArray arrayWithObjects:
                               (id)[UIColor colorWithRed:123/255.0 green:139/255.0 blue:156/255.0 alpha:0.3].CGColor,
                               (id)[UIColor colorWithRed:123/255.0 green:139/255.0 blue:156/255.0 alpha:0.2].CGColor,
                               (id)[UIColor colorWithRed:123/255.0 green:139/255.0 blue:156/255.0 alpha:0.0].CGColor,
                                    nil];
            return colors;
            
        } else if (weatherCode == 16 || weatherCode == 17) { // 沙尘
            colors = [NSArray arrayWithObjects:
                               (id)[UIColor colorWithRed:255/255.0 green:206/255.0 blue:152/255.0 alpha:0.3].CGColor,
                               (id)[UIColor colorWithRed:255/255.0 green:206/255.0 blue:152/255.0 alpha:0.2].CGColor,
                               (id)[UIColor colorWithRed:255/255.0 green:206/255.0 blue:152/255.0 alpha:0.0].CGColor,
                                    nil];
            return colors;
            
        } else if (weatherCode == 3) { // 阴天☁️
            
            colors = [NSArray arrayWithObjects:
                               (id)[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:0.3].CGColor,
                               (id)[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:0.2].CGColor,
                               (id)[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:0.0].CGColor,
                                    nil];
            return colors;
            
        } else if (weatherCode == 7 || weatherCode == 8 || weatherCode == 9 || weatherCode == 10) { // 雨🌧
            
            colors = [NSArray arrayWithObjects:
                               (id)[UIColor colorWithRed:161/255.0 green:175/255.0 blue:181/255.0 alpha:0.3].CGColor,
                               (id)[UIColor colorWithRed:161/255.0 green:175/255.0 blue:181/255.0 alpha:0.2].CGColor,
                               (id)[UIColor colorWithRed:161/255.0 green:175/255.0 blue:181/255.0 alpha:0.0].CGColor,
                                    nil];
            return colors;
            
        } else if (weatherCode == 19 || weatherCode == 20) { // 雷阵雨⛈
            
            colors = [NSArray arrayWithObjects:
                               (id)[UIColor colorWithRed:152/255.0 green:165/255.0 blue:254/255.0 alpha:0.3].CGColor,
                               (id)[UIColor colorWithRed:152/255.0 green:165/255.0 blue:254/255.0 alpha:0.2].CGColor,
                               (id)[UIColor colorWithRed:152/255.0 green:165/255.0 blue:254/255.0 alpha:0.0].CGColor,
                                    nil];
            return colors;
            
        } else if (weatherCode == 12 || weatherCode == 13 || weatherCode == 14 || weatherCode == 15 || weatherCode == 21) { // 雪❄️🌨
            
            colors = [NSArray arrayWithObjects:
                               (id)[UIColor colorWithRed:131/255.0 green:197/255.0 blue:255/255.0 alpha:0.3].CGColor,
                               (id)[UIColor colorWithRed:131/255.0 green:197/255.0 blue:255/255.0 alpha:0.2].CGColor,
                               (id)[UIColor colorWithRed:131/255.0 green:197/255.0 blue:255/255.0 alpha:0.0].CGColor,
                                    nil];
            return colors;
            
        } else {
            colors = [NSArray arrayWithObjects:
                               (id)[UIColor colorWithRed:255/255.0 green:196/255.0 blue:15/255.0 alpha:0.3].CGColor,
                               (id)[UIColor colorWithRed:255/255.0 green:196/255.0 blue:15/255.0 alpha:0.2].CGColor,
                               (id)[UIColor colorWithRed:255/255.0 green:196/255.0 blue:15/255.0 alpha:0.0].CGColor,
                                    nil];
            return colors;
        }
        
    }
    
    #pragma mark -- -- 根据:风力方向、风力级别 判断显示哪个 风力方向图片
    - (UIImage *)returnWindImg_withWinp:(NSInteger)winp withDirection:(NSString *)windDir {
        
        UIImage *windImg = [UIImage imageNamed:@"windDirection_big_NanWind_icon"];
        
        if (winp >= 6) { // 深色
            
            if ([windDir isEqualToString:@"北风"]) {
                windImg = [UIImage imageNamed:@"windDirection_big_BeiWind_icon"];
                
            } else if ([windDir isEqualToString:@"东北风"]) {
                windImg = [UIImage imageNamed:@"windDirection_big_DongBeiWind_icon"];
                
            } else if ([windDir isEqualToString:@"东风"]) {
                windImg = [UIImage imageNamed:@"windDirection_big_DongWind_icon"];
                
            } else if ([windDir isEqualToString:@"东南风"]) {
                windImg = [UIImage imageNamed:@"windDirection_big_DongNanWind_icon"];
                
            } else if ([windDir isEqualToString:@"南风"]) {
                windImg = [UIImage imageNamed:@"windDirection_big_NanWind_icon"];
                
            } else if ([windDir isEqualToString:@"西南风"]) {
                windImg = [UIImage imageNamed:@"windDirection_big_XiNanWind_icon"];
                
            } else if ([windDir isEqualToString:@"西风"]) {
                windImg = [UIImage imageNamed:@"windDirection_big_XiWind_icon"];
                
            } else if ([windDir isEqualToString:@"西北风"]) {
                windImg = [UIImage imageNamed:@"windDirection_big_XiBeiWind_icon"];
                
            }
            
        } else { // 浅色
            
            if ([windDir isEqualToString:@"北风"]) {
                windImg = [UIImage imageNamed:@"windDirection_small_BeiWind_icon"];
                
            } else if ([windDir isEqualToString:@"东北风"]) {
                windImg = [UIImage imageNamed:@"windDirection_small_DongBeiWind_icon"];
                
            } else if ([windDir isEqualToString:@"东风"]) {
                windImg = [UIImage imageNamed:@"windDirection_small_DongWind_icon"];
                
            } else if ([windDir isEqualToString:@"东南风"]) {
                windImg = [UIImage imageNamed:@"windDirection_small_DongNanWind_icon"];
                
            } else if ([windDir isEqualToString:@"南风"]) {
                windImg = [UIImage imageNamed:@"windDirection_small_NanWind_icon"];
                
            } else if ([windDir isEqualToString:@"西南风"]) {
                windImg = [UIImage imageNamed:@"windDirection_small_XiNanWind_icon"];
                
            } else if ([windDir isEqualToString:@"西风"]) {
                windImg = [UIImage imageNamed:@"windDirection_small_XiWind_icon"];
                
            } else if ([windDir isEqualToString:@"西北风"]) {
                windImg = [UIImage imageNamed:@"windDirection_small_XiBeiWind_icon"];
            }
            
        }
        
        return windImg;
        
    }
    
    
    - (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
    
    

    相关文章

      网友评论

        本文标题:ios ~ 贝塞尔曲线:天气预报(包含温度、渐变色块、风力)

        本文链接:https://www.haomeiwen.com/subject/nnhdjrtx.html