{"id":20468835,"url":"https://github.com/xifenglang/jpslidebar","last_synced_at":"2025-07-26T21:12:30.526Z","repository":{"id":209430093,"uuid":"49057572","full_name":"XiFengLang/JPSlideBar","owner":"XiFengLang","description":"类似简书首页、网易云音乐、UC浏览器新闻界面的顶部滚动导航条","archived":false,"fork":false,"pushed_at":"2017-05-03T02:32:36.000Z","size":1081,"stargazers_count":20,"open_issues_count":3,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T01:51:26.350Z","etag":null,"topics":["ios-ui","segementation","slideview"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/XiFengLang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-01-05T09:58:47.000Z","updated_at":"2024-08-27T09:40:07.000Z","dependencies_parsed_at":"2023-11-27T10:49:49.396Z","dependency_job_id":null,"html_url":"https://github.com/XiFengLang/JPSlideBar","commit_stats":null,"previous_names":["xifenglang/jpslidebar"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XiFengLang%2FJPSlideBar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XiFengLang%2FJPSlideBar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XiFengLang%2FJPSlideBar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XiFengLang%2FJPSlideBar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/XiFengLang","download_url":"https://codeload.github.com/XiFengLang/JPSlideBar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248697368,"owners_count":21147315,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios-ui","segementation","slideview"],"created_at":"2024-11-15T14:06:59.831Z","updated_at":"2025-04-13T10:26:52.410Z","avatar_url":"https://github.com/XiFengLang.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n##JPSlideBar 2.3\n----\n**类似简书首页、网易云音乐、UC浏览器新闻界面的顶部滚动导航条**\n\n![image](https://github.com/XiFengLang/JPSlideBar/raw/master/JPSlideBar/ExamplerImages/JPSlideBarGif01.gif)\n![image](https://github.com/XiFengLang/JPSlideBar/raw/master/JPSlideBar/ExamplerImages/JPSlideBarGif02.gif)\n![image](https://github.com/XiFengLang/JPSlideBar/raw/master/JPSlideBar/ExamplerImages/JPSlideBarGif03.gif)\n![image](https://github.com/XiFengLang/JPSlideBar/raw/master/JPSlideBar/ExamplerImages/JPSlideBarGif04.gif)\n\n----\n\n###功能介绍\n\u003e暂时实现可变滚动条+字体颜色渐变+字体大小渐变效果。\n\n\u003etitles.count \u003c= 5时只能点击SlideBar，并且等宽平铺处理，可以轻松应付切换2-5个内容页的界面。\n\n\u003eDemo里面的例子用了ScrollView/CollectionView添加SubViewController.view的模式，后续会模仿简书首页切换3个内容界面的效果。\n\n\u003e内部通过计算实现监测翻页，外部可以接收NSNotification做一些处理。\n\n###升级简介\nV2.3版\n\u003e少量修改，为年后大改做准备。\n\nV2.2版\n\u003e新增大小渐变\n\nV2.1版\n\u003e内部实现KVO以及翻页监测，使用更加灵活。\n\n\u003e解决内存泄露BUG。\n\n\u003e解决滑动过快而不调用scrollViewDidEndDecelerating的BUG。\n\n\u003e解决滑动条滚动到边缘后留有空隙的BUG。\n\n###Usage\n\n先导入JPSlideBar.h\n```Object-C\n#import \"JPSlideBar.h\"\n```\n\n内部带有强弱转换的宏，不用担心内存泄露。\n```Object-C\n    self.titleArray = @[@\"简书\",@\"ONE\",@\"网易云音乐\",@\"腾讯百度\",@\"谷歌\",@\"特斯拉\",@\"阿里巴巴\"];\n\n    self.slideBar = [JPSlideNavigationBar slideBarWithObservableScrollView:self.scrollView\n                                                            viewController:self\n                                                              frameOriginY:64\n                                                       slideBarSliderStyle:JPSlideBarStyleTransformationAndGradientColor];\n    \n    [self.view addSubview:self.slideBar];\n    \n    \n    Weak(self); //避免循环引用\n    [self.slideBar configureSlideBarWithTitles:titles\n                                     titleFont:[UIFont systemFontOfSize:18]\n                                     itemSpace:30\n                           normalTitleRGBColor:JColor_RGB(0,0,0)\n                         selectedTitleRGBColor:JColor_RGB(255,255,255)\n                                 selectedBlock:^(NSInteger index) {\n                                     Strong(self);\n                                     CGFloat scrollX = CGRectGetWidth(self.scrollView.bounds) * index;\n                                     [self.scrollView setContentOffset:CGPointMake(scrollX, 0)];\n                                 }];\n```\n\n默认使用磨砂玻璃的效果，如果不需要，设置背景颜色即可\n```Object-C\n    [self.slideBar setSlideBarBackgroudColorIfNecessary:[UIColor whiteColor]];\n```\n\n如果你需要监测每次滚动翻页，进行数据刷新/复用处理，监听翻页的通知就行。\n```Object-C\n    [JPNotificationCenter addObserver:self selector:@selector(doSomeThingWhenScrollViewChangePage:) name:JPSlideBarChangePageNotification object:nil];\n    \n- (void)doSomeThingWhenScrollViewChangePage:(NSNotification *)notification{\n    CGFloat offsetX = [notification.userInfo[JPSlideBarScrollViewContentOffsetX] floatValue];\n    NSInteger index = [notification.userInfo[JPSlideBarCurrentIndex] integerValue];\n    \n    JKLog(@\"offsetX:%f    index:%ld\",offsetX,index);\n}\n```\n\n\n```Object-C\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxifenglang%2Fjpslidebar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxifenglang%2Fjpslidebar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxifenglang%2Fjpslidebar/lists"}