代码:
#pragma mark ****** 4、台风:轨迹 “高德地图:【绘制折线】、【点平滑移动 】” ******
- (void)setupTyphoonTrack {
if (self.groundOverlay != nil) {
[self.mapView removeOverlay:self.groundOverlay]; // 删除 【绘制面】(图片覆盖物)overlay
self.groundOverlay = nil;
}
if (self.commonPolyline != nil) {
[self.mapView removeOverlay:self.commonPolyline]; // 删除 【绘制折线】(这里特指:台风)overlay
self.commonPolyline = nil;
}
for (MAAnnotationMoveAnimation *animation in [self.typhoon_AnimatedAnnotation allMoveAnimations]) {
[animation cancel];
}
if (self.typhoon_AnimatedAnnotation != nil) {
[self.mapView removeAnnotation:self.typhoon_AnimatedAnnotation]; // 删除 【点平滑移动】(这里特指 台风的图片)Annotation
self.typhoon_AnimatedAnnotation = nil;
}
if (self.locatinWeather_AnimatedAnnotation != nil) {
[self.mapView removeAnnotation:self.locatinWeather_AnimatedAnnotation]; // 删除 【自定义气泡】Annotation
self.locatinWeather_AnimatedAnnotation = nil;
}
if (self.raderMapDateModel.typhoon.count > 0) {
// 构造折线数据对象
CLLocationCoordinate2D commonPolylineCoords[self.raderMapDateModel.typhoon[0].routes.count];
for (int i = 0; i < self.raderMapDateModel.typhoon[0].routes.count; i++) {
GWHomeRaderMap_TyphoonRoutesModel *typhoonRoutesModel = self.raderMapDateModel.typhoon[0].routes[i];
commonPolylineCoords[i].latitude = typhoonRoutesModel.latitude;
commonPolylineCoords[i].longitude = typhoonRoutesModel.longitude;
}
/** 高德地图:构造折线对象 */
MAPolyline *commonPolyline = [MAPolyline polylineWithCoordinates:commonPolylineCoords count:self.raderMapDateModel.typhoon[0].routes.count];
//在地图上添加折线对象(再 实现 <MAMapViewDelegate> 协议中的 mapView:rendererForOverlay: 回调函数,设置折线的样式)
[self.mapView addOverlay:commonPolyline];
self.commonPolyline = commonPolyline;
[self.mapView setCenterCoordinate:CLLocationCoordinate2DMake(self.raderMapDateModel.typhoon[0].routes[0].latitude, self.raderMapDateModel.typhoon[0].routes[0].longitude) animated:YES];
[self.mapView setZoomLevel:6 animated:YES];
/** 高德地图:点平滑移动 */
if (self.typhoon_AnimatedAnnotation == nil) {
MAAnimatedAnnotation *animatedAnnotation = [[MAAnimatedAnnotation alloc] init];
animatedAnnotation.coordinate = commonPolylineCoords[0]; // 初始位置
animatedAnnotation.title = self.raderMapDateModel.typhoon[0].nameCn;
self.typhoon_AnimatedAnnotation = animatedAnnotation;
[self.mapView addAnnotation:self.typhoon_AnimatedAnnotation];
[self.mapView selectAnnotation:self.typhoon_AnimatedAnnotation animated:YES]; // 选中状态(显示标注view)
} else {
self.typhoon_AnimatedAnnotation.coordinate = commonPolylineCoords[0]; // 初始位置
}
// 给self.typhoon_AnimatedAnnotation添加一个移动动画(沿着 经纬度commonPolylineCoords)
[self.typhoon_AnimatedAnnotation addMoveAnimationWithKeyCoordinates:commonPolylineCoords count:self.raderMapDateModel.typhoon[0].routes.count withDuration:20 withName:@"台风运行轨迹线" completeCallback:^(BOOL isFinished) {
if (isFinished) {
}
}];
}
}
#pragma mark ========>>>>>>>>>> 方法【mapView:viewForAnnotation:】 <<<<<<<<<<<<==========
/// 在 <MAMapViewDelegate>协议的回调函数mapView:viewForAnnotation:中修改 MAAnnotationView 对应的标注图片。
- (MAAnnotationView *)mapView:(MAMapView *)mapView viewForAnnotation:(id <MAAnnotation>)annotation {
///注意:5.1.0后由于定位蓝点增加了平滑移动功能,如果在开启定位的情况先添加annotation,需要在此回调方法中判断annotation是否为MAUserLocation,从而返回正确的View。
if ([annotation isKindOfClass:[MAUserLocation class]]) {
// [self gain_ClickMap_Request_WithLocationCoordinate:self.mapView.userLocation.location.coordinate];
return nil; // 防止,更改用户当前位置的蓝点,为大头钉样式或自定义样式
}
// 台风轨迹线动画:
if (annotation == self.typhoon_AnimatedAnnotation) { // 所有的MAAnimatedAnnotation类(包含用户当前位置的图标)
NSLog(@"😆哈哈哈 ==== self.typhoon_AnimatedAnnotation 类");
MAAnnotationView *annotationView = (MAPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:NSStringFromClass([self.typhoon_AnimatedAnnotation class])];
if (annotationView == nil) {
annotationView = [[MAAnnotationView alloc] initWithAnnotation:self.typhoon_AnimatedAnnotation
reuseIdentifier:NSStringFromClass([self.typhoon_AnimatedAnnotation class])];
// [annotationView setSize:CGSizeMake([UIScreen mainScreen].bounds.size.width/375*47, [UIScreen mainScreen].bounds.size.width/375*25)];
}
// annotationView.backgroundColor = [UIColor redColor];
// UIImageView的 自定义动画
annotationView.imageView.size = CGSizeMake([UIScreen mainScreen].bounds.size.width/375*20, [UIScreen mainScreen].bounds.size.width/375*20);
annotationView.imageView.center = annotationView.centerOffset;
annotationView.imageView.backgroundColor = UIColor.clearColor;
annotationView.imageView.animationImages = [self animationImages]; // 获取 Gif 图片列表
annotationView.imageView.animationDuration = 0.3; // 执行一次完整动画所需的时长
annotationView.imageView.animationRepeatCount = 0; // 动画重复次数(0 无限)
[annotationView.imageView startAnimating];
annotationView.calloutOffset = CGPointMake(0, -15);
// annotationView.annotation = self.typhoon_AnimatedAnnotation;
annotationView.canShowCallout = YES;
annotationView.draggable = NO;
// annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
// [annotationView setSelected:YES animated:NO];
return annotationView;
}
/** 自定义气泡标注 */
if (annotation == self.locatinWeather_AnimatedAnnotation) {
NSLog(@"😆哈哈哈 ==== 自定义self.locatinWeather_AnimatedAnnotation 类");
GWRaderMap_CustomAnnotationView *costomAnnotationView = (GWRaderMap_CustomAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:NSStringFromClass([GWRaderMap_CustomAnnotationView class])];
if (costomAnnotationView == nil) {
costomAnnotationView = [[GWRaderMap_CustomAnnotationView alloc] initWithAnnotation:self.locatinWeather_AnimatedAnnotation
reuseIdentifier:NSStringFromClass([GWRaderMap_CustomAnnotationView class])];
}
if (self.tempBut.selected && self.itemCell < self.locationWeatherModel.temp.count) {
GWHomeRaderMap_TempLocationWeatherModel *model = self.locationWeatherModel.temp[self.itemCell];
costomAnnotationView.title = model.city;
costomAnnotationView.imageUrl = model.icon;
costomAnnotationView.detailContent = [NSString stringWithFormat:@"%ld°", model.temp];
costomAnnotationView.time = model.timeStr;
costomAnnotationView.weatherCode = model.weatherCode;
} else if (self.rainBut.selected && self.itemCell < self.locationWeatherModel.precip.count) {
GWHomeRaderMap_PrecipLocationWeatherModel *model = self.locationWeatherModel.precip[self.itemCell];
costomAnnotationView.title = model.city;
costomAnnotationView.imageUrl = model.icon;
costomAnnotationView.detailContent = model.weather;
costomAnnotationView.time = model.timeStr;
costomAnnotationView.weatherCode = model.weatherCode;
}
costomAnnotationView.calloutOffset = CGPointMake(8, -10);
costomAnnotationView.centerOffset = CGPointMake(0, -10);
// 点击自定义按钮,隐藏整个“气泡” 和 “大头针”:
costomAnnotationView.hideCustomCalloutViewBlock = ^(BOOL is_hideCustomView) {
if (self.locatinWeather_AnimatedAnnotation != nil) {
[self.mapView removeAnnotation:self.locatinWeather_AnimatedAnnotation]; // 删除 【自定义气泡】Annotation
self.locatinWeather_AnimatedAnnotation = nil;
}
// [self.mapView selectAnnotation:self.locatinWeather_AnimatedAnnotation animated:YES]; // 选中状态(显示标注view)
};
// @property (nonatomic, copy) NSString *title; // 地址
// @property (nonatomic, copy) NSString *imageUrl; // 天气图片url
// @property (nonatomic, copy) NSString *detailContent; // 气温时:显示 温度,降水时:显示 天气描述
// @property (nonatomic, copy) NSString *time; // 时间
//
// @property (nonatomic, assign) BOOL is_ShowButton;// YES 显示,NO 隐藏
return costomAnnotationView;
} else if ([annotation isKindOfClass:[MAPointAnnotation class]]) { //其他大头针
NSLog(@"😆哈哈哈 ==== MAPointAnnotation 类");
}
return nil;
}
// 多张图片循环播放,实现gif图的效果(这里是6张)
- (NSArray *)animationImages {
NSMutableArray *images = [NSMutableArray arrayWithCapacity:6];
for (int i = 0; i < 6; i++) {
NSString *imageStr = [NSString stringWithFormat:@"hfsdk_icon_typhoon_0%d.png",i + 1];
UIImage *image = [UIImage imageNamed:imageStr];
[images addObject:image];
}
return images;
}
- (void)mapView:(MAMapView *)mapView annotationView:(MAAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
NSLog(@"👌👌哈哈哈 ==== 方法:calloutAccessoryControlTapped");
}
/**
* @brief 标注view的calloutview整体点击时,触发该回调。只有使用默认calloutview时才生效。
* @param mapView 地图的view
* @param view calloutView所属的annotationView
*/
- (void)mapView:(MAMapView *)mapView didAnnotationViewCalloutTapped:(MAAnnotationView *)view {
NSLog(@"👌👌哈哈哈 ==== 使用默认calloutview,==== 方法:didAnnotationViewCalloutTapped");
}
/**
* @brief 标注view被点击时,触发该回调。(since 5.7.0)
* @param mapView 地图的view
* @param view annotationView
*/
- (void)mapView:(MAMapView *)mapView didAnnotationViewTapped:(MAAnnotationView *)view {
// 点击用户当前位置MAUserLocationView时、或显示标注的气泡的当前位置时,有反应
NSLog(@"👌👌哈哈哈 ==== 方法:didAnnotationViewTapped");
// if ([view isMemberOfClass:[MAUserLocationView class]]) {
// }
if (![view isMemberOfClass:[GWRaderMap_CustomAnnotationView class]]) {
if (self.locatinWeather_AnimatedAnnotation != nil) {
[self.mapView removeAnnotation:self.locatinWeather_AnimatedAnnotation]; // 删除 【自定义气泡】Annotation
self.locatinWeather_AnimatedAnnotation = nil;
}
// self.mapView.showsUserLocation = NO; // 隐藏用户当前位置的小圆点
NSLog(@"点击的是 当前小圆点 view ====>>>>>> %@", view);
[self gain_ClickMap_Request_WithLocationCoordinate:self.mapView.userLocation.location.coordinate];
} else {
NSLog(@"点击的是 自定义的view ====>>>>>> %@", view);
}
}
#pragma mark ******** 5、 网络请求:【点击地图 ,显示自定义view,显示 该坐标天气信息】 ********
- (void)gain_ClickMap_Request_WithLocationCoordinate:(CLLocationCoordinate2D)coordinate {
self.locationWeatherModel = [GWHomeRaderMap_LocationWeatherModel new];
NSDictionary *params = @{
@"longitude":@(coordinate.longitude),
@"latitude":@(coordinate.latitude)
};
[BRNetworkHepler getWithUrl:@"https://www.baidu.com/more/weatherImages" params:params headers:nil success:^(GWHttpBaseResponseModel *responseObject, NSString *message) {
NSInteger code = responseObject.code;
if (code == 200) {
NSDictionary *dataDic = responseObject.data;
GWHomeRaderMap_LocationWeatherModel *locationWeatherModel = [GWHomeRaderMap_LocationWeatherModel modelWithDictionary:dataDic];
locationWeatherModel.longitude = coordinate.longitude;
locationWeatherModel.latitude = coordinate.latitude;
for (int i=0; i < locationWeatherModel.temp.count; i++) {
GWHomeRaderMap_TempLocationWeatherModel *model = locationWeatherModel.temp[i];
locationWeatherModel.temp[i].timeStr = [LCM_Tool TimeStampTransform:model.timestamp andstyle:@"HH:mm"];
}
for (int i=0; i < locationWeatherModel.precip.count; i++) {
GWHomeRaderMap_PrecipLocationWeatherModel *model = locationWeatherModel.precip[i];
locationWeatherModel.precip[i].timeStr = [LCM_Tool TimeStampTransform:model.timestamp andstyle:@"HH:mm"];
}
self.locationWeatherModel = locationWeatherModel;
if (self.locationWeatherModel != nil) {
[self createCustomLocationWeatherView_WithModel:self.locationWeatherModel];
} else {
if (self.locatinWeather_AnimatedAnnotation != nil) {
[self.mapView removeAnnotation:self.locatinWeather_AnimatedAnnotation]; // 删除 【自定义气泡】Annotation
self.locatinWeather_AnimatedAnnotation = nil;
}
}
} else {
// [LCM_AlertViewFactory showToastWithMessage:responseObject.msg];
if (self.locatinWeather_AnimatedAnnotation != nil) {
[self.mapView removeAnnotation:self.locatinWeather_AnimatedAnnotation]; // 删除 【自定义气泡】Annotation
self.locatinWeather_AnimatedAnnotation = nil;
}
}
} failure:^(NSError *error, NSString *message) {
NSLog(@"error =====>>>> %@", error);
NSLog(@"message ---->> %@", message);
}];
}
/** 添加自定义气泡:背景、地址、天气图片、天气描述、时间 */
- (void)createCustomLocationWeatherView_WithModel:(GWHomeRaderMap_LocationWeatherModel *)locationWeatherModel {
// GWRaderMap_CustomAnnotationView
/** 高德地图: 点击地图,弹出自定义天气view */
if (self.locatinWeather_AnimatedAnnotation != nil) {
[self.mapView removeAnnotation:self.locatinWeather_AnimatedAnnotation]; // 删除 【自定义气泡】Annotation
self.locatinWeather_AnimatedAnnotation = nil;
}
if (self.locatinWeather_AnimatedAnnotation == nil) {
MAAnimatedAnnotation *locatinWeather_AnimatedAnnotation = [[MAAnimatedAnnotation alloc] init];
locatinWeather_AnimatedAnnotation.coordinate = CLLocationCoordinate2DMake(locationWeatherModel.latitude, locationWeatherModel.longitude); // 初始位置
// locatinWeather_AnimatedAnnotation.title = self.raderMapDateModel.typhoon[0].nameCn;
self.locatinWeather_AnimatedAnnotation = locatinWeather_AnimatedAnnotation;
[self.mapView addAnnotation:self.locatinWeather_AnimatedAnnotation];
[self.mapView selectAnnotation:self.locatinWeather_AnimatedAnnotation animated:YES]; // 选中状态(显示标注view)
[self.mapView setCenterCoordinate:locatinWeather_AnimatedAnnotation.coordinate animated:YES];
} else {
self.locatinWeather_AnimatedAnnotation.coordinate = CLLocationCoordinate2DMake(locationWeatherModel.latitude, locationWeatherModel.longitude); // 初始位置
}
}
#pragma mark ------------ 【设置UI】
- (void)setupUI {
_tempBut = [UIButton buttonWithType:UIButtonTypeCustom];
[_tempBut setBackgroundImage:[UIImage imageNamed:@"raderMap_气温_select_icon"] forState:UIControlStateSelected];
[_tempBut setBackgroundImage:[UIImage imageNamed:@"raderMap_气温_noSelect_icon"] forState:UIControlStateNormal];
_tempBut.adjustsImageWhenHighlighted = NO; // 下面的背景图片可以保证图片不变灰
[self.navigationBar addSubview:self.tempBut];
[self.tempBut makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.navigationBar);
make.left.mas_equalTo(self.navigationBar.mas_left).offset([UIScreen mainScreen].bounds.size.width/375*15);
make.width.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*93);
make.height.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*44);
}];
[self.tempBut addTarget:self action:@selector(clickRaderMapBotton:) forControlEvents:UIControlEventTouchUpInside];
_rainBut = [UIButton buttonWithType:UIButtonTypeCustom];
[_rainBut setBackgroundImage:[UIImage imageNamed:@"raderMap_降水_select_icon"] forState:UIControlStateSelected];
[_rainBut setBackgroundImage:[UIImage imageNamed:@"raderMap_降水_noSelect_icon"] forState:UIControlStateNormal];
_rainBut.adjustsImageWhenHighlighted = NO; // 下面的背景图片可以保证图片不变灰
[self.navigationBar addSubview:self.rainBut];
[self.rainBut makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.navigationBar);
make.centerX.equalTo(self.navigationBar);
make.width.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*93);
make.height.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*44);
}];
[self.rainBut addTarget:self action:@selector(clickRaderMapBotton:) forControlEvents:UIControlEventTouchUpInside];
_typhoonBut = [UIButton buttonWithType:UIButtonTypeCustom];
[_typhoonBut setBackgroundImage:[UIImage imageNamed:@"raderMap_台风_select_icon"] forState:UIControlStateSelected];
[_typhoonBut setBackgroundImage:[UIImage imageNamed:@"raderMap_台风_noSelect_icon"] forState:UIControlStateNormal];
_typhoonBut.adjustsImageWhenHighlighted = NO; // 下面的背景图片可以保证图片不变灰
[self.navigationBar addSubview:self.typhoonBut];
[self.typhoonBut makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.navigationBar);
make.right.mas_equalTo(self.navigationBar.mas_right).offset(-[UIScreen mainScreen].bounds.size.width/375*15);
make.width.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*93);
make.height.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*44);
}];
[self.typhoonBut addTarget:self action:@selector(clickRaderMapBotton:) forControlEvents:UIControlEventTouchUpInside];
self.tempBut.selected = YES;
self.rainBut.selected = NO;
self.typhoonBut.selected = NO;
}
/** 布局:(气温+降水)自定义功能 */
- (void)setupTempAndRainOtherFunction {
/// 气候等级
_climateRank_BackView = [[UIView alloc] init];
self.climateRank_BackView.backgroundColor = RGBA(248, 246, 242, 1);
self.climateRank_BackView.layer.cornerRadius = [UIScreen mainScreen].bounds.size.width/375*26/2;
self.climateRank_BackView.layer.shadowColor = RGBA(0, 0, 0, 0.12).CGColor;
self.climateRank_BackView.layer.shadowOffset = CGSizeMake(0, 0);
self.climateRank_BackView.layer.shadowRadius = [UIScreen mainScreen].bounds.size.width/375*8;
self.climateRank_BackView.layer.shadowOpacity = 1;
[self.view addSubview:self.climateRank_BackView];
[self.climateRank_BackView makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view.mas_top).offset(k_Height_StatusBar+k_Height_NavContentBar + [UIScreen mainScreen].bounds.size.width/375*14);
make.left.mas_equalTo(self.view.mas_left).offset([UIScreen mainScreen].bounds.size.width/375*20);
make.width.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*173);
make.height.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*26);
}];
_climateRank_Img = [[UIImageView alloc] init];
self.climateRank_Img.image = [UIImage imageNamed:@"raderMap_TempRankColor_icon"];
[self.climateRank_BackView addSubview:self.climateRank_Img];
[self.climateRank_Img makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self.climateRank_BackView);
make.width.mas_equalTo([UIScreen mainScreen].bounds.size.width/
375*115);
make.height.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*6);
}];
_climateRank_minTipsL = [[UILabel alloc] init];
_climateRank_minTipsL.text = @"-40°";
_climateRank_minTipsL.textColor = RGBA(0, 0, 0, 0.5);
_climateRank_minTipsL.textAlignment = NSTextAlignmentLeft;
_climateRank_minTipsL.font = FontSourceHanSerifCN_Medium([UIScreen mainScreen].bounds.size.width/375*10);
[self.climateRank_BackView addSubview:self.climateRank_minTipsL];
[self.climateRank_minTipsL makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.climateRank_BackView);
make.left.mas_equalTo(self.climateRank_BackView.mas_left).offset([UIScreen mainScreen].bounds.size.width/375*8);
}];
_climateRank_maxTipsL = [[UILabel alloc] init];
_climateRank_maxTipsL.text = @"40°";
_climateRank_maxTipsL.textColor = RGBA(0, 0, 0, 0.5);
_climateRank_maxTipsL.textAlignment = NSTextAlignmentRight;
_climateRank_maxTipsL.font = FontSourceHanSerifCN_Medium([UIScreen mainScreen].bounds.size.width/375*10);
[self.climateRank_BackView addSubview:self.climateRank_maxTipsL];
[self.climateRank_maxTipsL makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.climateRank_BackView);
make.right.mas_equalTo(self.climateRank_BackView.mas_right).offset(-[UIScreen mainScreen].bounds.size.width/375*8);
}];
_currentPositionBut = [UIButton buttonWithType:UIButtonTypeCustom];
[_currentPositionBut setBackgroundImage:[UIImage imageNamed:@"raderMap_currentLocation_icon"] forState:UIControlStateNormal];
_currentPositionBut.adjustsImageWhenHighlighted = NO; // 点击时图片 不变灰色
[self.currentPositionBut addTarget:self action:@selector(click_backCurrentPositionAction) forControlEvents:UIControlEventTouchUpInside];
self.currentPositionBut.layer.masksToBounds = YES;
self.currentPositionBut.layer.cornerRadius = [UIScreen mainScreen].bounds.size.width/375*44/2;
[self.view addSubview:self.currentPositionBut];
[self.currentPositionBut makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.view.mas_bottom).offset(-(k_Height_TabBar + [UIScreen mainScreen].bounds.size.width/375*19));
make.right.mas_equalTo(self.view.mas_right).offset(-[UIScreen mainScreen].bounds.size.width/375*12);
make.width.height.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*44);
}];
/** 播放/暂停:气候变化,(可以 手动滑动 刻度) */
_progress_BackView = [[UIView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/375*15, [UIScreen mainScreen].bounds.size.height - k_Height_TabBar - [UIScreen mainScreen].bounds.size.width/375*(19+44), [UIScreen mainScreen].bounds.size.width/375*290, [UIScreen mainScreen].bounds.size.width/375*44)];
_progress_BackView.backgroundColor = RGBA(248, 246, 242, 1);
self.progress_BackView.layer.cornerRadius = [UIScreen mainScreen].bounds.size.width/375*44/2;
self.progress_BackView.layer.shadowColor = RGBA(0, 0, 0, 0.12).CGColor;
self.progress_BackView.layer.shadowOffset = CGSizeMake(0, 0);
self.progress_BackView.layer.shadowRadius = [UIScreen mainScreen].bounds.size.width/375*4;
self.progress_BackView.layer.shadowOpacity = 1;
[self.view addSubview:self.progress_BackView];
/** 时间刻度的父view ,宽度:(290 - 40 -25) = 225*/
_progress_lineBackView = [[UIView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/375*40, 0, [UIScreen mainScreen].bounds.size.width/375*(225), [UIScreen mainScreen].bounds.size.width/375*44)];
self.progress_lineBackView.backgroundColor = UIColor.clearColor;//RGBA(212, 229, 225, 1);
[self.progress_BackView addSubview:self.progress_lineBackView];
_progress_beginTimeL = [[UILabel alloc] init];
_progress_beginTimeL.text = @" ";
_progress_beginTimeL.textColor = RGBA(153, 153, 153, 1);
_progress_beginTimeL.textAlignment = NSTextAlignmentLeft;
_progress_beginTimeL.font = FontSourceHanSerifCN_Medium([UIScreen mainScreen].bounds.size.width/375*12);
[self.progress_BackView addSubview:self.progress_beginTimeL];
[self.progress_beginTimeL makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.progress_BackView.mas_centerY).offset([UIScreen mainScreen].bounds.size.width/375*11);
make.left.mas_equalTo(self.progress_BackView.mas_left).offset([UIScreen mainScreen].bounds.size.width/375*40);
}];
_progress_endTimeL = [[UILabel alloc] init];
_progress_endTimeL.text = @" ";
_progress_endTimeL.textColor = RGBA(153, 153, 153, 1);
_progress_endTimeL.textAlignment = NSTextAlignmentRight;
_progress_endTimeL.font = FontSourceHanSerifCN_Medium([UIScreen mainScreen].bounds.size.width/375*12);
[self.progress_BackView addSubview:self.progress_endTimeL];
[self.progress_endTimeL makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.progress_BackView.mas_centerY).offset([UIScreen mainScreen].bounds.size.width/375*11);
make.right.mas_equalTo(self.progress_BackView.mas_right).offset(-[UIScreen mainScreen].bounds.size.width/375*25);
}];
_progress_currentLineView = [[UIView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/375*(40-1), 0, [UIScreen mainScreen].bounds.size.width/375*2, [UIScreen mainScreen].bounds.size.width/375*22)];
self.progress_currentLineView.backgroundColor = RGBA(193, 162, 122, 1);
[self.progress_BackView addSubview:self.progress_currentLineView];
// Touch触摸 view视图
_progress_view = [[UIView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/375*0, 0, [UIScreen mainScreen].bounds.size.width/375*290, [UIScreen mainScreen].bounds.size.width/375*44)];
self.progress_view.userInteractionEnabled = YES;
self.progress_view.backgroundColor = RGBA(88, 255, 88, 0);
[self.progress_BackView addSubview:self.progress_view];
// 开关:播放、暂停
_progress_playBut = [UIButton buttonWithType:UIButtonTypeCustom];
[_progress_playBut setBackgroundImage:[UIImage imageNamed:@"raderMap_playChange_icon"] forState:UIControlStateNormal];
[_progress_playBut setBackgroundImage:[UIImage imageNamed:@"raderMap_pauseChange_icon"] forState:UIControlStateSelected];
_progress_playBut.adjustsImageWhenHighlighted = NO; // 点击时图片 不变灰色
[self.progress_BackView addSubview:self.progress_playBut];
[self.progress_playBut makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.progress_BackView);
make.left.mas_equalTo(self.progress_BackView.mas_left).offset([UIScreen mainScreen].bounds.size.width/375*10);
make.width.height.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*24);
}];
[self.progress_playBut addTarget:self action:@selector(click_playClimateChangeAction) forControlEvents:UIControlEventTouchUpInside];
_progress_tipsL = [[UILabel alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/375*(15+40 - 30), [UIScreen mainScreen].bounds.size.height - k_Height_TabBar - [UIScreen mainScreen].bounds.size.width/375*(19+44+22), [UIScreen mainScreen].bounds.size.width/375*60, [UIScreen mainScreen].bounds.size.width/375*22)];
_progress_tipsL.backgroundColor = RGBA(193, 162, 122, 1);
_progress_tipsL.textColor = UIColor.whiteColor;
_progress_tipsL.textAlignment = NSTextAlignmentCenter;
_progress_tipsL.font = FontSourceHanSerifCN_Medium([UIScreen mainScreen].bounds.size.width/375*9);
_progress_tipsL.layer.masksToBounds = YES;
_progress_tipsL.layer.cornerRadius = [UIScreen mainScreen].bounds.size.width/375*22/2;
[self.view addSubview:self.progress_tipsL];
self.climateRank_minTipsL.text = @"-40°";
self.climateRank_maxTipsL.text = @"40°";
self.progress_BackView.hidden = YES;
self.progress_tipsL.hidden = YES;
}
/** 布局:(台风)弹窗 */
- (void)setupTyphoonOtherFunction {
/** 台风:经度、纬度、风力、最大风速、中心气压、距离本地 */
_typhoon_BackView = [[UIView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width/375*20, [UIScreen mainScreen].bounds.size.width/375*14 + k_Height_StatusBar+k_Height_NavContentBar, [UIScreen mainScreen].bounds.size.width/375*150, [UIScreen mainScreen].bounds.size.width/375*110)];
_typhoon_BackView.backgroundColor = RGBA(248, 246, 242, 1);
self.typhoon_BackView.layer.cornerRadius = [UIScreen mainScreen].bounds.size.width/375*8;
self.typhoon_BackView.layer.shadowColor = RGBA(0, 0, 0, 0.12).CGColor;
self.typhoon_BackView.layer.shadowOffset = CGSizeMake(0, 0);
self.typhoon_BackView.layer.shadowRadius = [UIScreen mainScreen].bounds.size.width/375*8;
self.typhoon_BackView.layer.shadowOpacity = 1;
[self.view addSubview:self.typhoon_BackView];
_typhoon_longitudeTipsL = [[UILabel alloc] init];
_typhoon_longitudeTipsL.text = @"经度";
_typhoon_longitudeTipsL.textColor = RGBA(0, 0, 0, 0.45);
_typhoon_longitudeTipsL.textAlignment = NSTextAlignmentLeft;
_typhoon_longitudeTipsL.font = FontSourceHanSerifCN_Medium([UIScreen mainScreen].bounds.size.width/375*12);
_typhoon_longitudeTipsL.adjustsFontSizeToFitWidth = YES;
_typhoon_longitudeTipsL.minimumScaleFactor = 0.5;
[self.typhoon_BackView addSubview:self.typhoon_longitudeTipsL];
[self.typhoon_longitudeTipsL makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.typhoon_BackView.mas_top).offset([UIScreen mainScreen].bounds.size.width/375*11);
make.left.mas_equalTo(self.typhoon_BackView.mas_left).offset([UIScreen mainScreen].bounds.size.width/375*12);
make.width.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*32);
}];
_typhoon_longitudeL = [[UILabel alloc] init];
_typhoon_longitudeL.textColor = RGBA(0, 0, 0, 9);
_typhoon_longitudeL.textAlignment = NSTextAlignmentRight;
_typhoon_longitudeL.font = FontSourceHanSerifCN_Medium([UIScreen mainScreen].bounds.size.width/375*12);
_typhoon_longitudeL.adjustsFontSizeToFitWidth = YES;
_typhoon_longitudeL.minimumScaleFactor = 0.5;
[self.typhoon_BackView addSubview:self.typhoon_longitudeL];
[self.typhoon_longitudeL makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.typhoon_longitudeTipsL);
make.left.mas_equalTo(self.typhoon_longitudeTipsL.mas_right).offset([UIScreen mainScreen].bounds.size.width/375*5);
make.right.mas_equalTo(self.typhoon_BackView.mas_right).offset(-[UIScreen mainScreen].bounds.size.width/375*14);
}];
_typhoon_latitudeTipsL = [[UILabel alloc] init];
_typhoon_latitudeTipsL.text = @"纬度";
_typhoon_latitudeTipsL.textColor = RGBA(0, 0, 0, 0.45);
_typhoon_latitudeTipsL.textAlignment = NSTextAlignmentLeft;
_typhoon_latitudeTipsL.font = FontSourceHanSerifCN_Medium([UIScreen mainScreen].bounds.size.width/375*12);
_typhoon_latitudeTipsL.adjustsFontSizeToFitWidth = YES;
_typhoon_latitudeTipsL.minimumScaleFactor = 0.5;
[self.typhoon_BackView addSubview:self.typhoon_latitudeTipsL];
[self.typhoon_latitudeTipsL makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.typhoon_longitudeTipsL.mas_bottom).offset([UIScreen mainScreen].bounds.size.width/375*6);
make.left.mas_equalTo(self.typhoon_BackView.mas_left).offset([UIScreen mainScreen].bounds.size.width/375*12);
make.width.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*32);
}];
_typhoon_latitudeL = [[UILabel alloc] init];
_typhoon_latitudeL.textColor = RGBA(0, 0, 0, 9);
_typhoon_latitudeL.textAlignment = NSTextAlignmentRight;
_typhoon_latitudeL.font = FontSourceHanSerifCN_Medium([UIScreen mainScreen].bounds.size.width/375*12);
_typhoon_latitudeL.adjustsFontSizeToFitWidth = YES;
_typhoon_latitudeL.minimumScaleFactor = 0.5;
[self.typhoon_BackView addSubview:self.typhoon_latitudeL];
[self.typhoon_latitudeL makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.typhoon_latitudeTipsL);
make.left.mas_equalTo(self.typhoon_latitudeTipsL.mas_right).offset([UIScreen mainScreen].bounds.size.width/375*5);
make.right.mas_equalTo(self.typhoon_BackView.mas_right).offset(-[UIScreen mainScreen].bounds.size.width/375*14);
}];
_typhoon_maxWindSpeedTipsL = [[UILabel alloc] init];
_typhoon_maxWindSpeedTipsL.text = @"最大风速";
_typhoon_maxWindSpeedTipsL.textColor = RGBA(0, 0, 0, 0.45);
_typhoon_maxWindSpeedTipsL.textAlignment = NSTextAlignmentLeft;
_typhoon_maxWindSpeedTipsL.font = FontSourceHanSerifCN_Medium([UIScreen mainScreen].bounds.size.width/375*12);
_typhoon_maxWindSpeedTipsL.adjustsFontSizeToFitWidth = YES;
_typhoon_maxWindSpeedTipsL.minimumScaleFactor = 0.5;
[self.typhoon_BackView addSubview:self.typhoon_maxWindSpeedTipsL];
[self.typhoon_maxWindSpeedTipsL makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.typhoon_latitudeTipsL.mas_bottom).offset([UIScreen mainScreen].bounds.size.width/375*6);
make.left.mas_equalTo(self.typhoon_BackView.mas_left).offset([UIScreen mainScreen].bounds.size.width/375*12);
make.width.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*55);
}];
_typhoon_maxWindSpeedL = [[UILabel alloc] init];
_typhoon_maxWindSpeedL.textColor = RGBA(0, 0, 0, 9);
_typhoon_maxWindSpeedL.textAlignment = NSTextAlignmentRight;
_typhoon_maxWindSpeedL.font = FontSourceHanSerifCN_Medium([UIScreen mainScreen].bounds.size.width/375*12);
_typhoon_maxWindSpeedL.adjustsFontSizeToFitWidth = YES;
_typhoon_maxWindSpeedL.minimumScaleFactor = 0.5;
[self.typhoon_BackView addSubview:self.typhoon_maxWindSpeedL];
[self.typhoon_maxWindSpeedL makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.typhoon_maxWindSpeedTipsL);
make.left.mas_equalTo(self.typhoon_maxWindSpeedTipsL.mas_right).offset([UIScreen mainScreen].bounds.size.width/375*5);
make.right.mas_equalTo(self.typhoon_BackView.mas_right).offset(-[UIScreen mainScreen].bounds.size.width/375*14);
}];
_typhoon_pressureTipsL = [[UILabel alloc] init];
_typhoon_pressureTipsL.text = @"中心气压";
_typhoon_pressureTipsL.textColor = RGBA(0, 0, 0, 0.45);
_typhoon_pressureTipsL.textAlignment = NSTextAlignmentLeft;
_typhoon_pressureTipsL.font = FontSourceHanSerifCN_Medium([UIScreen mainScreen].bounds.size.width/375*12);
_typhoon_pressureTipsL.adjustsFontSizeToFitWidth = YES;
_typhoon_pressureTipsL.minimumScaleFactor = 0.5;
[self.typhoon_BackView addSubview:self.typhoon_pressureTipsL];
[self.typhoon_pressureTipsL makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.typhoon_maxWindSpeedTipsL.mas_bottom).offset([UIScreen mainScreen].bounds.size.width/375*6);
make.left.mas_equalTo(self.typhoon_BackView.mas_left).offset([UIScreen mainScreen].bounds.size.width/375*12);
make.width.mas_equalTo([UIScreen mainScreen].bounds.size.width/375*55);
}];
_typhoon_pressureL = [[UILabel alloc] init];
_typhoon_pressureL.textColor = RGBA(0, 0, 0, 9);
_typhoon_pressureL.textAlignment = NSTextAlignmentRight;
_typhoon_pressureL.font = FontSourceHanSerifCN_Medium([UIScreen mainScreen].bounds.size.width/375*12);
_typhoon_pressureL.adjustsFontSizeToFitWidth = YES;
_typhoon_pressureL.minimumScaleFactor = 0.5;
[self.typhoon_BackView addSubview:self.typhoon_pressureL];
[self.typhoon_pressureL makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.typhoon_pressureTipsL);
make.left.mas_equalTo(self.typhoon_pressureTipsL.mas_right).offset([UIScreen mainScreen].bounds.size.width/375*5);
make.right.mas_equalTo(self.typhoon_BackView.mas_right).offset(-[UIScreen mainScreen].bounds.size.width/375*14);
}];
_noTyphoon_tipsL = [[UILabel alloc] init];
_noTyphoon_tipsL.text = @"当前无台风";
_noTyphoon_tipsL.textColor = RGBA(0, 0, 0, 9);
_noTyphoon_tipsL.textAlignment = NSTextAlignmentCenter;
_noTyphoon_tipsL.font = FontSourceHanSerifCN_Medium([UIScreen mainScreen].bounds.size.width/375*12);
_noTyphoon_tipsL.adjustsFontSizeToFitWidth = YES;
_noTyphoon_tipsL.minimumScaleFactor = 0.5;
[self.typhoon_BackView addSubview:self.noTyphoon_tipsL];
[self.noTyphoon_tipsL makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.typhoon_BackView);
make.left.mas_equalTo(self.typhoon_BackView.mas_left).offset([UIScreen mainScreen].bounds.size.width/375*5);
make.right.mas_equalTo(self.typhoon_BackView.mas_right).offset(-[UIScreen mainScreen].bounds.size.width/375*5);
}];
// 默认,无数据(无台风时),小提示框,如果有数据(有台风)显示大提示框
self.typhoon_BackView.frame = CGRectMake([UIScreen mainScreen].bounds.size.width/375*20, [UIScreen mainScreen].bounds.size.width/375*14 + k_Height_StatusBar+k_Height_NavContentBar, [UIScreen mainScreen].bounds.size.width/375*96, [UIScreen mainScreen].bounds.size.width/375*28);
self.typhoon_BackView.hidden = YES;
}
网友评论