Commit 641f5b24706b1ed80575f1970546d3a813d1a1d6
1 parent
a597ca52
头部背景图渐变设计
Showing
1 changed file
with
58 additions
and
0 deletions
CNLiveVideoClassifyKit/Classes/ClassifyCategory/Controller/CNLiveClassifySegmentController.m
| ... | ... | @@ -26,6 +26,8 @@ static const CGFloat animationHeight = 15; |
| 26 | 26 | @property (nonatomic, strong) CNCustomChannelListView *customChannelsV;//频道控制器窗口 |
| 27 | 27 | @property (nonatomic, strong) UIView *fuzzyView;//游客登录弹框 |
| 28 | 28 | @property (nonatomic, strong) UIImageView *topBgImg; //头部图片 |
| 29 | +@property (nonatomic, strong) UIImageView *indicatorImg;// 渐变图片 | |
| 30 | + | |
| 29 | 31 | @property (nonatomic, assign) CGFloat topBgImgHeight;//头部图片高度 |
| 30 | 32 | |
| 31 | 33 | @property (nonatomic, strong) NSString * currentAtatusColor; |
| ... | ... | @@ -67,6 +69,8 @@ static const CGFloat animationHeight = 15; |
| 67 | 69 | self.isLoginIndex = -1; |
| 68 | 70 | [self.view addSubview:self.topBgImg]; |
| 69 | 71 | [self.view sendSubviewToBack:self.topBgImg]; |
| 72 | + [self.view addSubview:self.indicatorImg]; | |
| 73 | + [self.view insertSubview:self.indicatorImg belowSubview:self.topBgImg]; | |
| 70 | 74 | [self dataDivideIntoNormalAndOtherWithFirst:YES]; |
| 71 | 75 | [self handleDateWithChannelsArray]; |
| 72 | 76 | |
| ... | ... | @@ -406,6 +410,8 @@ static const CGFloat animationHeight = 15; |
| 406 | 410 | }]; |
| 407 | 411 | NSString *backgroundColor = [self.bgColors wjj_safetyObjectAtIndex:index]; |
| 408 | 412 | self.topBgImg.backgroundColor = CNLiveColorWithHexString(backgroundColor); |
| 413 | + self.indicatorImg.alpha = 0; | |
| 414 | + self.topBgImg.alpha = 1; | |
| 409 | 415 | self.myCategoryView.titleColor = self.textColors[index]; |
| 410 | 416 | self.myCategoryView.titleSelectedColor = self.textColorSeleteds[index]; |
| 411 | 417 | if (!self.currentAtatusColor || ![self.currentAtatusColor isEqualToString:self.statusBarColors[index]] ) { |
| ... | ... | @@ -416,7 +422,38 @@ static const CGFloat animationHeight = 15; |
| 416 | 422 | //配置选中状态显示图片,未选中展示文字 |
| 417 | 423 | - (void)configCategoryViewWithType:(JXCategoryTitleImageType)imageType selectIndex:(NSInteger)index unselectIndex:(NSInteger)unIndex |
| 418 | 424 | { |
| 425 | + NSString *backgroundImage = [self.bgImages wjj_safetyObjectAtIndex:index]; | |
| 426 | + weakself | |
| 427 | + [self.topBgImg sd_setImageWithURL:[NSURL URLWithString:backgroundImage] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { | |
| 428 | + if (image) { | |
| 429 | + weakSelf.topBgImgHeight = KScreenWidth*image.size.height/image.size.width; | |
| 430 | + } else { | |
| 431 | + weakSelf.topBgImgHeight = kStatusHeight+100; | |
| 432 | + } | |
| 433 | + if (weakSelf.topBgImgHeight<kStatusHeight+100) { | |
| 434 | + weakSelf.topBgImgHeight = kStatusHeight+100; | |
| 435 | + } | |
| 436 | + weakSelf.topBgImg.height = weakSelf.topBgImgHeight; | |
| 437 | + weakSelf.topBgImg.bottom = kStatusHeight+100; | |
| 438 | + }]; | |
| 439 | + NSString *backgroundColor = [self.bgColors wjj_safetyObjectAtIndex:index]; | |
| 440 | + self.topBgImg.backgroundColor = CNLiveColorWithHexString(backgroundColor); | |
| 419 | 441 | |
| 442 | + NSString *unBackgroundImage = [self.bgImages wjj_safetyObjectAtIndex:unIndex]; | |
| 443 | + [self.indicatorImg sd_setImageWithURL:[NSURL URLWithString:unBackgroundImage] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { | |
| 444 | + if (image) { | |
| 445 | + weakSelf.topBgImgHeight = KScreenWidth*image.size.height/image.size.width; | |
| 446 | + } else { | |
| 447 | + weakSelf.topBgImgHeight = kStatusHeight+100; | |
| 448 | + } | |
| 449 | + if (weakSelf.topBgImgHeight<kStatusHeight+100) { | |
| 450 | + weakSelf.topBgImgHeight = kStatusHeight+100; | |
| 451 | + } | |
| 452 | + weakSelf.indicatorImg.height = weakSelf.topBgImgHeight; | |
| 453 | + weakSelf.indicatorImg.bottom = kStatusHeight+100; | |
| 454 | + }]; | |
| 455 | + NSString *unBackgroundColor = [self.bgColors wjj_safetyObjectAtIndex:unIndex]; | |
| 456 | + self.indicatorImg.backgroundColor = CNLiveColorWithHexString(unBackgroundColor); | |
| 420 | 457 | NSMutableArray *types = [NSMutableArray array]; |
| 421 | 458 | for (int i = 0; i < self.titles.count; i ++) { |
| 422 | 459 | if (i == index || i == unIndex) { |
| ... | ... | @@ -860,6 +897,18 @@ static const CGFloat animationHeight = 15; |
| 860 | 897 | } |
| 861 | 898 | // [MobClick event:@"channel_click_top"]; |
| 862 | 899 | } |
| 900 | +- (void)categoryView:(JXCategoryBaseView *)categoryView scrollingFromLeftIndex:(NSInteger)leftIndex toRightIndex:(NSInteger)rightIndex ratio:(CGFloat)ratio{ | |
| 901 | + | |
| 902 | + if (self.ld_currentIndex == leftIndex) { | |
| 903 | + [self configCategoryViewWithType:JXCategoryTitleImageType_OnlyImage selectIndex:leftIndex unselectIndex:rightIndex]; | |
| 904 | + self.topBgImg.alpha = 1 - ratio; | |
| 905 | + self.indicatorImg.alpha = ratio; | |
| 906 | + }else{ | |
| 907 | + [self configCategoryViewWithType:JXCategoryTitleImageType_OnlyImage selectIndex:rightIndex unselectIndex:leftIndex]; | |
| 908 | + self.topBgImg.alpha = ratio; | |
| 909 | + self.indicatorImg.alpha = 1 - ratio; | |
| 910 | + } | |
| 911 | +} | |
| 863 | 912 | #pragma mark - Public |
| 864 | 913 | -(JXCategoryBaseView *)preferredCategoryView |
| 865 | 914 | { |
| ... | ... | @@ -881,6 +930,15 @@ static const CGFloat animationHeight = 15; |
| 881 | 930 | } |
| 882 | 931 | return _topBgImg; |
| 883 | 932 | } |
| 933 | +- (UIImageView *)indicatorImg | |
| 934 | +{ | |
| 935 | + if (!_indicatorImg) { | |
| 936 | + _indicatorImg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, self.topBgImgHeight)]; | |
| 937 | + _indicatorImg.contentMode = UIViewContentModeScaleAspectFill; | |
| 938 | + _indicatorImg.alpha = 0; | |
| 939 | + } | |
| 940 | + return _indicatorImg; | |
| 941 | +} | |
| 884 | 942 | |
| 885 | 943 | - (UIButton *)customChannelsBtn { |
| 886 | 944 | if (!_customChannelsBtn) { | ... | ... |