你点进去肯定会喜欢,所以请不要吝啬你的star,点击打开链接,去下载吧
GitHub:
https://github.com/targetcloud/baisibudejie
运行效果
本DEMO高仿最新版百思不得姐(4.5.6),运用了以下第三方框架
DACircularProgress
FLAnimatedImage
pop
另外自己定义了一个导航条控件TGSegment,自己的导航条segment与UINavigationController的导航条相互融合,效果见GIF图,这是很多流行的APP使用的功能,当向上滚动视图时,自己的导航条与UINavigationController的bar整合在一起,同时融合的导航条(高度在64)变得透明,这也是很多流行APP使用的全屏穿透并有透视效果,如果向下滚动视图时,并达到一定速度(慢慢向下滚动或滑动则不会分离出来),那么segment又从UINavigationController的导航条中分离出来,此时的导航条效果是变高了,高出的部分即segment的高度(两者的相加的高度为:64+segment高度)。
除了上面融合分离透视效果外,作者还加入了在segment的导航条最后的更多功能,点击更多按钮,即会弹出一个控制器,让你选择需要跳转的控制器,这也是很多流行APP使用的功能,如网易新闻等。
本DEMO的数据都用Charles抓取,可能后面的版本的请求数据路径地址及参数在将来会有变化,读者可以自行修改,或者告诉作者修改。
在DEMO中,视频、声音、GIF播放均已实现,视频播放不弹出新的控制器进行播放,而是直接在cell上加入播放图层进行播放,GIF及图片缓存是使用自己的缓存实现的,另外评论界面中的语音播放功能也已经加入...
本DEMO中,也已经实现历史穿越功能,点击精华导航条右上角按钮即可穿越到旧版本,即呈现(全部视频声音图片段子)这5个控制器的界面。
使用TGSegment的代码如下(若要显示更多按钮功能,那么//.showMore(YES)去掉这句注释即可,本示例使用的链式编程语法)
@interface TGEssenceNewVC ()
@property (nonatomic, weak) TGSementBarVC *segmentBarVC;
@end
@implementation TGEssenceNewVC
-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;//UIStatusBarStyleDefault;
}
- (TGSementBarVC *)segmentBarVC {
if (!_segmentBarVC) {
TGSementBarVC *vc = [[TGSementBarVC alloc] init];
[self addChildViewController:vc];
_segmentBarVC = vc;
}
return _segmentBarVC;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.automaticallyAdjustsScrollViewInsets = NO;
self.segmentBarVC.segmentBar.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 35);
self.segmentBarVC.view.frame = self.view.bounds;
[self.view addSubview:self.segmentBarVC.view];
NSArray *items = @[@"推荐", @"视频", @"图片", @"段子",@"排行",@"互动区",@"网红",@"社会",@"投票",@"美女",@"冷知识",@"游戏"];
NSMutableArray* childVCs = [NSMutableArray array];
[childVCs addObject:[[TGRecommendedVC alloc] init]];
[childVCs addObject:[[TGVideoPlayVC alloc] init]];
[childVCs addObject:[[TGPictureVC alloc] init]];
[childVCs addObject:[[TGJokesVC alloc] init]];
[childVCs addObject:[[TGRankingVC alloc] init]];
[childVCs addObject:[[TGInteractVC alloc] init]];
[childVCs addObject:[[TGRedNetVC alloc] init]];
[childVCs addObject:[[TGSocietyVC alloc] init]];
[childVCs addObject:[[TGVoteVC alloc] init]];
[childVCs addObject:[[TGBeautyVC alloc] init]];
[childVCs addObject:[[TGColdKnowledgeVC alloc] init]];
[childVCs addObject:[[TGGameVC alloc] init]];
[self.segmentBarVC setupWithItems:items childVCs:childVCs];
[self.segmentBarVC.segmentBar updateViewWithConfig:^(TGSegmentConfig *config) {
config.selectedColor([UIColor lightTextColor])
.normalColor([UIColor lightTextColor])
.selectedFont([UIFont systemFontOfSize:14])
.normalFont([UIFont systemFontOfSize:13])
.indicateExtraW(8)
.indicateH(2)
.indicateColor([UIColor whiteColor])
//.showMore(YES)
.moreCellBGColor([[UIColor grayColor] colorWithAlphaComponent:0.3])
.moreBGColor([UIColor clearColor])
.moreCellFont([UIFont systemFontOfSize:13])
.moreCellTextColor(NavTinColor)
.moreCellMinH(30)
.showMoreBtnlineView(YES)
.moreBtnlineViewColor([UIColor lightTextColor])
.moreBtnTitleFont([UIFont systemFontOfSize:13])
.moreBtnTitleColor([UIColor lightTextColor])
.margin(18)
.barBGColor(NavTinColor)
;
}];
}
@end
TGSegment的各设置参数如下
//
// TGSegmentConfig.h
// TGSegment
//
// Created by targetcloud on 2017/4/18.
// Copyright © 2017年 targetcloud. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface TGSegmentConfig : NSObject
+ (instancetype)defaultConfig;
@property (nonatomic, strong) UIColor *segmentBarBGColor;//标题栏 的背景色
@property (nonatomic, assign) CGFloat segmentBarH;//标题栏的高度
@property (nonatomic, assign) BOOL isShowMore;//是否显示更多
@property (nonatomic, strong) UIColor *indicatorColor;//指示器颜色
@property (nonatomic, assign) CGFloat indicatorH;//指示器高度
@property (nonatomic, assign) CGFloat indicatorExtraW;//指示器左右扩展的宽度
@property (nonatomic, strong) UIColor *segNormalColor;//每个标签的正常颜色
@property (nonatomic, strong) UIColor *segSelectedColor;//每个标签选中的颜色
@property (nonatomic, strong) UIFont *segNormalFont;//每个标签的正常字体
@property (nonatomic, strong) UIFont *segSelectedFont;//每个标签的选中时的字体
@property (nonatomic, assign) CGFloat limitMargin;//标签间最小间距
@property (nonatomic, strong) UIColor *coverViewColor;//遮照颜色
@property (nonatomic, strong) UIColor *showMoreBGColor;//显示更多面板的背景色
@property (nonatomic, strong) UIColor *showMoreCellBGColor;//显示更多面板的每个单元格的背景色
@property (nonatomic, assign) NSInteger showMoreVCRowCount;//显示更多面板的每行个数
@property (nonatomic, assign) CGFloat showMoreCellMinH;//显示更多面板的每个单元格的最小高度
@property (nonatomic, strong) UIColor *showMoreCellTextColor;//显示更多面板的每个单元格的文本颜色
@property (nonatomic, strong) UIFont *showMoreCellFont;//显示更多面板的每个单元格的字体大小
@property (nonatomic, strong) UIColor *showMoreBtnBorderColor;//显示更多按钮的 边框颜色
@property (nonatomic, assign) CGFloat showMoreBtnborderW;//显示更多按钮的 边框宽度
@property (nonatomic, strong) UIColor *showMoreBtnTitleColor;//显示更多按钮的 标题颜色
@property (nonatomic, strong) UIColor *showMoreBtnBGColor;//显示更多按钮的 背景颜色
@property (nonatomic, strong) UIFont *showMoreBtnTitleFont;//显示更多按钮的 标题字体大小
@property (nonatomic, assign) BOOL isShowMoreBtnlineView;//是否显示更多按钮的 分割线
@property (nonatomic, assign) CGFloat showMoreBtnlineViewH;//显示更多按钮的 分割线的高度
@property (nonatomic, strong) UIColor *showMoreBtnlineViewColor;//显示更多按钮的 分割线的颜色
- (TGSegmentConfig *(^)(UIColor *color))barBGColor;
- (TGSegmentConfig *(^)(BOOL isShow))showMore;
- (TGSegmentConfig *(^)(UIColor *color))indicateColor;
- (TGSegmentConfig *(^)(CGFloat height))indicateH;
- (TGSegmentConfig *(^)(CGFloat width)) indicateExtraW;
- (TGSegmentConfig *(^)(UIColor *color))normalColor;
- (TGSegmentConfig *(^)(UIColor *color))selectedColor;
- (TGSegmentConfig *(^)(UIFont *font))normalFont;
- (TGSegmentConfig *(^)(UIFont *font))selectedFont;
- (TGSegmentConfig *(^)(CGFloat margin))margin;
- (TGSegmentConfig *(^)(CGFloat height))barH;
- (TGSegmentConfig *(^)(UIColor *color))moreBGColor;
- (TGSegmentConfig *(^)(UIColor *color))moreCellBGColor;
- (TGSegmentConfig *(^)(CGFloat count))moreVCRowCount;
- (TGSegmentConfig *(^)(CGFloat height))moreCellMinH;
- (TGSegmentConfig *(^)(UIColor *color))moreBtnBorderColor;
- (TGSegmentConfig *(^)(CGFloat width)) moreBtnborderW;
- (TGSegmentConfig *(^)(UIColor *color))moreBtnTitleColor;
- (TGSegmentConfig *(^)(UIColor *color))moreBtnBGColor;
- (TGSegmentConfig *(^)(UIFont *font))moreBtnTitleFont;
- (TGSegmentConfig *(^)(BOOL isShow))showMoreBtnlineView;
- (TGSegmentConfig *(^)(CGFloat height))moreBtnlineViewH;
- (TGSegmentConfig *(^)(UIColor *color))moreBtnlineViewColor;
- (TGSegmentConfig *(^)(UIColor *color))coverColor;
- (TGSegmentConfig *(^)(UIColor *color))moreCellTextColor;
- (TGSegmentConfig *(^)(UIFont *font))moreCellFont;
@end
部分运行截图
写在最后:
感谢你浏览到这里,文章一开始就提到你一定会喜欢,喜欢的理由是什么呢?因为在这里作者没有把最新效果放在这里,最新效果如随听、下拉刷新还有许多亮点等你去发现呢?全是工作中比较实用的技术,快快去发现吧
发现地址:
https://github.com/targetcloud/baisibudejie
最后的最后,送你一个惊喜,欢迎你中项目中使用TGRefreshOC
惊喜地址:https://github.com/targetcloud/TGRefreshOC