├── .gitignore ├── LICENSE ├── Pictures └── SGPagingView.png ├── README.md ├── READMEOBJC.md ├── SGPagingView.podspec ├── SGPagingView.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── SGPagingView ├── AppDelegate.swift ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── bg_image.imageset │ │ ├── Contents.json │ │ └── bg_image@2x.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Example │ ├── AttributedVC.swift │ ├── BadgeVC.swift │ ├── CoverOneVC.swift │ ├── CoverTwoVC.swift │ ├── FixedOneVC.swift │ ├── FixedTwoVC.swift │ ├── GradientEffectVC.swift │ ├── IDynamicVC.swift │ ├── IFixedVC.swift │ ├── ScrollVC.swift │ ├── Suspension │ │ ├── BaseSubVC.swift │ │ ├── BaseTableView.swift │ │ ├── SubTitleVC.swift │ │ ├── SubVC.swift │ │ └── SuspensionVC.swift │ ├── SuspensionPro │ │ ├── BaseSubProVC.swift │ │ ├── SubProVC.swift │ │ ├── SubTitleProVC.swift │ │ └── SuspensionProVC.swift │ └── ZoomVC.swift ├── Info.plist ├── SceneDelegate.swift └── ViewController.swift ├── SGPagingViewTests └── SGPagingViewTests.swift ├── SGPagingViewUITests ├── SGPagingViewUITests.swift └── SGPagingViewUITestsLaunchTests.swift └── Sources ├── Extensions ├── UIButton+SGPagingView.swift └── UIScreen+SGPagingView.swift ├── PagingContent ├── SGPagingContentCollectionView.swift ├── SGPagingContentScrollView.swift ├── SGPagingContentView.swift └── SGPagingContentViewDelegate.swift └── PagingTitle ├── SGPagingTitleView.swift └── SGPagingTitleViewConfigure.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | 55 | #Code Injection 56 | # 57 | # After new code Injection tools there's a generated folder /iOSInjectionProject 58 | # https://github.com/johnno1962/injectionforxcode 59 | 60 | iOSInjectionProject/ 61 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 kingsic 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Pictures/SGPagingView.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kingsic/SGPagingView/275af731a41e0cc306ee91af044cf36c405350c4/Pictures/SGPagingView.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SGPagingView 2 | 3 | 4 | ## 前言 5 | * QQ群:825339547 6 | * 2.0.0 版本起,升级为 Swift 编程语言 7 | * [Objc 版本说明](https://github.com/kingsic/SGPagingView/blob/master/READMEOBJC.md) 8 | 9 | 10 | ## 结构图 11 | ![](https://github.com/kingsic/SGPagingView/blob/master/Pictures/SGPagingView.png) 12 | 13 | 14 | ## 效果图 15 | ![](https://github.com/kingsic/Kar98k/blob/master/SGPagingView/SGPagingView.gif) 16 | 17 | 18 | ## Installation 19 | * CocoaPods 导入 pod 'SGPagingView', '~> 2.1.0' 20 | 21 | 22 | ## 代码介绍 23 | * 初始化方法 24 | ``` 25 | // 配置类 26 | let configure = SGPagingTitleViewConfigure() 27 | 28 | // 标题视图 29 | let pagingTitleView = SGPagingTitleView(frame: frame, titles: titles, configure: configure) 30 | pagingTitleView.delegate = self 31 | view.addSubview(pagingTitleView) 32 | 33 | // 内容视图 34 | let pagingContentView = SGPagingContentScrollView(frame: frame, parentVC: self, childVCs: childVCs) 35 | pagingContentView.delegate = self 36 | view.addSubview(pagingContentView) 37 | ``` 38 | 39 | * SGPagingTitleView 代理方法 40 | ``` 41 | func pagingTitleView(titleView: SGPagingTitleView, index: Int) { 42 | pagingContentView.setPagingContentView(index: index) 43 | } 44 | ``` 45 | 46 | * SGPagingContentView 代理方法 47 | ``` 48 | func pagingContentView(contentView: SGPagingContentView, progress: CGFloat, currentIndex: Int, targetIndex: Int) { 49 | pagingTitleView.setPagingTitleView(progress: progress, currentIndex: currentIndex, targetIndex: targetIndex) 50 | } 51 | ``` 52 | 53 | 54 | ## Requirements 55 | * iOS 10.0 + 56 | * Swift 5.0 + 57 | 58 | 59 | ## Concluding remarks 60 | * 如有问题 [issues](https://github.com/kingsic/SGPagingView/issues) 61 | 62 | -------------------------------------------------------------------------------- /READMEOBJC.md: -------------------------------------------------------------------------------- 1 | 2 | ## 前言 3 | * 从 2.0.0 版本起,升级为 Swift 编程语言 4 | * 从 2.1.0 版本起,已兼容 Objective-C 语义 5 | * Objective-C 编程语言最后的版本是 [1.7.2](https://github.com/kingsic/SGPagingView/releases/tag/1.7.2),且不在给予维护 6 | 7 | 8 | ## 结构图 9 | ``` 10 | SGPageTitleViewConfigure(SGPageTitleView 初始化配置信息) 11 | 12 | SGPageTitleView(用于与 SGPageContent 联动) 13 | 14 | SGPageContentScrollView(内部由 UIScrollView 实现) 15 | 16 | SGPageContentCollectionView(内部由 UICollectionView 实现) 17 | ``` 18 | 19 | 20 | ## Installation 21 | * 1、CocoaPods 导入 Objective-C 版本,pod 'SGPagingView', '~> 1.7.2' 22 | * 2、下载 [1.7.2](https://github.com/kingsic/SGPagingView/releases/tag/1.7.2) 版本并拖拽 “SGPagingView” 文件夹到工程中 23 | 24 | 25 | ## 代码介绍 26 | * 初始化方法 27 | ``` 28 | // 配置类 29 | SGPageTitleViewConfigure *configure = [SGPageTitleViewConfigure pageTitleViewConfigure]; 30 | 31 | // 标题视图 32 | SGPageTitleView *pageTitleView = [SGPageTitleView pageTitleViewWithFrame:frame delegate:self titleNames:titleNames configure:configure]; 33 | [self.view addSubview:pageTitleView]; 34 | 35 | // 内容视图 36 | SGPageContentScrollView *pageContentScrollView = [[SGPageContentScrollView alloc] initWithFrame:frame parentVC:self childVCs:childVCs]; 37 | pageContentScrollView.delegatePageContentScrollView = self; 38 | [self.view addSubview:pageContentScrollView]; 39 | ``` 40 | 41 | * 滚动内容视图的代理方法 42 | ``` 43 | - (void)pageContentScrollView:(SGPageContentScrollView *)pageContentScrollView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex { 44 | [self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex]; 45 | } 46 | ``` 47 | 48 | * 滚动标题视图的代理方法 49 | ``` 50 | - (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex { 51 | [self.pageContentScrollView setPageCententScrollViewCurrentIndex:selectedIndex]; 52 | } 53 | ``` 54 | 55 | 56 | ## 问题及解决方案 57 | ### 一、CocoaPods 安装 SGPagingView 时,遇到的问题及解决方案 58 | * 若在使用 CocoaPods 安装 SGPagingView 时,出现 [!] Unable to find a specification for SGPagingView 提示时,打开终端先输入 pod repo remove master;执行完毕后再输入 pod setup 即可 (可能会等待一段时间) 59 | *** 60 | 61 | ### 二、父子视图 autolayout 及 frame 62 | * 父视图使用 autolayout 约束,子视图也需使用 autolayout 去约束;父视图使用 frame 布局,子视图也需使用 frame 去布局 63 | *** 64 | 65 | ### 三、关于父子控制器的说明(SGPageContentScrollView 与 SGPageContentCollectionView) 66 | ###### 参考链接 67 | * [添加子视图控制器时,子视图控制器的 viewWillAppear 方法不调用](https://blog.csdn.net/u012907783/article/details/78972227) 68 | * [addChildViewController 与 viewWillAppear、viewDidAppear 关系说明](https://blog.csdn.net/zhaoxy_thu/article/details/50826190) 69 | *** 70 | 71 | ### 四、关于侧滑返回手势(请参考 DefaultVCPopGesture 类以及点击子控制器对下一界面所做的处理) 72 | #### 1、如果是系统默认返回 item ;只需实现 SGPageContentScrollView 的 pageContentScrollView:offsetX:代理方法或 SGPageContentCollectionView 的 pageContentCollectionView:offsetX:代理方法,并在此方法实现以下代码即可,如: 73 | ``` 74 | - (void)pageContentScrollView:(SGPageContentScrollView *)pageContentScrollView index:(NSInteger)index { 75 | if (index == 0) { 76 | self.navigationController.interactivePopGestureRecognizer.enabled = YES; 77 | } else { 78 | self.navigationController.interactivePopGestureRecognizer.enabled = NO; 79 | } 80 | } 81 | ``` 82 | 83 | #### 2、如果是自定义返回 item 84 | a. 需单独在 .h 文件中导入 #import "SGPagingViewPopGestureVC.h",且控制器继承 SGPagingViewPopGestureVC; 85 | 86 | b. 实现 SGPageContentScrollView 的 pageContentScrollView:index:代理方法或 SGPageContentCollectionView 的 pageContentCollectionView:index:代理方法 87 | ``` 88 | - (void)pageContentScrollView:(SGPageContentScrollView *)pageContentScrollView index:(NSInteger)index { 89 | if (index == 0) { 90 | self.navigationController.interactivePopGestureRecognizer.enabled = YES; 91 | } else { 92 | self.navigationController.interactivePopGestureRecognizer.enabled = NO; 93 | } 94 | } 95 | ``` 96 | 97 | ##### 温馨提示一:由于 index != 0 时 self.navigationController.interactivePopGestureRecognizer.enabled = NO; 所以 push 到下一控制器需在 viewDidLoad 中设置为 YES; 98 | 99 | ##### 温馨提示二:导航栏包装自定义返回 item 使用 SGPagingView 也会导致侧滑返回失效解决方案同(2、如果是自定义返回 item);如果你工程中某个控制器使用自定义返回 item 解决方案同(2、如果是自定义返回 item);这里只是提供一种解决方案,仅供参考。如果你有更好的解决方案欢迎联我 100 | 101 | ##### 温馨提示三:自定义返回 item 导致侧滑返回手势失效[参考链接](https://www.jianshu.com/p/33ce1340a543) 102 | 103 | #### 3、issues [关于返回手势](https://github.com/kingsic/SGPagingView/issues/25) 已有开发者提供了解决方案,仅供参看 104 | *** 105 | 106 | ### 五、只有 PageContent 为 SGPageContentScrollView 且 selectedIndex != 0 与 insertSubview 方法同时出现时造成程序崩溃 107 | * 第一种解决方案:更换 SGPageContentScrollView 为 SGPageContentCollectionView 即可 108 | * 第一种解决方案:默认子控制器为0,即 selectedIndex 不设置 109 | * 第三种解决方案:代码如下处理 110 | ``` 111 | [self.view addSubview:_pageContentScrollView]; 112 | dispatch_async(dispatch_get_main_queue(), ^{ 113 | [self.view insertSubview:self.pageContentScrollView atIndex:0]; 114 | }); 115 | ``` 116 | * 如不需要 autolayout 创建,导入 v1.5.6(无需考虑上述问题) 117 | 118 | 119 | ## 版本介绍 120 | 121 | * 2016-10-07 :初始版本的创建 122 | 123 | * 2017-07-21 :v1.1.7 加入 CocoaPods 管理及新增 SGPageContentScrollView 类 124 | 125 | * 2017-10-17 :v1.3.0 版本升级:新增 SGPageTitleViewConfigure 类及支持指示器遮盖样式 126 | 127 | * 2018-07-09 :v1.5.0 版本升级:具体相关信息请查看 [releases](https://github.com/kingsic/SGPagingView/releases) 中版本介绍 128 | 129 | * 2019-01-09 :v1.6.0 版本升级:支持 autolayout 布局 130 | 131 | * 2019-07-22 :v1.6.6 SGPageTitleViewConfigure 新增 equivalence 属性支持静止样式下标题从左到右自动布局 132 | 133 | * 2019-07-27 :v1.6.7 标题支持上下行及 titleGradientEffect 属性与 resetTitleColor:titleSelectedColor: 方法兼容 134 | 135 | * 2020-11-01 :v1.6.9 Badge 新增配置属性,支持网络图片,修复无指示器滚动内容视图时标题文字不切换 136 | 137 | * 2020-12-22 :v1.7.0 标题不支持换行(极端情况出现的标题换行效果) 138 | 139 | * 2021-01-05 :v1.7.1 修复退至到后台,标题重新默认选中Bug 140 | 141 | * 2021-05-05 :v1.7.2 新增 SGPageTitleView 左右内边距属性 142 | -------------------------------------------------------------------------------- /SGPagingView.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint SGPagingView.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see https://guides.cocoapods.org/syntax/podspec.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |spec| 10 | spec.name = "SGPagingView" 11 | spec.version = "2.1.0" 12 | spec.summary = "A powerful and easy to use segment view" 13 | spec.homepage = "https://github.com/kingsic/SGPagingView" 14 | spec.license = "MIT" 15 | spec.author = { "kingsic" => "kingsic@126.com" } 16 | spec.platform = :ios, "10.0" 17 | spec.source = {:git => "https://github.com/kingsic/SGPagingView.git", :tag => spec.version} 18 | spec.source_files = "Sources/**/*.{swift}" 19 | spec.requires_arc = true 20 | spec.swift_versions = "5.0" 21 | end 22 | -------------------------------------------------------------------------------- /SGPagingView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 55; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 8D173CCB2763A5E700B59F4D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173CCA2763A5E700B59F4D /* AppDelegate.swift */; }; 11 | 8D173CCD2763A5E700B59F4D /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173CCC2763A5E700B59F4D /* SceneDelegate.swift */; }; 12 | 8D173CCF2763A5E700B59F4D /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173CCE2763A5E700B59F4D /* ViewController.swift */; }; 13 | 8D173CD22763A5E700B59F4D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8D173CD02763A5E700B59F4D /* Main.storyboard */; }; 14 | 8D173CD42763A5EB00B59F4D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8D173CD32763A5EB00B59F4D /* Assets.xcassets */; }; 15 | 8D173CD72763A5EB00B59F4D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8D173CD52763A5EB00B59F4D /* LaunchScreen.storyboard */; }; 16 | 8D173CE22763A5EB00B59F4D /* SGPagingViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173CE12763A5EB00B59F4D /* SGPagingViewTests.swift */; }; 17 | 8D173CEC2763A5EB00B59F4D /* SGPagingViewUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173CEB2763A5EB00B59F4D /* SGPagingViewUITests.swift */; }; 18 | 8D173CEE2763A5EB00B59F4D /* SGPagingViewUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173CED2763A5EB00B59F4D /* SGPagingViewUITestsLaunchTests.swift */; }; 19 | 8D173D062763A90B00B59F4D /* UIButton+SGPagingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173CFC2763A90B00B59F4D /* UIButton+SGPagingView.swift */; }; 20 | 8D173D072763A90B00B59F4D /* UIScreen+SGPagingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173CFD2763A90B00B59F4D /* UIScreen+SGPagingView.swift */; }; 21 | 8D173D082763A90B00B59F4D /* SGPagingContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173CFF2763A90B00B59F4D /* SGPagingContentView.swift */; }; 22 | 8D173D092763A90B00B59F4D /* SGPagingContentScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D002763A90B00B59F4D /* SGPagingContentScrollView.swift */; }; 23 | 8D173D0A2763A90B00B59F4D /* SGPagingContentViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D012763A90B00B59F4D /* SGPagingContentViewDelegate.swift */; }; 24 | 8D173D0B2763A90B00B59F4D /* SGPagingContentCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D022763A90B00B59F4D /* SGPagingContentCollectionView.swift */; }; 25 | 8D173D0C2763A90B00B59F4D /* SGPagingTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D042763A90B00B59F4D /* SGPagingTitleView.swift */; }; 26 | 8D173D0D2763A90B00B59F4D /* SGPagingTitleViewConfigure.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D052763A90B00B59F4D /* SGPagingTitleViewConfigure.swift */; }; 27 | 8D173D252763A92600B59F4D /* FixedOneVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D0F2763A92600B59F4D /* FixedOneVC.swift */; }; 28 | 8D173D262763A92600B59F4D /* ScrollVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D102763A92600B59F4D /* ScrollVC.swift */; }; 29 | 8D173D272763A92600B59F4D /* SuspensionProVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D122763A92600B59F4D /* SuspensionProVC.swift */; }; 30 | 8D173D282763A92600B59F4D /* BaseSubProVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D132763A92600B59F4D /* BaseSubProVC.swift */; }; 31 | 8D173D292763A92600B59F4D /* SubTitleProVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D142763A92600B59F4D /* SubTitleProVC.swift */; }; 32 | 8D173D2A2763A92600B59F4D /* SubProVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D152763A92600B59F4D /* SubProVC.swift */; }; 33 | 8D173D2B2763A92600B59F4D /* CoverOneVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D162763A92600B59F4D /* CoverOneVC.swift */; }; 34 | 8D173D2C2763A92600B59F4D /* BadgeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D172763A92600B59F4D /* BadgeVC.swift */; }; 35 | 8D173D2D2763A92600B59F4D /* ZoomVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D182763A92600B59F4D /* ZoomVC.swift */; }; 36 | 8D173D2E2763A92600B59F4D /* FixedTwoVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D192763A92600B59F4D /* FixedTwoVC.swift */; }; 37 | 8D173D2F2763A92600B59F4D /* IDynamicVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D1A2763A92600B59F4D /* IDynamicVC.swift */; }; 38 | 8D173D302763A92600B59F4D /* IFixedVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D1B2763A92600B59F4D /* IFixedVC.swift */; }; 39 | 8D173D312763A92600B59F4D /* CoverTwoVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D1C2763A92600B59F4D /* CoverTwoVC.swift */; }; 40 | 8D173D322763A92600B59F4D /* SubVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D1E2763A92600B59F4D /* SubVC.swift */; }; 41 | 8D173D332763A92600B59F4D /* BaseSubVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D1F2763A92600B59F4D /* BaseSubVC.swift */; }; 42 | 8D173D342763A92600B59F4D /* BaseTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D202763A92600B59F4D /* BaseTableView.swift */; }; 43 | 8D173D352763A92600B59F4D /* SuspensionVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D212763A92600B59F4D /* SuspensionVC.swift */; }; 44 | 8D173D362763A92600B59F4D /* SubTitleVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D222763A92600B59F4D /* SubTitleVC.swift */; }; 45 | 8D173D372763A92600B59F4D /* AttributedVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D232763A92600B59F4D /* AttributedVC.swift */; }; 46 | 8D173D382763A92600B59F4D /* GradientEffectVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D173D242763A92600B59F4D /* GradientEffectVC.swift */; }; 47 | /* End PBXBuildFile section */ 48 | 49 | /* Begin PBXContainerItemProxy section */ 50 | 8D173CDE2763A5EB00B59F4D /* PBXContainerItemProxy */ = { 51 | isa = PBXContainerItemProxy; 52 | containerPortal = 8D173CBF2763A5E700B59F4D /* Project object */; 53 | proxyType = 1; 54 | remoteGlobalIDString = 8D173CC62763A5E700B59F4D; 55 | remoteInfo = SGPagingView; 56 | }; 57 | 8D173CE82763A5EB00B59F4D /* PBXContainerItemProxy */ = { 58 | isa = PBXContainerItemProxy; 59 | containerPortal = 8D173CBF2763A5E700B59F4D /* Project object */; 60 | proxyType = 1; 61 | remoteGlobalIDString = 8D173CC62763A5E700B59F4D; 62 | remoteInfo = SGPagingView; 63 | }; 64 | /* End PBXContainerItemProxy section */ 65 | 66 | /* Begin PBXFileReference section */ 67 | 8D173CC72763A5E700B59F4D /* SGPagingView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SGPagingView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 68 | 8D173CCA2763A5E700B59F4D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 69 | 8D173CCC2763A5E700B59F4D /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 70 | 8D173CCE2763A5E700B59F4D /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 71 | 8D173CD12763A5E700B59F4D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 72 | 8D173CD32763A5EB00B59F4D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 73 | 8D173CD62763A5EB00B59F4D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 74 | 8D173CD82763A5EB00B59F4D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 75 | 8D173CDD2763A5EB00B59F4D /* SGPagingViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SGPagingViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 76 | 8D173CE12763A5EB00B59F4D /* SGPagingViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SGPagingViewTests.swift; sourceTree = ""; }; 77 | 8D173CE72763A5EB00B59F4D /* SGPagingViewUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SGPagingViewUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 78 | 8D173CEB2763A5EB00B59F4D /* SGPagingViewUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SGPagingViewUITests.swift; sourceTree = ""; }; 79 | 8D173CED2763A5EB00B59F4D /* SGPagingViewUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SGPagingViewUITestsLaunchTests.swift; sourceTree = ""; }; 80 | 8D173CFC2763A90B00B59F4D /* UIButton+SGPagingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIButton+SGPagingView.swift"; sourceTree = ""; }; 81 | 8D173CFD2763A90B00B59F4D /* UIScreen+SGPagingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIScreen+SGPagingView.swift"; sourceTree = ""; }; 82 | 8D173CFF2763A90B00B59F4D /* SGPagingContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SGPagingContentView.swift; sourceTree = ""; }; 83 | 8D173D002763A90B00B59F4D /* SGPagingContentScrollView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SGPagingContentScrollView.swift; sourceTree = ""; }; 84 | 8D173D012763A90B00B59F4D /* SGPagingContentViewDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SGPagingContentViewDelegate.swift; sourceTree = ""; }; 85 | 8D173D022763A90B00B59F4D /* SGPagingContentCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SGPagingContentCollectionView.swift; sourceTree = ""; }; 86 | 8D173D042763A90B00B59F4D /* SGPagingTitleView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SGPagingTitleView.swift; sourceTree = ""; }; 87 | 8D173D052763A90B00B59F4D /* SGPagingTitleViewConfigure.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SGPagingTitleViewConfigure.swift; sourceTree = ""; }; 88 | 8D173D0F2763A92600B59F4D /* FixedOneVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FixedOneVC.swift; sourceTree = ""; }; 89 | 8D173D102763A92600B59F4D /* ScrollVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScrollVC.swift; sourceTree = ""; }; 90 | 8D173D122763A92600B59F4D /* SuspensionProVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SuspensionProVC.swift; sourceTree = ""; }; 91 | 8D173D132763A92600B59F4D /* BaseSubProVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseSubProVC.swift; sourceTree = ""; }; 92 | 8D173D142763A92600B59F4D /* SubTitleProVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SubTitleProVC.swift; sourceTree = ""; }; 93 | 8D173D152763A92600B59F4D /* SubProVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SubProVC.swift; sourceTree = ""; }; 94 | 8D173D162763A92600B59F4D /* CoverOneVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoverOneVC.swift; sourceTree = ""; }; 95 | 8D173D172763A92600B59F4D /* BadgeVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BadgeVC.swift; sourceTree = ""; }; 96 | 8D173D182763A92600B59F4D /* ZoomVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZoomVC.swift; sourceTree = ""; }; 97 | 8D173D192763A92600B59F4D /* FixedTwoVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FixedTwoVC.swift; sourceTree = ""; }; 98 | 8D173D1A2763A92600B59F4D /* IDynamicVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IDynamicVC.swift; sourceTree = ""; }; 99 | 8D173D1B2763A92600B59F4D /* IFixedVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IFixedVC.swift; sourceTree = ""; }; 100 | 8D173D1C2763A92600B59F4D /* CoverTwoVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoverTwoVC.swift; sourceTree = ""; }; 101 | 8D173D1E2763A92600B59F4D /* SubVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SubVC.swift; sourceTree = ""; }; 102 | 8D173D1F2763A92600B59F4D /* BaseSubVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseSubVC.swift; sourceTree = ""; }; 103 | 8D173D202763A92600B59F4D /* BaseTableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseTableView.swift; sourceTree = ""; }; 104 | 8D173D212763A92600B59F4D /* SuspensionVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SuspensionVC.swift; sourceTree = ""; }; 105 | 8D173D222763A92600B59F4D /* SubTitleVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SubTitleVC.swift; sourceTree = ""; }; 106 | 8D173D232763A92600B59F4D /* AttributedVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttributedVC.swift; sourceTree = ""; }; 107 | 8D173D242763A92600B59F4D /* GradientEffectVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GradientEffectVC.swift; sourceTree = ""; }; 108 | /* End PBXFileReference section */ 109 | 110 | /* Begin PBXFrameworksBuildPhase section */ 111 | 8D173CC42763A5E700B59F4D /* Frameworks */ = { 112 | isa = PBXFrameworksBuildPhase; 113 | buildActionMask = 2147483647; 114 | files = ( 115 | ); 116 | runOnlyForDeploymentPostprocessing = 0; 117 | }; 118 | 8D173CDA2763A5EB00B59F4D /* Frameworks */ = { 119 | isa = PBXFrameworksBuildPhase; 120 | buildActionMask = 2147483647; 121 | files = ( 122 | ); 123 | runOnlyForDeploymentPostprocessing = 0; 124 | }; 125 | 8D173CE42763A5EB00B59F4D /* Frameworks */ = { 126 | isa = PBXFrameworksBuildPhase; 127 | buildActionMask = 2147483647; 128 | files = ( 129 | ); 130 | runOnlyForDeploymentPostprocessing = 0; 131 | }; 132 | /* End PBXFrameworksBuildPhase section */ 133 | 134 | /* Begin PBXGroup section */ 135 | 8D173CBE2763A5E700B59F4D = { 136 | isa = PBXGroup; 137 | children = ( 138 | 8D173CFA2763A90B00B59F4D /* Sources */, 139 | 8D173CC92763A5E700B59F4D /* SGPagingView */, 140 | 8D173CE02763A5EB00B59F4D /* SGPagingViewTests */, 141 | 8D173CEA2763A5EB00B59F4D /* SGPagingViewUITests */, 142 | 8D173CC82763A5E700B59F4D /* Products */, 143 | ); 144 | sourceTree = ""; 145 | }; 146 | 8D173CC82763A5E700B59F4D /* Products */ = { 147 | isa = PBXGroup; 148 | children = ( 149 | 8D173CC72763A5E700B59F4D /* SGPagingView.app */, 150 | 8D173CDD2763A5EB00B59F4D /* SGPagingViewTests.xctest */, 151 | 8D173CE72763A5EB00B59F4D /* SGPagingViewUITests.xctest */, 152 | ); 153 | name = Products; 154 | sourceTree = ""; 155 | }; 156 | 8D173CC92763A5E700B59F4D /* SGPagingView */ = { 157 | isa = PBXGroup; 158 | children = ( 159 | 8D173CCA2763A5E700B59F4D /* AppDelegate.swift */, 160 | 8D173CCC2763A5E700B59F4D /* SceneDelegate.swift */, 161 | 8D173CCE2763A5E700B59F4D /* ViewController.swift */, 162 | 8D173D0E2763A92600B59F4D /* Example */, 163 | 8D173CD02763A5E700B59F4D /* Main.storyboard */, 164 | 8D173CD32763A5EB00B59F4D /* Assets.xcassets */, 165 | 8D173CD52763A5EB00B59F4D /* LaunchScreen.storyboard */, 166 | 8D173CD82763A5EB00B59F4D /* Info.plist */, 167 | ); 168 | path = SGPagingView; 169 | sourceTree = ""; 170 | }; 171 | 8D173CE02763A5EB00B59F4D /* SGPagingViewTests */ = { 172 | isa = PBXGroup; 173 | children = ( 174 | 8D173CE12763A5EB00B59F4D /* SGPagingViewTests.swift */, 175 | ); 176 | path = SGPagingViewTests; 177 | sourceTree = ""; 178 | }; 179 | 8D173CEA2763A5EB00B59F4D /* SGPagingViewUITests */ = { 180 | isa = PBXGroup; 181 | children = ( 182 | 8D173CEB2763A5EB00B59F4D /* SGPagingViewUITests.swift */, 183 | 8D173CED2763A5EB00B59F4D /* SGPagingViewUITestsLaunchTests.swift */, 184 | ); 185 | path = SGPagingViewUITests; 186 | sourceTree = ""; 187 | }; 188 | 8D173CFA2763A90B00B59F4D /* Sources */ = { 189 | isa = PBXGroup; 190 | children = ( 191 | 8D173D032763A90B00B59F4D /* PagingTitle */, 192 | 8D173CFE2763A90B00B59F4D /* PagingContent */, 193 | 8D173CFB2763A90B00B59F4D /* Extensions */, 194 | ); 195 | path = Sources; 196 | sourceTree = ""; 197 | }; 198 | 8D173CFB2763A90B00B59F4D /* Extensions */ = { 199 | isa = PBXGroup; 200 | children = ( 201 | 8D173CFC2763A90B00B59F4D /* UIButton+SGPagingView.swift */, 202 | 8D173CFD2763A90B00B59F4D /* UIScreen+SGPagingView.swift */, 203 | ); 204 | path = Extensions; 205 | sourceTree = ""; 206 | }; 207 | 8D173CFE2763A90B00B59F4D /* PagingContent */ = { 208 | isa = PBXGroup; 209 | children = ( 210 | 8D173D022763A90B00B59F4D /* SGPagingContentCollectionView.swift */, 211 | 8D173D002763A90B00B59F4D /* SGPagingContentScrollView.swift */, 212 | 8D173CFF2763A90B00B59F4D /* SGPagingContentView.swift */, 213 | 8D173D012763A90B00B59F4D /* SGPagingContentViewDelegate.swift */, 214 | ); 215 | path = PagingContent; 216 | sourceTree = ""; 217 | }; 218 | 8D173D032763A90B00B59F4D /* PagingTitle */ = { 219 | isa = PBXGroup; 220 | children = ( 221 | 8D173D052763A90B00B59F4D /* SGPagingTitleViewConfigure.swift */, 222 | 8D173D042763A90B00B59F4D /* SGPagingTitleView.swift */, 223 | ); 224 | path = PagingTitle; 225 | sourceTree = ""; 226 | }; 227 | 8D173D0E2763A92600B59F4D /* Example */ = { 228 | isa = PBXGroup; 229 | children = ( 230 | 8D173D0F2763A92600B59F4D /* FixedOneVC.swift */, 231 | 8D173D192763A92600B59F4D /* FixedTwoVC.swift */, 232 | 8D173D102763A92600B59F4D /* ScrollVC.swift */, 233 | 8D173D232763A92600B59F4D /* AttributedVC.swift */, 234 | 8D173D242763A92600B59F4D /* GradientEffectVC.swift */, 235 | 8D173D182763A92600B59F4D /* ZoomVC.swift */, 236 | 8D173D172763A92600B59F4D /* BadgeVC.swift */, 237 | 8D173D1B2763A92600B59F4D /* IFixedVC.swift */, 238 | 8D173D1A2763A92600B59F4D /* IDynamicVC.swift */, 239 | 8D173D162763A92600B59F4D /* CoverOneVC.swift */, 240 | 8D173D1C2763A92600B59F4D /* CoverTwoVC.swift */, 241 | 8D173D1D2763A92600B59F4D /* Suspension */, 242 | 8D173D112763A92600B59F4D /* SuspensionPro */, 243 | ); 244 | path = Example; 245 | sourceTree = ""; 246 | }; 247 | 8D173D112763A92600B59F4D /* SuspensionPro */ = { 248 | isa = PBXGroup; 249 | children = ( 250 | 8D173D122763A92600B59F4D /* SuspensionProVC.swift */, 251 | 8D173D132763A92600B59F4D /* BaseSubProVC.swift */, 252 | 8D173D152763A92600B59F4D /* SubProVC.swift */, 253 | 8D173D142763A92600B59F4D /* SubTitleProVC.swift */, 254 | ); 255 | path = SuspensionPro; 256 | sourceTree = ""; 257 | }; 258 | 8D173D1D2763A92600B59F4D /* Suspension */ = { 259 | isa = PBXGroup; 260 | children = ( 261 | 8D173D212763A92600B59F4D /* SuspensionVC.swift */, 262 | 8D173D1F2763A92600B59F4D /* BaseSubVC.swift */, 263 | 8D173D1E2763A92600B59F4D /* SubVC.swift */, 264 | 8D173D222763A92600B59F4D /* SubTitleVC.swift */, 265 | 8D173D202763A92600B59F4D /* BaseTableView.swift */, 266 | ); 267 | path = Suspension; 268 | sourceTree = ""; 269 | }; 270 | /* End PBXGroup section */ 271 | 272 | /* Begin PBXNativeTarget section */ 273 | 8D173CC62763A5E700B59F4D /* SGPagingView */ = { 274 | isa = PBXNativeTarget; 275 | buildConfigurationList = 8D173CF12763A5EB00B59F4D /* Build configuration list for PBXNativeTarget "SGPagingView" */; 276 | buildPhases = ( 277 | 8D173CC32763A5E700B59F4D /* Sources */, 278 | 8D173CC42763A5E700B59F4D /* Frameworks */, 279 | 8D173CC52763A5E700B59F4D /* Resources */, 280 | ); 281 | buildRules = ( 282 | ); 283 | dependencies = ( 284 | ); 285 | name = SGPagingView; 286 | productName = SGPagingView; 287 | productReference = 8D173CC72763A5E700B59F4D /* SGPagingView.app */; 288 | productType = "com.apple.product-type.application"; 289 | }; 290 | 8D173CDC2763A5EB00B59F4D /* SGPagingViewTests */ = { 291 | isa = PBXNativeTarget; 292 | buildConfigurationList = 8D173CF42763A5EB00B59F4D /* Build configuration list for PBXNativeTarget "SGPagingViewTests" */; 293 | buildPhases = ( 294 | 8D173CD92763A5EB00B59F4D /* Sources */, 295 | 8D173CDA2763A5EB00B59F4D /* Frameworks */, 296 | 8D173CDB2763A5EB00B59F4D /* Resources */, 297 | ); 298 | buildRules = ( 299 | ); 300 | dependencies = ( 301 | 8D173CDF2763A5EB00B59F4D /* PBXTargetDependency */, 302 | ); 303 | name = SGPagingViewTests; 304 | productName = SGPagingViewTests; 305 | productReference = 8D173CDD2763A5EB00B59F4D /* SGPagingViewTests.xctest */; 306 | productType = "com.apple.product-type.bundle.unit-test"; 307 | }; 308 | 8D173CE62763A5EB00B59F4D /* SGPagingViewUITests */ = { 309 | isa = PBXNativeTarget; 310 | buildConfigurationList = 8D173CF72763A5EB00B59F4D /* Build configuration list for PBXNativeTarget "SGPagingViewUITests" */; 311 | buildPhases = ( 312 | 8D173CE32763A5EB00B59F4D /* Sources */, 313 | 8D173CE42763A5EB00B59F4D /* Frameworks */, 314 | 8D173CE52763A5EB00B59F4D /* Resources */, 315 | ); 316 | buildRules = ( 317 | ); 318 | dependencies = ( 319 | 8D173CE92763A5EB00B59F4D /* PBXTargetDependency */, 320 | ); 321 | name = SGPagingViewUITests; 322 | productName = SGPagingViewUITests; 323 | productReference = 8D173CE72763A5EB00B59F4D /* SGPagingViewUITests.xctest */; 324 | productType = "com.apple.product-type.bundle.ui-testing"; 325 | }; 326 | /* End PBXNativeTarget section */ 327 | 328 | /* Begin PBXProject section */ 329 | 8D173CBF2763A5E700B59F4D /* Project object */ = { 330 | isa = PBXProject; 331 | attributes = { 332 | BuildIndependentTargetsInParallel = 1; 333 | LastSwiftUpdateCheck = 1300; 334 | LastUpgradeCheck = 1300; 335 | TargetAttributes = { 336 | 8D173CC62763A5E700B59F4D = { 337 | CreatedOnToolsVersion = 13.0; 338 | }; 339 | 8D173CDC2763A5EB00B59F4D = { 340 | CreatedOnToolsVersion = 13.0; 341 | TestTargetID = 8D173CC62763A5E700B59F4D; 342 | }; 343 | 8D173CE62763A5EB00B59F4D = { 344 | CreatedOnToolsVersion = 13.0; 345 | TestTargetID = 8D173CC62763A5E700B59F4D; 346 | }; 347 | }; 348 | }; 349 | buildConfigurationList = 8D173CC22763A5E700B59F4D /* Build configuration list for PBXProject "SGPagingView" */; 350 | compatibilityVersion = "Xcode 13.0"; 351 | developmentRegion = en; 352 | hasScannedForEncodings = 0; 353 | knownRegions = ( 354 | en, 355 | Base, 356 | ); 357 | mainGroup = 8D173CBE2763A5E700B59F4D; 358 | productRefGroup = 8D173CC82763A5E700B59F4D /* Products */; 359 | projectDirPath = ""; 360 | projectRoot = ""; 361 | targets = ( 362 | 8D173CC62763A5E700B59F4D /* SGPagingView */, 363 | 8D173CDC2763A5EB00B59F4D /* SGPagingViewTests */, 364 | 8D173CE62763A5EB00B59F4D /* SGPagingViewUITests */, 365 | ); 366 | }; 367 | /* End PBXProject section */ 368 | 369 | /* Begin PBXResourcesBuildPhase section */ 370 | 8D173CC52763A5E700B59F4D /* Resources */ = { 371 | isa = PBXResourcesBuildPhase; 372 | buildActionMask = 2147483647; 373 | files = ( 374 | 8D173CD72763A5EB00B59F4D /* LaunchScreen.storyboard in Resources */, 375 | 8D173CD42763A5EB00B59F4D /* Assets.xcassets in Resources */, 376 | 8D173CD22763A5E700B59F4D /* Main.storyboard in Resources */, 377 | ); 378 | runOnlyForDeploymentPostprocessing = 0; 379 | }; 380 | 8D173CDB2763A5EB00B59F4D /* Resources */ = { 381 | isa = PBXResourcesBuildPhase; 382 | buildActionMask = 2147483647; 383 | files = ( 384 | ); 385 | runOnlyForDeploymentPostprocessing = 0; 386 | }; 387 | 8D173CE52763A5EB00B59F4D /* Resources */ = { 388 | isa = PBXResourcesBuildPhase; 389 | buildActionMask = 2147483647; 390 | files = ( 391 | ); 392 | runOnlyForDeploymentPostprocessing = 0; 393 | }; 394 | /* End PBXResourcesBuildPhase section */ 395 | 396 | /* Begin PBXSourcesBuildPhase section */ 397 | 8D173CC32763A5E700B59F4D /* Sources */ = { 398 | isa = PBXSourcesBuildPhase; 399 | buildActionMask = 2147483647; 400 | files = ( 401 | 8D173D332763A92600B59F4D /* BaseSubVC.swift in Sources */, 402 | 8D173D2F2763A92600B59F4D /* IDynamicVC.swift in Sources */, 403 | 8D173D082763A90B00B59F4D /* SGPagingContentView.swift in Sources */, 404 | 8D173D0C2763A90B00B59F4D /* SGPagingTitleView.swift in Sources */, 405 | 8D173D342763A92600B59F4D /* BaseTableView.swift in Sources */, 406 | 8D173D382763A92600B59F4D /* GradientEffectVC.swift in Sources */, 407 | 8D173D252763A92600B59F4D /* FixedOneVC.swift in Sources */, 408 | 8D173D0D2763A90B00B59F4D /* SGPagingTitleViewConfigure.swift in Sources */, 409 | 8D173D312763A92600B59F4D /* CoverTwoVC.swift in Sources */, 410 | 8D173D2C2763A92600B59F4D /* BadgeVC.swift in Sources */, 411 | 8D173D292763A92600B59F4D /* SubTitleProVC.swift in Sources */, 412 | 8D173CCF2763A5E700B59F4D /* ViewController.swift in Sources */, 413 | 8D173D262763A92600B59F4D /* ScrollVC.swift in Sources */, 414 | 8D173D072763A90B00B59F4D /* UIScreen+SGPagingView.swift in Sources */, 415 | 8D173D352763A92600B59F4D /* SuspensionVC.swift in Sources */, 416 | 8D173D372763A92600B59F4D /* AttributedVC.swift in Sources */, 417 | 8D173D2A2763A92600B59F4D /* SubProVC.swift in Sources */, 418 | 8D173D2E2763A92600B59F4D /* FixedTwoVC.swift in Sources */, 419 | 8D173D2B2763A92600B59F4D /* CoverOneVC.swift in Sources */, 420 | 8D173D322763A92600B59F4D /* SubVC.swift in Sources */, 421 | 8D173D302763A92600B59F4D /* IFixedVC.swift in Sources */, 422 | 8D173D272763A92600B59F4D /* SuspensionProVC.swift in Sources */, 423 | 8D173D282763A92600B59F4D /* BaseSubProVC.swift in Sources */, 424 | 8D173D362763A92600B59F4D /* SubTitleVC.swift in Sources */, 425 | 8D173D2D2763A92600B59F4D /* ZoomVC.swift in Sources */, 426 | 8D173CCB2763A5E700B59F4D /* AppDelegate.swift in Sources */, 427 | 8D173D062763A90B00B59F4D /* UIButton+SGPagingView.swift in Sources */, 428 | 8D173D092763A90B00B59F4D /* SGPagingContentScrollView.swift in Sources */, 429 | 8D173CCD2763A5E700B59F4D /* SceneDelegate.swift in Sources */, 430 | 8D173D0B2763A90B00B59F4D /* SGPagingContentCollectionView.swift in Sources */, 431 | 8D173D0A2763A90B00B59F4D /* SGPagingContentViewDelegate.swift in Sources */, 432 | ); 433 | runOnlyForDeploymentPostprocessing = 0; 434 | }; 435 | 8D173CD92763A5EB00B59F4D /* Sources */ = { 436 | isa = PBXSourcesBuildPhase; 437 | buildActionMask = 2147483647; 438 | files = ( 439 | 8D173CE22763A5EB00B59F4D /* SGPagingViewTests.swift in Sources */, 440 | ); 441 | runOnlyForDeploymentPostprocessing = 0; 442 | }; 443 | 8D173CE32763A5EB00B59F4D /* Sources */ = { 444 | isa = PBXSourcesBuildPhase; 445 | buildActionMask = 2147483647; 446 | files = ( 447 | 8D173CEC2763A5EB00B59F4D /* SGPagingViewUITests.swift in Sources */, 448 | 8D173CEE2763A5EB00B59F4D /* SGPagingViewUITestsLaunchTests.swift in Sources */, 449 | ); 450 | runOnlyForDeploymentPostprocessing = 0; 451 | }; 452 | /* End PBXSourcesBuildPhase section */ 453 | 454 | /* Begin PBXTargetDependency section */ 455 | 8D173CDF2763A5EB00B59F4D /* PBXTargetDependency */ = { 456 | isa = PBXTargetDependency; 457 | target = 8D173CC62763A5E700B59F4D /* SGPagingView */; 458 | targetProxy = 8D173CDE2763A5EB00B59F4D /* PBXContainerItemProxy */; 459 | }; 460 | 8D173CE92763A5EB00B59F4D /* PBXTargetDependency */ = { 461 | isa = PBXTargetDependency; 462 | target = 8D173CC62763A5E700B59F4D /* SGPagingView */; 463 | targetProxy = 8D173CE82763A5EB00B59F4D /* PBXContainerItemProxy */; 464 | }; 465 | /* End PBXTargetDependency section */ 466 | 467 | /* Begin PBXVariantGroup section */ 468 | 8D173CD02763A5E700B59F4D /* Main.storyboard */ = { 469 | isa = PBXVariantGroup; 470 | children = ( 471 | 8D173CD12763A5E700B59F4D /* Base */, 472 | ); 473 | name = Main.storyboard; 474 | sourceTree = ""; 475 | }; 476 | 8D173CD52763A5EB00B59F4D /* LaunchScreen.storyboard */ = { 477 | isa = PBXVariantGroup; 478 | children = ( 479 | 8D173CD62763A5EB00B59F4D /* Base */, 480 | ); 481 | name = LaunchScreen.storyboard; 482 | sourceTree = ""; 483 | }; 484 | /* End PBXVariantGroup section */ 485 | 486 | /* Begin XCBuildConfiguration section */ 487 | 8D173CEF2763A5EB00B59F4D /* Debug */ = { 488 | isa = XCBuildConfiguration; 489 | buildSettings = { 490 | ALWAYS_SEARCH_USER_PATHS = NO; 491 | CLANG_ANALYZER_NONNULL = YES; 492 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 493 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 494 | CLANG_CXX_LIBRARY = "libc++"; 495 | CLANG_ENABLE_MODULES = YES; 496 | CLANG_ENABLE_OBJC_ARC = YES; 497 | CLANG_ENABLE_OBJC_WEAK = YES; 498 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 499 | CLANG_WARN_BOOL_CONVERSION = YES; 500 | CLANG_WARN_COMMA = YES; 501 | CLANG_WARN_CONSTANT_CONVERSION = YES; 502 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 503 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 504 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 505 | CLANG_WARN_EMPTY_BODY = YES; 506 | CLANG_WARN_ENUM_CONVERSION = YES; 507 | CLANG_WARN_INFINITE_RECURSION = YES; 508 | CLANG_WARN_INT_CONVERSION = YES; 509 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 510 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 511 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 512 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 513 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 514 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 515 | CLANG_WARN_STRICT_PROTOTYPES = YES; 516 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 517 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 518 | CLANG_WARN_UNREACHABLE_CODE = YES; 519 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 520 | COPY_PHASE_STRIP = NO; 521 | DEBUG_INFORMATION_FORMAT = dwarf; 522 | ENABLE_STRICT_OBJC_MSGSEND = YES; 523 | ENABLE_TESTABILITY = YES; 524 | GCC_C_LANGUAGE_STANDARD = gnu11; 525 | GCC_DYNAMIC_NO_PIC = NO; 526 | GCC_NO_COMMON_BLOCKS = YES; 527 | GCC_OPTIMIZATION_LEVEL = 0; 528 | GCC_PREPROCESSOR_DEFINITIONS = ( 529 | "DEBUG=1", 530 | "$(inherited)", 531 | ); 532 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 533 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 534 | GCC_WARN_UNDECLARED_SELECTOR = YES; 535 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 536 | GCC_WARN_UNUSED_FUNCTION = YES; 537 | GCC_WARN_UNUSED_VARIABLE = YES; 538 | IPHONEOS_DEPLOYMENT_TARGET = 15.0; 539 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 540 | MTL_FAST_MATH = YES; 541 | ONLY_ACTIVE_ARCH = YES; 542 | SDKROOT = iphoneos; 543 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 544 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 545 | WARNING_CFLAGS = "-Wno-deprecated-declarations"; 546 | }; 547 | name = Debug; 548 | }; 549 | 8D173CF02763A5EB00B59F4D /* Release */ = { 550 | isa = XCBuildConfiguration; 551 | buildSettings = { 552 | ALWAYS_SEARCH_USER_PATHS = NO; 553 | CLANG_ANALYZER_NONNULL = YES; 554 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 555 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 556 | CLANG_CXX_LIBRARY = "libc++"; 557 | CLANG_ENABLE_MODULES = YES; 558 | CLANG_ENABLE_OBJC_ARC = YES; 559 | CLANG_ENABLE_OBJC_WEAK = YES; 560 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 561 | CLANG_WARN_BOOL_CONVERSION = YES; 562 | CLANG_WARN_COMMA = YES; 563 | CLANG_WARN_CONSTANT_CONVERSION = YES; 564 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 565 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 566 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 567 | CLANG_WARN_EMPTY_BODY = YES; 568 | CLANG_WARN_ENUM_CONVERSION = YES; 569 | CLANG_WARN_INFINITE_RECURSION = YES; 570 | CLANG_WARN_INT_CONVERSION = YES; 571 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 572 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 573 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 574 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 575 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 576 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 577 | CLANG_WARN_STRICT_PROTOTYPES = YES; 578 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 579 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 580 | CLANG_WARN_UNREACHABLE_CODE = YES; 581 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 582 | COPY_PHASE_STRIP = NO; 583 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 584 | ENABLE_NS_ASSERTIONS = NO; 585 | ENABLE_STRICT_OBJC_MSGSEND = YES; 586 | GCC_C_LANGUAGE_STANDARD = gnu11; 587 | GCC_NO_COMMON_BLOCKS = YES; 588 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 589 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 590 | GCC_WARN_UNDECLARED_SELECTOR = YES; 591 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 592 | GCC_WARN_UNUSED_FUNCTION = YES; 593 | GCC_WARN_UNUSED_VARIABLE = YES; 594 | IPHONEOS_DEPLOYMENT_TARGET = 15.0; 595 | MTL_ENABLE_DEBUG_INFO = NO; 596 | MTL_FAST_MATH = YES; 597 | SDKROOT = iphoneos; 598 | SWIFT_COMPILATION_MODE = wholemodule; 599 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 600 | VALIDATE_PRODUCT = YES; 601 | WARNING_CFLAGS = "-Wno-deprecated-declarations"; 602 | }; 603 | name = Release; 604 | }; 605 | 8D173CF22763A5EB00B59F4D /* Debug */ = { 606 | isa = XCBuildConfiguration; 607 | buildSettings = { 608 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 609 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 610 | CODE_SIGN_STYLE = Automatic; 611 | CURRENT_PROJECT_VERSION = 1; 612 | GENERATE_INFOPLIST_FILE = YES; 613 | INFOPLIST_FILE = SGPagingView/Info.plist; 614 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 615 | INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; 616 | INFOPLIST_KEY_UIMainStoryboardFile = Main; 617 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 618 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 619 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 620 | LD_RUNPATH_SEARCH_PATHS = ( 621 | "$(inherited)", 622 | "@executable_path/Frameworks", 623 | ); 624 | MARKETING_VERSION = 1.0; 625 | PRODUCT_BUNDLE_IDENTIFIER = com.SGPagingView; 626 | PRODUCT_NAME = "$(TARGET_NAME)"; 627 | SWIFT_EMIT_LOC_STRINGS = YES; 628 | SWIFT_VERSION = 5.0; 629 | TARGETED_DEVICE_FAMILY = "1,2"; 630 | WARNING_CFLAGS = "-Wno-unused-variable"; 631 | }; 632 | name = Debug; 633 | }; 634 | 8D173CF32763A5EB00B59F4D /* Release */ = { 635 | isa = XCBuildConfiguration; 636 | buildSettings = { 637 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 638 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 639 | CODE_SIGN_STYLE = Automatic; 640 | CURRENT_PROJECT_VERSION = 1; 641 | GENERATE_INFOPLIST_FILE = YES; 642 | INFOPLIST_FILE = SGPagingView/Info.plist; 643 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 644 | INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; 645 | INFOPLIST_KEY_UIMainStoryboardFile = Main; 646 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 647 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 648 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 649 | LD_RUNPATH_SEARCH_PATHS = ( 650 | "$(inherited)", 651 | "@executable_path/Frameworks", 652 | ); 653 | MARKETING_VERSION = 1.0; 654 | PRODUCT_BUNDLE_IDENTIFIER = com.SGPagingView; 655 | PRODUCT_NAME = "$(TARGET_NAME)"; 656 | SWIFT_EMIT_LOC_STRINGS = YES; 657 | SWIFT_VERSION = 5.0; 658 | TARGETED_DEVICE_FAMILY = "1,2"; 659 | WARNING_CFLAGS = "-Wno-unused-variable"; 660 | }; 661 | name = Release; 662 | }; 663 | 8D173CF52763A5EB00B59F4D /* Debug */ = { 664 | isa = XCBuildConfiguration; 665 | buildSettings = { 666 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 667 | BUNDLE_LOADER = "$(TEST_HOST)"; 668 | CODE_SIGN_STYLE = Automatic; 669 | CURRENT_PROJECT_VERSION = 1; 670 | GENERATE_INFOPLIST_FILE = YES; 671 | IPHONEOS_DEPLOYMENT_TARGET = 15.0; 672 | LD_RUNPATH_SEARCH_PATHS = ( 673 | "$(inherited)", 674 | "@executable_path/Frameworks", 675 | "@loader_path/Frameworks", 676 | ); 677 | MARKETING_VERSION = 1.0; 678 | PRODUCT_BUNDLE_IDENTIFIER = com.SGPagingViewTests; 679 | PRODUCT_NAME = "$(TARGET_NAME)"; 680 | SWIFT_EMIT_LOC_STRINGS = NO; 681 | SWIFT_VERSION = 5.0; 682 | TARGETED_DEVICE_FAMILY = "1,2"; 683 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SGPagingView.app/SGPagingView"; 684 | }; 685 | name = Debug; 686 | }; 687 | 8D173CF62763A5EB00B59F4D /* Release */ = { 688 | isa = XCBuildConfiguration; 689 | buildSettings = { 690 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 691 | BUNDLE_LOADER = "$(TEST_HOST)"; 692 | CODE_SIGN_STYLE = Automatic; 693 | CURRENT_PROJECT_VERSION = 1; 694 | GENERATE_INFOPLIST_FILE = YES; 695 | IPHONEOS_DEPLOYMENT_TARGET = 15.0; 696 | LD_RUNPATH_SEARCH_PATHS = ( 697 | "$(inherited)", 698 | "@executable_path/Frameworks", 699 | "@loader_path/Frameworks", 700 | ); 701 | MARKETING_VERSION = 1.0; 702 | PRODUCT_BUNDLE_IDENTIFIER = com.SGPagingViewTests; 703 | PRODUCT_NAME = "$(TARGET_NAME)"; 704 | SWIFT_EMIT_LOC_STRINGS = NO; 705 | SWIFT_VERSION = 5.0; 706 | TARGETED_DEVICE_FAMILY = "1,2"; 707 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SGPagingView.app/SGPagingView"; 708 | }; 709 | name = Release; 710 | }; 711 | 8D173CF82763A5EB00B59F4D /* Debug */ = { 712 | isa = XCBuildConfiguration; 713 | buildSettings = { 714 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 715 | CODE_SIGN_STYLE = Automatic; 716 | CURRENT_PROJECT_VERSION = 1; 717 | GENERATE_INFOPLIST_FILE = YES; 718 | LD_RUNPATH_SEARCH_PATHS = ( 719 | "$(inherited)", 720 | "@executable_path/Frameworks", 721 | "@loader_path/Frameworks", 722 | ); 723 | MARKETING_VERSION = 1.0; 724 | PRODUCT_BUNDLE_IDENTIFIER = com.SGPagingViewUITests; 725 | PRODUCT_NAME = "$(TARGET_NAME)"; 726 | SWIFT_EMIT_LOC_STRINGS = NO; 727 | SWIFT_VERSION = 5.0; 728 | TARGETED_DEVICE_FAMILY = "1,2"; 729 | TEST_TARGET_NAME = SGPagingView; 730 | }; 731 | name = Debug; 732 | }; 733 | 8D173CF92763A5EB00B59F4D /* Release */ = { 734 | isa = XCBuildConfiguration; 735 | buildSettings = { 736 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 737 | CODE_SIGN_STYLE = Automatic; 738 | CURRENT_PROJECT_VERSION = 1; 739 | GENERATE_INFOPLIST_FILE = YES; 740 | LD_RUNPATH_SEARCH_PATHS = ( 741 | "$(inherited)", 742 | "@executable_path/Frameworks", 743 | "@loader_path/Frameworks", 744 | ); 745 | MARKETING_VERSION = 1.0; 746 | PRODUCT_BUNDLE_IDENTIFIER = com.SGPagingViewUITests; 747 | PRODUCT_NAME = "$(TARGET_NAME)"; 748 | SWIFT_EMIT_LOC_STRINGS = NO; 749 | SWIFT_VERSION = 5.0; 750 | TARGETED_DEVICE_FAMILY = "1,2"; 751 | TEST_TARGET_NAME = SGPagingView; 752 | }; 753 | name = Release; 754 | }; 755 | /* End XCBuildConfiguration section */ 756 | 757 | /* Begin XCConfigurationList section */ 758 | 8D173CC22763A5E700B59F4D /* Build configuration list for PBXProject "SGPagingView" */ = { 759 | isa = XCConfigurationList; 760 | buildConfigurations = ( 761 | 8D173CEF2763A5EB00B59F4D /* Debug */, 762 | 8D173CF02763A5EB00B59F4D /* Release */, 763 | ); 764 | defaultConfigurationIsVisible = 0; 765 | defaultConfigurationName = Release; 766 | }; 767 | 8D173CF12763A5EB00B59F4D /* Build configuration list for PBXNativeTarget "SGPagingView" */ = { 768 | isa = XCConfigurationList; 769 | buildConfigurations = ( 770 | 8D173CF22763A5EB00B59F4D /* Debug */, 771 | 8D173CF32763A5EB00B59F4D /* Release */, 772 | ); 773 | defaultConfigurationIsVisible = 0; 774 | defaultConfigurationName = Release; 775 | }; 776 | 8D173CF42763A5EB00B59F4D /* Build configuration list for PBXNativeTarget "SGPagingViewTests" */ = { 777 | isa = XCConfigurationList; 778 | buildConfigurations = ( 779 | 8D173CF52763A5EB00B59F4D /* Debug */, 780 | 8D173CF62763A5EB00B59F4D /* Release */, 781 | ); 782 | defaultConfigurationIsVisible = 0; 783 | defaultConfigurationName = Release; 784 | }; 785 | 8D173CF72763A5EB00B59F4D /* Build configuration list for PBXNativeTarget "SGPagingViewUITests" */ = { 786 | isa = XCConfigurationList; 787 | buildConfigurations = ( 788 | 8D173CF82763A5EB00B59F4D /* Debug */, 789 | 8D173CF92763A5EB00B59F4D /* Release */, 790 | ); 791 | defaultConfigurationIsVisible = 0; 792 | defaultConfigurationName = Release; 793 | }; 794 | /* End XCConfigurationList section */ 795 | }; 796 | rootObject = 8D173CBF2763A5E700B59F4D /* Project object */; 797 | } 798 | -------------------------------------------------------------------------------- /SGPagingView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SGPagingView.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SGPagingView/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2021/12/10. 6 | // 7 | 8 | import UIKit 9 | 10 | @main 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | // Override point for customization after application launch. 17 | return true 18 | } 19 | 20 | // MARK: UISceneSession Lifecycle 21 | 22 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 23 | // Called when a new scene session is being created. 24 | // Use this method to select a configuration to create the new scene with. 25 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 26 | } 27 | 28 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 29 | // Called when the user discards a scene session. 30 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 31 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 32 | } 33 | 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /SGPagingView/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SGPagingView/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /SGPagingView/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /SGPagingView/Assets.xcassets/bg_image.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "filename" : "bg_image@2x.png", 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SGPagingView/Assets.xcassets/bg_image.imageset/bg_image@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kingsic/SGPagingView/275af731a41e0cc306ee91af044cf36c405350c4/SGPagingView/Assets.xcassets/bg_image.imageset/bg_image@2x.png -------------------------------------------------------------------------------- /SGPagingView/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /SGPagingView/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /SGPagingView/Example/AttributedVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SystemVC.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2020/12/29. 6 | // Copyright © 2020 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class AttributedVC: UIViewController { 12 | 13 | deinit { 14 | print("AttributedVC - deinit") 15 | } 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | // Do any additional setup after loading the view. 21 | view.backgroundColor = .green 22 | 23 | HY() 24 | 25 | addPagingView() 26 | } 27 | 28 | func HY() { 29 | // 提示语 30 | let lab: UILabel = UILabel() 31 | lab.frame = CGRect.init(x: 0, y: 110, width: UIScreen.width, height: 50) 32 | lab.text = "虎牙样式" 33 | lab.textAlignment = .center 34 | lab.font = .boldSystemFont(ofSize: 22) 35 | view.addSubview(lab) 36 | 37 | let configure = SGPagingTitleViewConfigure() 38 | configure.showBottomSeparator = false 39 | configure.font = .systemFont(ofSize: 13) 40 | 41 | let pty = lab.frame.maxY 42 | let ptw = view.frame.size.width * 4 / 5 43 | let pth: CGFloat = 44 44 | 45 | let frame = CGRect.init(x: 0, y: pty, width: ptw, height: pth) 46 | let titles = ["聊天", "主播", "排行", "贵宾"] 47 | let pagingTitle = SGPagingTitleView(frame: frame, titles: titles, configure: configure) 48 | view.addSubview(pagingTitle) 49 | 50 | // setAttributedTitle 51 | let ptStr = "贵宾(12138)" 52 | let ptAttriStr = NSMutableAttributedString(string: ptStr) 53 | let ptDict = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 11), NSAttributedString.Key.foregroundColor: UIColor.lightGray] 54 | let ptRange = NSMakeRange(2, ptStr.count - 2) 55 | ptAttriStr.addAttributes(ptDict, range: ptRange) 56 | 57 | let ptSAttriStr = NSMutableAttributedString(string: ptStr) 58 | let ptSDict = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 13), NSAttributedString.Key.foregroundColor: UIColor.red] 59 | let ptSSDict = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 11), NSAttributedString.Key.foregroundColor: UIColor.red] 60 | let ptSRange = NSMakeRange(0, 2) 61 | ptSAttriStr.addAttributes(ptSSDict, range: ptRange) 62 | ptSAttriStr.addAttributes(ptSDict, range: ptSRange) 63 | pagingTitle.setTitle(attributed: ptAttriStr, selectedAttributed: ptSAttriStr, index: 3) 64 | 65 | 66 | // rightBtn 67 | let rightBtn: UIButton = UIButton(type: .custom) 68 | rightBtn.frame = CGRect.init(x: pagingTitle.frame.maxX, y: pty, width: view.frame.size.width / 5, height: pth) 69 | rightBtn.backgroundColor = .orange 70 | rightBtn.setTitleColor(.white, for: .normal) 71 | rightBtn.titleLabel!.lineBreakMode = .byWordWrapping 72 | rightBtn.titleLabel?.textAlignment = .center 73 | rightBtn.titleLabel!.font = UIFont.systemFont(ofSize: 12) 74 | view.addSubview(rightBtn) 75 | 76 | let rightBtnText = "订阅\n520" 77 | let attriStr = NSMutableAttributedString(string: rightBtnText) 78 | let dict = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 17), NSAttributedString.Key.foregroundColor: UIColor.white] 79 | let range = NSMakeRange(0, 2) 80 | attriStr.addAttributes(dict, range: range) 81 | rightBtn.setAttributedTitle(attriStr, for: .normal) 82 | } 83 | 84 | 85 | func addPagingView() { 86 | view.addSubview(pagingTitleView) 87 | view.addSubview(pagingContentView) 88 | } 89 | 90 | lazy var pagingTitleView: SGPagingTitleView = { 91 | let configure = SGPagingTitleViewConfigure() 92 | configure.indicatorLocation = .Top 93 | configure.indicatorHeight = 5 94 | 95 | let frame = CGRect.init(x: 0, y: 220, width: UIScreen.width, height: 44) 96 | let titles = ["聊天", "主播", "排行", "贵宾"] 97 | let pagingTitle = SGPagingTitleView(frame: frame, titles: titles, configure: configure) 98 | pagingTitle.delegate = self 99 | 100 | let text = "订阅\n520" 101 | let attriStr = NSMutableAttributedString(string: text) 102 | let dict = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 17), NSAttributedString.Key.foregroundColor: UIColor.black] 103 | let range = NSMakeRange(0, 2) 104 | attriStr.addAttributes(dict, range: range) 105 | let dict2 = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 13), NSAttributedString.Key.foregroundColor: UIColor.black] 106 | let range2 = NSMakeRange(text.count - 3, 3) 107 | attriStr.addAttributes(dict2, range: range2) 108 | 109 | let selectedAttriStr = NSMutableAttributedString(string: text) 110 | let selectedDict = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 17), NSAttributedString.Key.foregroundColor: UIColor.red] 111 | let selectedRange = NSMakeRange(0, 2) 112 | selectedAttriStr.addAttributes(selectedDict, range: selectedRange) 113 | let selectedDict2 = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 13), NSAttributedString.Key.foregroundColor: UIColor.red] 114 | let selectedRange2 = NSMakeRange(text.count - 3, 3) 115 | selectedAttriStr.addAttributes(selectedDict2, range: selectedRange2) 116 | 117 | pagingTitle.setTitle(attributed: attriStr, selectedAttributed: selectedAttriStr, index: 3) 118 | 119 | let imageUrl = "https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png" 120 | pagingTitle.setBackgroundImage(name: imageUrl, selectedName: nil, index: 1) 121 | return pagingTitle 122 | }() 123 | 124 | lazy var pagingContentView: SGPagingContentScrollView = { 125 | let vc1 = UIViewController() 126 | vc1.view.backgroundColor = .orange 127 | let vc2 = UIViewController() 128 | vc2.view.backgroundColor = .purple 129 | let vc3 = UIViewController() 130 | vc3.view.backgroundColor = .blue 131 | let vc4 = UIViewController() 132 | vc4.view.backgroundColor = .brown 133 | let vcs = [vc1, vc2, vc3, vc4] 134 | 135 | let y: CGFloat = pagingTitleView.frame.maxY + 20 136 | let tempRect: CGRect = CGRect.init(x: 0, y: y, width: UIScreen.width, height: 200) 137 | let pagingContent = SGPagingContentScrollView(frame: tempRect, parentVC: self, childVCs: vcs) 138 | pagingContent.delegate = self 139 | pagingContent.isAnimated = true 140 | pagingContent.isBounces = true 141 | return pagingContent 142 | }() 143 | } 144 | 145 | extension AttributedVC: SGPagingTitleViewDelegate, SGPagingContentViewDelegate { 146 | func pagingTitleView(titleView: SGPagingTitleView, index: Int) { 147 | pagingContentView.setPagingContentView(index: index) 148 | } 149 | 150 | func pagingContentView(contentView: SGPagingContentView, progress: CGFloat, currentIndex: Int, targetIndex: Int) { 151 | pagingTitleView.setPagingTitleView(progress: progress, currentIndex: currentIndex, targetIndex: targetIndex) 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /SGPagingView/Example/BadgeVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BadgeVC.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2020/12/29. 6 | // Copyright © 2020 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class BadgeVC: UIViewController , SGPagingTitleViewDelegate, SGPagingContentViewDelegate { 12 | 13 | deinit { 14 | print("BadgeVC - deinit") 15 | } 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | // Do any additional setup after loading the view. 21 | view.backgroundColor = .black 22 | view.addSubview(pagingTitleView) 23 | view.addSubview(pagingContentView) 24 | } 25 | 26 | lazy var pagingTitleView: SGPagingTitleView = { 27 | let configure = SGPagingTitleViewConfigure() 28 | configure.badgeHeight = 10 29 | configure.indicatorScrollStyle = .End 30 | 31 | let frame = CGRect.init(x: 0, y: UIScreen.navBarHeight, width: UIScreen.width, height: 44) 32 | let titles = ["关注", "推荐", "热榜", "免费小说"] 33 | let pagingTitle = SGPagingTitleView(frame: frame, titles: titles, configure: configure) 34 | pagingTitle.delegate = self 35 | pagingTitle.addBadge(index: 1) 36 | pagingTitle.addBadge(text: "New", index: 2) 37 | return pagingTitle 38 | }() 39 | 40 | lazy var pagingContentView: SGPagingContentScrollView = { 41 | let vc1 = UIViewController() 42 | vc1.view.backgroundColor = .orange 43 | let vc2 = UIViewController() 44 | vc2.view.backgroundColor = .purple 45 | let vc3 = UIViewController() 46 | vc3.view.backgroundColor = .green 47 | let vc4 = UIViewController() 48 | vc4.view.backgroundColor = .brown 49 | let vcs = [vc1, vc2, vc3, vc4] 50 | 51 | let y: CGFloat = pagingTitleView.frame.maxY 52 | let tempRect: CGRect = CGRect.init(x: 0, y: y, width: UIScreen.width, height: UIScreen.height - y) 53 | let pagingContent = SGPagingContentScrollView(frame: tempRect, parentVC: self, childVCs: vcs) 54 | pagingContent.delegate = self 55 | return pagingContent 56 | }() 57 | 58 | 59 | func pagingTitleView(titleView: SGPagingTitleView, index: Int) { 60 | pagingContentView.setPagingContentView(index: index) 61 | } 62 | 63 | func pagingContentView(contentView: SGPagingContentView, progress: CGFloat, currentIndex: Int, targetIndex: Int) { 64 | pagingTitleView.setPagingTitleView(progress: progress, currentIndex: currentIndex, targetIndex: targetIndex) 65 | } 66 | 67 | func pagingContentView(index: Int) { 68 | if index == 1 { 69 | DispatchQueue.main.async { 70 | self.pagingTitleView.removeBadge(index: 1) 71 | } 72 | } else if index == 2 { 73 | DispatchQueue.main.async { 74 | self.pagingTitleView.removeBadge(index: 2) 75 | } 76 | } 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /SGPagingView/Example/CoverOneVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CoverOneVC.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2020/12/29. 6 | // Copyright © 2020 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CoverOneVC: UIViewController, SGPagingTitleViewDelegate, SGPagingContentViewDelegate { 12 | 13 | deinit { 14 | print("CoverOneVC - deinit") 15 | } 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | // Do any additional setup after loading the view. 21 | view.backgroundColor = .black 22 | view.addSubview(pagingTitleView) 23 | view.addSubview(pagingContentView) 24 | } 25 | 26 | lazy var pagingTitleView: SGPagingTitleView = { 27 | let configure = SGPagingTitleViewConfigure() 28 | configure.indicatorType = .Cover 29 | configure.indicatorHeight = 34 30 | configure.indicatorAdditionalWidth = 30 31 | configure.indicatorCornerRadius = 17 32 | configure.indicatorColor = .black 33 | configure.selectedColor = .white 34 | 35 | let frame = CGRect.init(x: 0, y: UIScreen.navBarHeight, width: UIScreen.width, height: 44) 36 | let titles = ["关注", "推荐", "热榜", "免费小说"] 37 | let pagingTitle = SGPagingTitleView(frame: frame, titles: titles, configure: configure) 38 | pagingTitle.delegate = self 39 | return pagingTitle 40 | }() 41 | 42 | lazy var pagingContentView: SGPagingContentScrollView = { 43 | let vc1 = UIViewController() 44 | vc1.view.backgroundColor = .orange 45 | let vc2 = UIViewController() 46 | vc2.view.backgroundColor = .purple 47 | let vc3 = UIViewController() 48 | vc3.view.backgroundColor = .green 49 | let vc4 = UIViewController() 50 | vc4.view.backgroundColor = .brown 51 | let vcs = [vc1, vc2, vc3, vc4] 52 | 53 | let y: CGFloat = pagingTitleView.frame.maxY 54 | let tempRect: CGRect = CGRect.init(x: 0, y: y, width: UIScreen.width, height: UIScreen.height - y) 55 | let pagingContent = SGPagingContentScrollView(frame: tempRect, parentVC: self, childVCs: vcs) 56 | pagingContent.delegate = self 57 | return pagingContent 58 | }() 59 | 60 | 61 | func pagingTitleView(titleView: SGPagingTitleView, index: Int) { 62 | pagingContentView.setPagingContentView(index: index) 63 | } 64 | 65 | func pagingContentView(contentView: SGPagingContentView, progress: CGFloat, currentIndex: Int, targetIndex: Int) { 66 | pagingTitleView.setPagingTitleView(progress: progress, currentIndex: currentIndex, targetIndex: targetIndex) 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /SGPagingView/Example/CoverTwoVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CoverTwoVC.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2020/12/29. 6 | // Copyright © 2020 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CoverTwoVC: UIViewController , SGPagingTitleViewDelegate, SGPagingContentViewDelegate { 12 | 13 | deinit { 14 | print("CoverTwoVC - deinit") 15 | } 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | // Do any additional setup after loading the view. 21 | view.backgroundColor = .white 22 | view.addSubview(pagingTitleView) 23 | view.addSubview(pagingContentView) 24 | } 25 | 26 | lazy var pagingTitleView: SGPagingTitleView = { 27 | let configure = SGPagingTitleViewConfigure() 28 | configure.showBottomSeparator = false 29 | configure.indicatorAnimationTime = 0.05 30 | configure.indicatorType = .Fixed // 由于 Cover 样式是随标题内容而变化的,而这里的指示器长度是固定的,所以使用 Fixed 样式再配置相关属性 31 | configure.indicatorHeight = 38 32 | configure.indicatorFixedWidth = (UIScreen.width - 60)/3 - 6 33 | configure.indicatorCornerRadius = 5 34 | configure.indicatorColor = .white 35 | configure.indicatorToBottomDistance = 3; 36 | configure.color = .lightGray 37 | configure.selectedColor = .black 38 | 39 | let frame = CGRect.init(x: 30, y: UIScreen.navBarHeight, width: UIScreen.width - 60, height: 44) 40 | let titles = ["下载列表", "上传列表", "保存至手机"] 41 | let pagingTitle = SGPagingTitleView(frame: frame, titles: titles, configure: configure) 42 | pagingTitle.layer.cornerRadius = 5 43 | pagingTitle.backgroundColor = UIColor.black.withAlphaComponent(0.07) 44 | pagingTitle.delegate = self 45 | return pagingTitle 46 | }() 47 | 48 | lazy var pagingContentView: SGPagingContentCollectionView = { 49 | let vc1 = UIViewController() 50 | vc1.view.backgroundColor = .orange 51 | let vc2 = UIViewController() 52 | vc2.view.backgroundColor = .purple 53 | let vc3 = UIViewController() 54 | vc3.view.backgroundColor = .green 55 | let vcs = [vc1, vc2, vc3] 56 | 57 | let y: CGFloat = pagingTitleView.frame.maxY 58 | let tempRect: CGRect = CGRect.init(x: 0, y: y, width: UIScreen.width, height: UIScreen.height - y) 59 | let pagingContent = SGPagingContentCollectionView(frame: tempRect, parentVC: self, childVCs: vcs) 60 | pagingContent.delegate = self 61 | return pagingContent 62 | }() 63 | 64 | 65 | func pagingTitleView(titleView: SGPagingTitleView, index: Int) { 66 | pagingContentView.setPagingContentView(index: index) 67 | } 68 | 69 | func pagingContentView(contentView: SGPagingContentView, progress: CGFloat, currentIndex: Int, targetIndex: Int) { 70 | pagingTitleView.setPagingTitleView(progress: progress, currentIndex: currentIndex, targetIndex: targetIndex) 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /SGPagingView/Example/FixedOneVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FixedOneVC.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2020/12/29. 6 | // Copyright © 2020 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class FixedOneVC: UIViewController, SGPagingTitleViewDelegate, SGPagingContentViewDelegate { 12 | 13 | deinit { 14 | print("FixedOneVC - deinit") 15 | } 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | // Do any additional setup after loading the view. 21 | view.backgroundColor = .black 22 | 23 | addPagingView() 24 | } 25 | 26 | var pagingTitleView: SGPagingTitleView! 27 | var pagingContentView: SGPagingContentScrollView! 28 | 29 | func addPagingView() { 30 | let configure = SGPagingTitleViewConfigure() 31 | configure.equivalence = false 32 | configure.additionalWidth = 37 33 | configure.selectedFont = .systemFont(ofSize: 17) 34 | 35 | let frame = CGRect.init(x: 0, y: UIScreen.navBarHeight, width: UIScreen 36 | .width, height: 44) 37 | let titles = ["滚动", "内容视图", "最左或最右", "回弹"] 38 | let pagingTitle = SGPagingTitleView(frame: frame, titles: titles, configure: configure) 39 | pagingTitle.delegate = self 40 | view.addSubview(pagingTitle) 41 | pagingTitleView = pagingTitle 42 | 43 | let vc1 = UIViewController() 44 | vc1.view.backgroundColor = .orange 45 | let vc2 = UIViewController() 46 | vc2.view.backgroundColor = .purple 47 | let vc3 = UIViewController() 48 | vc3.view.backgroundColor = .green 49 | let vc4 = UIViewController() 50 | vc4.view.backgroundColor = .brown 51 | let vcs = [vc1, vc2, vc3, vc4] 52 | 53 | let y: CGFloat = pagingTitle.frame.maxY 54 | let tempRect: CGRect = CGRect.init(x: 0, y: y, width: UIScreen.width, height: UIScreen.height - y) 55 | let pagingContent = SGPagingContentScrollView(frame: tempRect, parentVC: self, childVCs: vcs) 56 | pagingContent.delegate = self 57 | pagingContent.isBounces = true 58 | view.addSubview(pagingContent) 59 | pagingContentView = pagingContent 60 | } 61 | 62 | 63 | func pagingTitleView(titleView: SGPagingTitleView, index: Int) { 64 | pagingContentView.setPagingContentView(index: index) 65 | } 66 | 67 | func pagingContentView(contentView: SGPagingContentView, progress: CGFloat, currentIndex: Int, targetIndex: Int) { 68 | pagingTitleView.setPagingTitleView(progress: progress, currentIndex: currentIndex, targetIndex: targetIndex) 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /SGPagingView/Example/FixedTwoVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FixedTwoVC.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2020/12/29. 6 | // Copyright © 2020 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class FixedTwoVC: UIViewController, SGPagingTitleViewDelegate, SGPagingContentViewDelegate { 12 | 13 | deinit { 14 | print("FixedTwoVC - deinit") 15 | } 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | // Do any additional setup after loading the view. 21 | view.backgroundColor = .black 22 | view.addSubview(pagingTitleView) 23 | view.addSubview(pagingContentView) 24 | } 25 | 26 | lazy var pagingTitleView: SGPagingTitleView = { 27 | let configure = SGPagingTitleViewConfigure() 28 | 29 | let frame = CGRect.init(x: 0, y: UIScreen.navBarHeight, width: UIScreen.width, height: 44) 30 | let titles = ["点击", "标题", "内容", "动画切换"] 31 | let pagingTitle = SGPagingTitleView(frame: frame, titles: titles, configure: configure) 32 | pagingTitle.delegate = self 33 | return pagingTitle 34 | }() 35 | 36 | lazy var pagingContentView: SGPagingContentScrollView = { 37 | let vc1 = UIViewController() 38 | vc1.view.backgroundColor = .orange 39 | let vc2 = UIViewController() 40 | vc2.view.backgroundColor = .purple 41 | let vc3 = UIViewController() 42 | vc3.view.backgroundColor = .green 43 | let vc4 = UIViewController() 44 | vc4.view.backgroundColor = .brown 45 | let vcs = [vc1, vc2, vc3, vc4] 46 | 47 | let y: CGFloat = pagingTitleView.frame.maxY 48 | let tempRect: CGRect = CGRect.init(x: 0, y: y, width: UIScreen.width, height: UIScreen.height - y) 49 | let pagingContent = SGPagingContentScrollView(frame: tempRect, parentVC: self, childVCs: vcs) 50 | pagingContent.delegate = self 51 | pagingContent.isAnimated = true 52 | pagingContent.isBounces = true 53 | return pagingContent 54 | }() 55 | 56 | func pagingTitleView(titleView: SGPagingTitleView, index: Int) { 57 | pagingContentView.setPagingContentView(index: index) 58 | } 59 | 60 | func pagingContentView(contentView: SGPagingContentView, progress: CGFloat, currentIndex: Int, targetIndex: Int) { 61 | pagingTitleView.setPagingTitleView(progress: progress, currentIndex: currentIndex, targetIndex: targetIndex) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /SGPagingView/Example/GradientEffectVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // gradientEffectVC.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2020/12/29. 6 | // Copyright © 2020 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class GradientEffectVC: UIViewController, SGPagingTitleViewDelegate, SGPagingContentViewDelegate { 12 | 13 | deinit { 14 | print("gradientEffectVC - deinit") 15 | } 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | // Do any additional setup after loading the view. 21 | view.backgroundColor = .black 22 | view.addSubview(pagingTitleView) 23 | view.addSubview(pagingContentView) 24 | } 25 | 26 | lazy var pagingTitleView: SGPagingTitleView = { 27 | let configure = SGPagingTitleViewConfigure() 28 | configure.gradientEffect = true 29 | 30 | let frame = CGRect.init(x: 0, y: UIScreen.navBarHeight, width: UIScreen.width, height: 44) 31 | let titles = ["关注", "推荐", "热榜", "免费小说"] 32 | let pagingTitle = SGPagingTitleView(frame: frame, titles: titles, configure: configure) 33 | pagingTitle.delegate = self 34 | return pagingTitle 35 | }() 36 | 37 | lazy var pagingContentView: SGPagingContentScrollView = { 38 | let vc1 = UIViewController() 39 | vc1.view.backgroundColor = .orange 40 | let vc2 = UIViewController() 41 | vc2.view.backgroundColor = .purple 42 | let vc3 = UIViewController() 43 | vc3.view.backgroundColor = .green 44 | let vc4 = UIViewController() 45 | vc4.view.backgroundColor = .brown 46 | let vcs = [vc1, vc2, vc3, vc4] 47 | 48 | let y: CGFloat = pagingTitleView.frame.maxY 49 | let tempRect: CGRect = CGRect.init(x: 0, y: y, width: UIScreen.width, height: UIScreen.height - y) 50 | let pagingContent = SGPagingContentScrollView(frame: tempRect, parentVC: self, childVCs: vcs) 51 | pagingContent.delegate = self 52 | return pagingContent 53 | }() 54 | 55 | 56 | func pagingTitleView(titleView: SGPagingTitleView, index: Int) { 57 | pagingContentView.setPagingContentView(index: index) 58 | } 59 | 60 | func pagingContentView(contentView: SGPagingContentView, progress: CGFloat, currentIndex: Int, targetIndex: Int) { 61 | pagingTitleView.setPagingTitleView(progress: progress, currentIndex: currentIndex, targetIndex: targetIndex) 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /SGPagingView/Example/IDynamicVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IDynamicVC.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2020/12/29. 6 | // Copyright © 2020 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class IDynamicVC: UIViewController, SGPagingTitleViewDelegate, SGPagingContentViewDelegate { 12 | 13 | deinit { 14 | print("IDynamicVC - deinit") 15 | } 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | // Do any additional setup after loading the view. 21 | view.backgroundColor = .black 22 | view.addSubview(pagingTitleView) 23 | view.addSubview(pagingContentView) 24 | } 25 | 26 | lazy var pagingTitleView: SGPagingTitleView = { 27 | let configure = SGPagingTitleViewConfigure() 28 | configure.indicatorType = .Dynamic 29 | configure.indicatorScrollStyle = .Half 30 | 31 | let frame = CGRect.init(x: 0, y: UIScreen.navBarHeight, width: UIScreen.width, height: 44) 32 | let titles = ["关注", "推荐", "热榜", "免费小说"] 33 | let pagingTitle = SGPagingTitleView(frame: frame, titles: titles, configure: configure) 34 | pagingTitle.delegate = self 35 | return pagingTitle 36 | }() 37 | 38 | lazy var pagingContentView: SGPagingContentScrollView = { 39 | let vc1 = UIViewController() 40 | vc1.view.backgroundColor = .orange 41 | let vc2 = UIViewController() 42 | vc2.view.backgroundColor = .purple 43 | let vc3 = UIViewController() 44 | vc3.view.backgroundColor = .green 45 | let vc4 = UIViewController() 46 | vc4.view.backgroundColor = .brown 47 | let vcs = [vc1, vc2, vc3, vc4] 48 | 49 | let y: CGFloat = pagingTitleView.frame.maxY 50 | let tempRect: CGRect = CGRect.init(x: 0, y: y, width: UIScreen.width, height: UIScreen.height - y) 51 | let pagingContent = SGPagingContentScrollView(frame: tempRect, parentVC: self, childVCs: vcs) 52 | pagingContent.delegate = self 53 | return pagingContent 54 | }() 55 | 56 | 57 | func pagingTitleView(titleView: SGPagingTitleView, index: Int) { 58 | pagingContentView.setPagingContentView(index: index) 59 | } 60 | 61 | func pagingContentView(contentView: SGPagingContentView, progress: CGFloat, currentIndex: Int, targetIndex: Int) { 62 | pagingTitleView.setPagingTitleView(progress: progress, currentIndex: currentIndex, targetIndex: targetIndex) 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /SGPagingView/Example/IFixedVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IFixedVC.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2020/12/29. 6 | // Copyright © 2020 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class IFixedVC: UIViewController, SGPagingTitleViewDelegate, SGPagingContentViewDelegate { 12 | 13 | deinit { 14 | print("IFixedVC - deinit") 15 | } 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | // Do any additional setup after loading the view. 21 | view.backgroundColor = .black 22 | view.addSubview(pagingTitleView) 23 | view.addSubview(pagingContentView) 24 | } 25 | 26 | lazy var pagingTitleView: SGPagingTitleView = { 27 | let configure = SGPagingTitleViewConfigure() 28 | configure.indicatorType = .Fixed 29 | configure.indicatorScrollStyle = .End 30 | configure.indicatorHeight = 3 31 | 32 | let frame = CGRect.init(x: 0, y: UIScreen.navBarHeight, width: UIScreen.width, height: 44) 33 | let titles = ["关注", "推荐", "热榜", "免费小说"] 34 | let pagingTitle = SGPagingTitleView(frame: frame, titles: titles, configure: configure) 35 | pagingTitle.delegate = self 36 | pagingTitle.backgroundColor = .white 37 | return pagingTitle 38 | }() 39 | 40 | lazy var pagingContentView: SGPagingContentScrollView = { 41 | let vc1 = UIViewController() 42 | vc1.view.backgroundColor = .purple 43 | let vc2 = UIViewController() 44 | vc2.view.backgroundColor = .red 45 | let vc3 = UIViewController() 46 | vc3.view.backgroundColor = .green 47 | let vc4 = UIViewController() 48 | vc4.view.backgroundColor = .brown 49 | let vcs = [vc1, vc2, vc3, vc4] 50 | 51 | let y: CGFloat = pagingTitleView.frame.maxY 52 | let tempRect: CGRect = CGRect.init(x: 0, y: y, width: UIScreen.width, height: UIScreen.height - y) 53 | let pagingContent = SGPagingContentScrollView(frame: tempRect, parentVC: self, childVCs: vcs) 54 | pagingContent.delegate = self 55 | return pagingContent 56 | }() 57 | 58 | 59 | func pagingTitleView(titleView: SGPagingTitleView, index: Int) { 60 | pagingContentView.setPagingContentView(index: index) 61 | } 62 | 63 | func pagingContentView(contentView: SGPagingContentView, progress: CGFloat, currentIndex: Int, targetIndex: Int) { 64 | pagingTitleView.setPagingTitleView(progress: progress, currentIndex: currentIndex, targetIndex: targetIndex) 65 | } 66 | 67 | func pagingContentView(index: Int) { 68 | if index == 1 { 69 | pagingTitleView.backgroundColor = .black 70 | pagingTitleView.resetTitle(color: .white, selectedColor: .white) 71 | pagingTitleView.resetIndicator(color: .white) 72 | } else { 73 | pagingTitleView.backgroundColor = .white 74 | pagingTitleView.resetTitle(color: .black, selectedColor: .red) 75 | pagingTitleView.resetIndicator(color: .red) 76 | } 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /SGPagingView/Example/ScrollVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScrollVC.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2020/12/29. 6 | // Copyright © 2020 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ScrollVC: UIViewController, SGPagingTitleViewDelegate, SGPagingContentViewDelegate { 12 | 13 | deinit { 14 | print("ScrollVC - deinit") 15 | } 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | // Do any additional setup after loading the view. 21 | view.backgroundColor = .black 22 | view.addSubview(pagingTitleView) 23 | view.addSubview(pagingContentView) 24 | } 25 | 26 | lazy var pagingTitleView: SGPagingTitleView = { 27 | let configure = SGPagingTitleViewConfigure() 28 | configure.indicatorScrollStyle = .Half 29 | configure.indicatorType = .Dynamic 30 | 31 | let frame = CGRect.init(x: 0, y: UIScreen.navBarHeight, width: UIScreen.width, height: 44) 32 | let titles = ["关注", "推荐", "热榜", "免费小说", "财经", "问答", "科技", "要闻"] 33 | let pagingTitle = SGPagingTitleView(frame: frame, titles: titles, configure: configure) 34 | pagingTitle.delegate = self 35 | pagingTitle.index = 1 36 | return pagingTitle 37 | }() 38 | 39 | lazy var pagingContentView: SGPagingContentCollectionView = { 40 | let vc1 = UIViewController() 41 | vc1.view.backgroundColor = .orange 42 | let vc2 = UIViewController() 43 | vc2.view.backgroundColor = .purple 44 | let vc3 = UIViewController() 45 | vc3.view.backgroundColor = .green 46 | let vc4 = UIViewController() 47 | vc4.view.backgroundColor = .brown 48 | let vc5 = UIViewController() 49 | vc5.view.backgroundColor = .yellow 50 | let vc6 = UIViewController() 51 | vc6.view.backgroundColor = .orange 52 | let vc7 = UIViewController() 53 | vc7.view.backgroundColor = .green 54 | let vc8 = UIViewController() 55 | vc8.view.backgroundColor = .brown 56 | let vcs = [vc1, vc2, vc3, vc4, vc5, vc6, vc7, vc8] 57 | 58 | let y: CGFloat = pagingTitleView.frame.maxY 59 | let tempRect: CGRect = CGRect.init(x: 0, y: y, width: UIScreen.width, height: UIScreen.height - y) 60 | let pagingContent = SGPagingContentCollectionView(frame: tempRect, parentVC: self, childVCs: vcs) 61 | pagingContent.delegate = self 62 | pagingContent.isBounces = true 63 | return pagingContent 64 | }() 65 | 66 | 67 | func pagingTitleView(titleView: SGPagingTitleView, index: Int) { 68 | pagingContentView.setPagingContentView(index: index) 69 | } 70 | 71 | func pagingContentView(contentView: SGPagingContentView, progress: CGFloat, currentIndex: Int, targetIndex: Int) { 72 | pagingTitleView.setPagingTitleView(progress: progress, currentIndex: currentIndex, targetIndex: targetIndex) 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /SGPagingView/Example/Suspension/BaseSubVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BaseSubVC.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2021/10/20. 6 | // Copyright © 2021 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class BaseSubVC: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | /// 监听主视图发出的通知 17 | NotificationCenter.default.addObserver(self, selector: #selector(pageTitleViewToTop), name: NSNotification.Name(NNLesstMainHeaderViewHeight), object: nil) 18 | } 19 | 20 | var subScrollView: UIScrollView? 21 | 22 | func subScrollViewDidScroll(_ scrollView: UIScrollView) { 23 | subScrollView = scrollView 24 | 25 | NotificationCenter.default.post(name: NSNotification.Name(NNSubScrollViewDidScroll), object: scrollView) 26 | } 27 | 28 | @objc func pageTitleViewToTop() { 29 | subScrollView?.contentOffset = .zero 30 | } 31 | 32 | deinit { 33 | print("BaseSubVC") 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /SGPagingView/Example/Suspension/BaseTableView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BaseTableView.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2021/10/20. 6 | // Copyright © 2021 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | /// 监听子视图滚动方法名 12 | let NNSubScrollViewDidScroll = "NNSubScrollViewDidScroll" 13 | /// 监听主视图滚动方法名 14 | let NNLesstMainHeaderViewHeight = "NNLesstMainHeaderViewHeight" 15 | /// 监听子视图左右滚动方法名 16 | let NNSubScrollViewLRScroll = "NNSubScrollViewLRScroll" 17 | 18 | class BaseTableView: UITableView, UIGestureRecognizerDelegate { 19 | override init(frame: CGRect, style: UITableView.Style) { 20 | super.init(frame: frame, style: style) 21 | 22 | NotificationCenter.default.addObserver(self, selector: #selector(subScrollViewLRScroll), name: NSNotification.Name(NNSubScrollViewLRScroll), object: nil) 23 | } 24 | 25 | required init?(coder: NSCoder) { 26 | fatalError("init(coder:) has not been implemented") 27 | } 28 | 29 | var tempLRScroll: Bool = true 30 | @objc func subScrollViewLRScroll(noti: Notification) { 31 | tempLRScroll = noti.object as! Bool 32 | } 33 | 34 | func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { 35 | if tempLRScroll == false { 36 | return false 37 | } 38 | return true 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /SGPagingView/Example/Suspension/SubTitleVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SubTitleVC.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2021/10/20. 6 | // Copyright © 2021 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SubTitleVC: BaseSubVC { 12 | 13 | lazy var tableView: UITableView = { 14 | let tempTableView = UITableView(frame: CGRect(origin: .zero, size: CGSize(width: view.frame.size.width, height: view.frame.size.height - UIScreen.statusBarHeight - 44 - 44)), style: .plain) 15 | tempTableView.delegate = self 16 | tempTableView.dataSource = self 17 | tempTableView.register(UITableViewCell.self, forCellReuseIdentifier: "cellID") 18 | return tempTableView 19 | }() 20 | 21 | override func viewDidLoad() { 22 | super.viewDidLoad() 23 | // Do any additional setup after loading the view. 24 | 25 | view.addSubview(tableView) 26 | } 27 | 28 | } 29 | 30 | extension SubTitleVC: UITableViewDelegate { 31 | func scrollViewDidScroll(_ scrollView: UIScrollView) { 32 | subScrollViewDidScroll(scrollView) 33 | } 34 | } 35 | 36 | extension SubTitleVC: UITableViewDataSource { 37 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 38 | 7 39 | } 40 | 41 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 42 | let cell = tableView.dequeueReusableCell(withIdentifier: "cellID", for: indexPath) 43 | cell.textLabel?.text = "第 \(indexPath.row) 行" 44 | return cell 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /SGPagingView/Example/Suspension/SubVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SubVC.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2021/10/20. 6 | // Copyright © 2021 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SubVC: BaseSubVC { 12 | 13 | lazy var tableView: UITableView = { 14 | let tempTableView = UITableView(frame: CGRect(origin: .zero, size: CGSize(width: view.frame.size.width, height: view.frame.size.height - UIScreen.statusBarHeight - 44 - 44)), style: .plain) 15 | tempTableView.delegate = self 16 | tempTableView.dataSource = self 17 | tempTableView.register(UITableViewCell.self, forCellReuseIdentifier: "cellID") 18 | return tempTableView 19 | }() 20 | 21 | override func viewDidLoad() { 22 | super.viewDidLoad() 23 | // Do any additional setup after loading the view. 24 | 25 | view.addSubview(tableView) 26 | } 27 | 28 | } 29 | 30 | extension SubVC: UITableViewDelegate { 31 | func scrollViewDidScroll(_ scrollView: UIScrollView) { 32 | subScrollViewDidScroll(scrollView) 33 | } 34 | } 35 | 36 | extension SubVC: UITableViewDataSource { 37 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 38 | 37 39 | } 40 | 41 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 42 | let cell = tableView.dequeueReusableCell(withIdentifier: "cellID", for: indexPath) 43 | if indexPath.row % 2 == 0 { 44 | cell.backgroundColor = .green 45 | } else { 46 | cell.backgroundColor = .orange 47 | } 48 | return cell 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /SGPagingView/Example/Suspension/SuspensionVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SuspensionVC.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2021/10/20. 6 | // Copyright © 2021 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | let headerViewHeight: CGFloat = 200 12 | 13 | class SuspensionVC: UIViewController { 14 | 15 | lazy var tableView: BaseTableView = { 16 | let tempTableView = BaseTableView(frame: CGRect(origin: CGPoint(x: 0, y: UIScreen.statusBarHeight + 44), size: view.frame.size), style: .plain) 17 | tempTableView.delegate = self 18 | tempTableView.dataSource = self 19 | tempTableView.register(UITableViewCell.self, forCellReuseIdentifier: "cellID") 20 | let tempView = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: headerViewHeight)) 21 | tempView.backgroundColor = .red 22 | let btn = UIButton(type: .custom) 23 | btn.backgroundColor = .black 24 | let btn_width: CGFloat = 200 25 | btn.frame = CGRect(origin: CGPoint(x: (view.frame.size.width - btn_width) * 0.5, y: headerViewHeight - 100), size: CGSize(width: btn_width, height: btn_width * 0.25)) 26 | btn.layer.cornerRadius = 10 27 | btn.setTitle("You know?I can click", for: .normal) 28 | btn.addTarget(self, action: #selector(btn_action), for: .touchUpInside) 29 | tempView.addSubview(btn) 30 | tempTableView.tableHeaderView = tempView 31 | return tempTableView 32 | }() 33 | 34 | @objc func btn_action() { 35 | print("btn_action") 36 | } 37 | 38 | lazy var pagingTitleView: SGPagingTitleView = { 39 | let configure = SGPagingTitleViewConfigure() 40 | configure.color = .lightGray 41 | configure.selectedColor = .black 42 | configure.indicatorType = .Dynamic 43 | configure.indicatorColor = .orange 44 | configure.showBottomSeparator = false 45 | 46 | let x: CGFloat = 70 47 | let frame = CGRect.init(x: x, y: 0, width: view.frame.size.width - 2 * x, height: 44) 48 | let titles = ["精选", "微博", "相册"] 49 | let pagingTitle = SGPagingTitleView(frame: frame, titles: titles, configure: configure) 50 | pagingTitle.delegate = self 51 | return pagingTitle 52 | }() 53 | 54 | lazy var pagingContentView: SGPagingContentScrollView = { 55 | let vc1 = SubVC() 56 | vc1.view.backgroundColor = .orange 57 | let vc2 = SubTitleVC() 58 | vc2.view.backgroundColor = .purple 59 | let vc3 = SubVC() 60 | vc3.view.backgroundColor = .green 61 | let vcs = [vc1, vc2, vc3] 62 | 63 | let y: CGFloat = pagingTitleView.frame.maxY 64 | let tempRect: CGRect = CGRect.init(x: 0, y: y, width: view.frame.size.width, height: view.frame.size.height - y) 65 | let pagingContent = SGPagingContentScrollView(frame: tempRect, parentVC: self, childVCs: vcs) 66 | pagingContent.delegate = self 67 | pagingContent.isBounces = true 68 | return pagingContent 69 | }() 70 | 71 | override func viewDidLoad() { 72 | super.viewDidLoad() 73 | // Do any additional setup after loading the view. 74 | view.backgroundColor = .white 75 | 76 | view.addSubview(tableView) 77 | 78 | // 监听子视图发出的通知 79 | NotificationCenter.default.addObserver(self, selector: #selector(subTableViewDidScroll), name: NSNotification.Name(NNSubScrollViewDidScroll), object: nil) 80 | } 81 | 82 | var tempSubScrollView: UIScrollView? 83 | 84 | deinit { 85 | print("SuspensionVC") 86 | } 87 | } 88 | 89 | extension SuspensionVC { 90 | @objc func subTableViewDidScroll(noti: Notification) { 91 | let scrollVeiw = noti.object as! UIScrollView 92 | tempSubScrollView = scrollVeiw 93 | if tableView.contentOffset.y < headerViewHeight { 94 | scrollVeiw.contentOffset = .zero 95 | } 96 | } 97 | } 98 | 99 | extension SuspensionVC: UITableViewDelegate { 100 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 101 | return view.frame.size.height 102 | } 103 | 104 | func scrollViewDidScroll(_ scrollView: UIScrollView) { 105 | if tableView == scrollView { 106 | if (tempSubScrollView != nil && (tempSubScrollView?.contentOffset.y)! > 0) || scrollView.contentOffset.y > headerViewHeight { 107 | tableView.contentOffset = CGPoint(x: 0, y: headerViewHeight) 108 | } 109 | 110 | let offSetY = scrollView.contentOffset.y 111 | if offSetY < headerViewHeight { 112 | NotificationCenter.default.post(name: NSNotification.Name(NNLesstMainHeaderViewHeight), object: nil) 113 | } 114 | } 115 | } 116 | 117 | } 118 | 119 | extension SuspensionVC: UITableViewDataSource { 120 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 121 | 1 122 | } 123 | 124 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 125 | let cell = tableView.dequeueReusableCell(withIdentifier: "cellID", for: indexPath) 126 | cell.contentView.addSubview(pagingTitleView) 127 | cell.contentView.addSubview(pagingContentView) 128 | cell.selectionStyle = .none 129 | return cell 130 | } 131 | } 132 | 133 | extension SuspensionVC: SGPagingTitleViewDelegate, SGPagingContentViewDelegate { 134 | func pagingTitleView(titleView: SGPagingTitleView, index: Int) { 135 | pagingContentView.setPagingContentView(index: index) 136 | } 137 | 138 | func pagingContentView(contentView: SGPagingContentView, progress: CGFloat, currentIndex: Int, targetIndex: Int) { 139 | pagingTitleView.setPagingTitleView(progress: progress, currentIndex: currentIndex, targetIndex: targetIndex) 140 | } 141 | 142 | func pagingContentViewWillBeginDragging() { 143 | // 内容子视图开始滚动时,不让父视图 tableView 支持多手势 144 | NotificationCenter.default.post(name: NSNotification.Name(NNSubScrollViewLRScroll), object: false) 145 | } 146 | func pagingContentViewDidEndDecelerating() { 147 | // 内容子视图结束滚动时,让其父视图 tableView 支持多手势 148 | NotificationCenter.default.post(name: NSNotification.Name(NNSubScrollViewLRScroll), object: true) 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /SGPagingView/Example/SuspensionPro/BaseSubProVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BaseSubProVC.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2021/10/20. 6 | // Copyright © 2021 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | /// 监听子视图滚动方法名 12 | let NNProSubScrollViewDidScroll = "NNProSubScrollViewDidScroll" 13 | 14 | let pro_subScrollViewContentOffsetY: CGFloat = pro_headerViewHeight + pro_pagingTitleViewHeight 15 | 16 | class BaseSubProVC: UIViewController { 17 | 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | 21 | } 22 | 23 | /// 标记子 scrollView 24 | public var scrollView: UIScrollView? 25 | 26 | /// 标记子 scrollView 的 contentOffset 27 | fileprivate var scrollViewContentOffset: CGPoint = .zero 28 | 29 | /// 供子类调用 30 | func subScrollViewDidScroll(_ scrollView: UIScrollView) { 31 | self.scrollView = scrollView 32 | 33 | // 子 scrollView 的偏移量差值 34 | let offsetDifference = scrollView.contentOffset.y - scrollViewContentOffset.y 35 | 36 | let tempUserInfo: [String : Any] = ["scrollingScrollView": scrollView, "offsetDifference": offsetDifference] 37 | // 子 scrollVIew 滚动时,发通知告诉主控制器 38 | NotificationCenter.default.post(name: NSNotification.Name(NNProSubScrollViewDidScroll), object: scrollView, userInfo: tempUserInfo) 39 | 40 | // 标记子 scrollVIew 的 contentOffset 41 | scrollViewContentOffset = scrollView.contentOffset 42 | } 43 | 44 | deinit { 45 | print("BaseSubProVC") 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /SGPagingView/Example/SuspensionPro/SubProVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SubProVC.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2021/10/20. 6 | // Copyright © 2021 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | //import MJRefresh 11 | 12 | class SubProVC: BaseSubProVC { 13 | 14 | lazy var tableView: UITableView = { 15 | let tempTableView = UITableView(frame: CGRect(origin: .zero, size: CGSize(width: view.frame.size.width, height: view.frame.size.height)), style: .plain) 16 | tempTableView.delegate = self 17 | tempTableView.dataSource = self 18 | tempTableView.register(UITableViewCell.self, forCellReuseIdentifier: "cellID") 19 | tempTableView.contentInset = UIEdgeInsets(top: pro_subScrollViewContentOffsetY, left: 0, bottom: 0, right: 0) 20 | return tempTableView 21 | }() 22 | 23 | override func viewDidLoad() { 24 | super.viewDidLoad() 25 | // Do any additional setup after loading the view. 26 | 27 | view.addSubview(tableView) 28 | 29 | if #available(iOS 11.0, *) { 30 | self.tableView.contentInsetAdjustmentBehavior = .never 31 | } else { 32 | self.automaticallyAdjustsScrollViewInsets = false 33 | } 34 | 35 | // addRefresh() 36 | } 37 | 38 | } 39 | 40 | extension SubProVC { 41 | // func addRefresh() { 42 | // tableView.mj_header = MJRefreshNormalHeader(refreshingTarget: self, refreshingAction: #selector(header_refresh)) 43 | // } 44 | // @objc func header_refresh() { 45 | // DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Double(2)) { [self] in 46 | // tableView.mj_header?.endRefreshing() 47 | // } 48 | // } 49 | } 50 | 51 | extension SubProVC: UITableViewDelegate { 52 | func scrollViewDidScroll(_ scrollView: UIScrollView) { 53 | subScrollViewDidScroll(scrollView) 54 | } 55 | } 56 | 57 | extension SubProVC: UITableViewDataSource { 58 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 59 | 37 60 | } 61 | 62 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 63 | let cell = tableView.dequeueReusableCell(withIdentifier: "cellID", for: indexPath) 64 | if indexPath.row % 2 == 0 { 65 | cell.backgroundColor = .green 66 | } else { 67 | cell.backgroundColor = .orange 68 | } 69 | return cell 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /SGPagingView/Example/SuspensionPro/SubTitleProVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SubTitleProVC.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2021/10/20. 6 | // Copyright © 2021 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | //import MJRefresh 11 | 12 | class SubTitleProVC: BaseSubProVC { 13 | 14 | lazy var tableView: UITableView = { 15 | let tempTableView = UITableView(frame: CGRect(origin: .zero, size: CGSize(width: view.frame.size.width, height: view.frame.size.height)), style: .plain) 16 | tempTableView.delegate = self 17 | tempTableView.dataSource = self 18 | tempTableView.register(UITableViewCell.self, forCellReuseIdentifier: "cellID") 19 | tempTableView.contentInset = UIEdgeInsets(top: pro_subScrollViewContentOffsetY, left: 0, bottom: 0, right: 0) 20 | return tempTableView 21 | }() 22 | 23 | override func viewDidLoad() { 24 | super.viewDidLoad() 25 | // Do any additional setup after loading the view. 26 | 27 | view.addSubview(tableView) 28 | 29 | if #available(iOS 11.0, *) { 30 | self.tableView.contentInsetAdjustmentBehavior = .never; 31 | } else { 32 | self.automaticallyAdjustsScrollViewInsets = false 33 | } 34 | 35 | // addRefresh() 36 | } 37 | 38 | } 39 | 40 | extension SubTitleProVC { 41 | // func addRefresh() { 42 | // tableView.mj_header = MJRefreshNormalHeader(refreshingTarget: self, refreshingAction: #selector(header_refresh)) 43 | // } 44 | // @objc func header_refresh() { 45 | // DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Double(2)) { [self] in 46 | // tableView.mj_header?.endRefreshing() 47 | // } 48 | // } 49 | } 50 | 51 | extension SubTitleProVC: UITableViewDelegate { 52 | func scrollViewDidScroll(_ scrollView: UIScrollView) { 53 | subScrollViewDidScroll(scrollView) 54 | } 55 | } 56 | 57 | extension SubTitleProVC: UITableViewDataSource { 58 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 59 | 7 60 | } 61 | 62 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 63 | let cell = tableView.dequeueReusableCell(withIdentifier: "cellID", for: indexPath) 64 | cell.textLabel?.text = "第 \(indexPath.row) 行" 65 | return cell 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /SGPagingView/Example/SuspensionPro/SuspensionProVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SuspensionProVC.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2021/10/20. 6 | // Copyright © 2021 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | let pro_headerViewHeight: CGFloat = 270 12 | let pro_pagingTitleViewHeight: CGFloat = 40 13 | 14 | let navHeight: CGFloat = 44 + UIScreen.statusBarHeight 15 | 16 | class SuspensionProVC: UIViewController { 17 | 18 | lazy var pagingTitleView: SGPagingTitleView = { 19 | let configure = SGPagingTitleViewConfigure() 20 | configure.color = .lightGray 21 | configure.selectedColor = .black 22 | configure.indicatorType = .Dynamic 23 | configure.indicatorColor = .orange 24 | configure.showBottomSeparator = false 25 | 26 | let frame = CGRect.init(x: 0, y: pro_headerViewHeight, width: view.frame.size.width, height: pro_pagingTitleViewHeight) 27 | let titles = ["精选", "微博", "相册"] 28 | let pagingTitle = SGPagingTitleView(frame: frame, titles: titles, configure: configure) 29 | pagingTitle.delegate = self 30 | return pagingTitle 31 | }() 32 | 33 | var tempBaseSubVCs: [BaseSubProVC] = [] 34 | 35 | lazy var pagingContentView: SGPagingContentScrollView = { 36 | let vc1 = SubProVC() 37 | let vc2 = SubTitleProVC() 38 | let vc3 = SubProVC() 39 | let vcs = [vc1, vc2, vc3] 40 | tempBaseSubVCs = vcs 41 | 42 | let tempRect: CGRect = CGRect.init(x: 0, y: 0, width: view.frame.size.width, height: view.frame.size.height) 43 | let pagingContent = SGPagingContentScrollView(frame: tempRect, parentVC: self, childVCs: vcs) 44 | pagingContent.delegate = self 45 | return pagingContent 46 | }() 47 | 48 | lazy var headerView: UIView = { 49 | let headerView: UIView = UIView() 50 | headerView.backgroundColor = .red 51 | headerView.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: pro_headerViewHeight) 52 | let pan = UIPanGestureRecognizer(target: self, action: #selector(pan_action)) 53 | headerView.addGestureRecognizer(pan) 54 | let btn = UIButton(type: .custom) 55 | let btn_width: CGFloat = 200 56 | let btn_x = 0.5 * (view.frame.width - btn_width) 57 | btn.frame = CGRect(x: btn_x, y: pro_headerViewHeight - 100, width: btn_width, height: 50) 58 | btn.layer.cornerRadius = 10 59 | btn.backgroundColor = .black 60 | btn.setTitle("You know?I can click", for: .normal) 61 | btn.addTarget(self, action: #selector(temp_btn_action), for: .touchUpInside) 62 | headerView.addSubview(btn) 63 | return headerView 64 | }() 65 | 66 | override func viewDidLoad() { 67 | super.viewDidLoad() 68 | // Do any additional setup after loading the view. 69 | view.backgroundColor = .white 70 | 71 | view.addSubview(UIView()) 72 | view.addSubview(pagingContentView) 73 | view.addSubview(headerView) 74 | view.addSubview(pagingTitleView) 75 | 76 | tempLastPagingTitleViewY = pro_headerViewHeight 77 | 78 | // 监听子视图发出的通知 79 | NotificationCenter.default.addObserver(self, selector: #selector(subTableViewDidScroll), name: NSNotification.Name(NNProSubScrollViewDidScroll), object: nil) 80 | } 81 | 82 | var tempSubScrollView: UIScrollView? 83 | var tempLastPagingTitleViewY: CGFloat = 0 84 | var tempLastPoint: CGPoint = .zero 85 | 86 | deinit { 87 | print("SuspensionProVC") 88 | } 89 | } 90 | 91 | extension SuspensionProVC { 92 | @objc func pan_action(pan: UIPanGestureRecognizer) { 93 | if pan.state == .began { 94 | 95 | } else if pan.state == .changed { 96 | let currenrPoint: CGPoint = pan.translation(in: pan.view) 97 | let distanceY = currenrPoint.y - tempLastPoint.y 98 | tempLastPoint = currenrPoint 99 | let baseSubVC = tempBaseSubVCs[pagingTitleView.index] 100 | var contentOffset: CGPoint = baseSubVC.scrollView!.contentOffset 101 | contentOffset.y += -distanceY 102 | if contentOffset.y <= -pro_subScrollViewContentOffsetY { 103 | contentOffset.y = -pro_subScrollViewContentOffsetY 104 | } 105 | baseSubVC.scrollView?.contentOffset = contentOffset 106 | } else { 107 | pan.setTranslation(.zero, in: pan.view) 108 | tempLastPoint = .zero 109 | } 110 | } 111 | } 112 | 113 | extension SuspensionProVC { 114 | @objc func subTableViewDidScroll(noti: Notification) { 115 | let scrollingScrollView = noti.userInfo!["scrollingScrollView"] as! UIScrollView 116 | let offsetDifference: CGFloat = noti.userInfo!["offsetDifference"] as! CGFloat 117 | 118 | var distanceY: CGFloat = 0 119 | 120 | let baseSubVC = tempBaseSubVCs[pagingTitleView.index] 121 | 122 | // 当前滚动的 scrollView 不是当前显示的 scrollView 直接返回 123 | guard scrollingScrollView == baseSubVC.scrollView else { 124 | return 125 | } 126 | var pagingTitleViewFrame: CGRect = pagingTitleView.frame 127 | guard pagingTitleViewFrame.origin.y >= navHeight else { 128 | return 129 | } 130 | 131 | let scrollViewContentOffsetY = scrollingScrollView.contentOffset.y 132 | 133 | // 往上滚动 134 | if offsetDifference > 0 && scrollViewContentOffsetY + pro_subScrollViewContentOffsetY > 0 { 135 | if (scrollViewContentOffsetY + pro_subScrollViewContentOffsetY + pagingTitleView.frame.origin.y) > pro_headerViewHeight || scrollViewContentOffsetY + pro_subScrollViewContentOffsetY < 0 { 136 | pagingTitleViewFrame.origin.y += -offsetDifference 137 | if pagingTitleViewFrame.origin.y <= navHeight { 138 | pagingTitleViewFrame.origin.y = navHeight 139 | } 140 | } 141 | } else { // 往下滚动 142 | if (scrollViewContentOffsetY + pagingTitleView.frame.origin.y + pro_subScrollViewContentOffsetY) < pro_headerViewHeight { 143 | pagingTitleViewFrame.origin.y = -scrollViewContentOffsetY - pro_pagingTitleViewHeight 144 | if pagingTitleViewFrame.origin.y >= pro_headerViewHeight { 145 | pagingTitleViewFrame.origin.y = pro_headerViewHeight 146 | } 147 | } 148 | } 149 | 150 | // 更新 pagingTitleView 的 frame 151 | pagingTitleView.frame = pagingTitleViewFrame 152 | 153 | // 更新 headerView 的 frame 154 | var headerViewFrame: CGRect = headerView.frame 155 | headerViewFrame.origin.y = pagingTitleView.frame.origin.y - pro_headerViewHeight 156 | headerView.frame = headerViewFrame 157 | 158 | distanceY = pagingTitleViewFrame.origin.y - tempLastPagingTitleViewY 159 | tempLastPagingTitleViewY = pagingTitleView.frame.origin.y 160 | 161 | /// 让其余控制器的 scrollView 跟随当前正在滚动的 scrollView 而滚动 162 | otherScrollViewFollowingScrollingScrollView(scrollView: scrollingScrollView, distanceY: distanceY) 163 | } 164 | 165 | /// 让其余控制器的 scrollView 跟随当前正在滚动的 scrollView 而滚动 166 | func otherScrollViewFollowingScrollingScrollView(scrollView: UIScrollView, distanceY: CGFloat) { 167 | var baseSubVC: BaseSubProVC 168 | for (index, _) in tempBaseSubVCs.enumerated() { 169 | baseSubVC = tempBaseSubVCs[index] 170 | if baseSubVC.scrollView == scrollView { 171 | continue 172 | } else { 173 | if let tempScrollView = baseSubVC.scrollView { 174 | var contentOffSet: CGPoint = tempScrollView.contentOffset 175 | contentOffSet.y += -distanceY 176 | tempScrollView.contentOffset = contentOffSet 177 | } 178 | } 179 | } 180 | } 181 | } 182 | 183 | extension SuspensionProVC: SGPagingTitleViewDelegate, SGPagingContentViewDelegate { 184 | func pagingTitleView(titleView: SGPagingTitleView, index: Int) { 185 | pagingContentView.setPagingContentView(index: index) 186 | } 187 | 188 | func pagingContentView(contentView: SGPagingContentView, progress: CGFloat, currentIndex: Int, targetIndex: Int) { 189 | pagingTitleView.setPagingTitleView(progress: progress, currentIndex: currentIndex, targetIndex: targetIndex) 190 | } 191 | 192 | func pagingContentViewDidScroll() { 193 | let baseSubVC: BaseSubProVC = tempBaseSubVCs[pagingTitleView.index] 194 | if let tempScrollView = baseSubVC.scrollView { 195 | if (tempScrollView.contentSize.height) < UIScreen.main.bounds.size.width { 196 | tempScrollView.setContentOffset(CGPoint(x: 0, y: -pro_subScrollViewContentOffsetY), animated: false) 197 | } 198 | } 199 | } 200 | 201 | } 202 | 203 | extension SuspensionProVC { 204 | @objc func temp_btn_action() { 205 | print("temp_btn_action") 206 | } 207 | } 208 | -------------------------------------------------------------------------------- /SGPagingView/Example/ZoomVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ZoomVC.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2020/12/29. 6 | // Copyright © 2020 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ZoomVC: UIViewController, SGPagingTitleViewDelegate, SGPagingContentViewDelegate { 12 | 13 | deinit { 14 | print("ZoomVC - deinit") 15 | } 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | // Do any additional setup after loading the view. 21 | view.backgroundColor = .black 22 | view.addSubview(pagingTitleView) 23 | view.addSubview(pagingContentView) 24 | } 25 | 26 | lazy var pagingTitleView: SGPagingTitleView = { 27 | let configure = SGPagingTitleViewConfigure() 28 | configure.gradientEffect = true 29 | configure.textZoom = true 30 | configure.textZoomRatio = 0.2 31 | 32 | let frame = CGRect.init(x: 0, y: UIScreen.navBarHeight, width: UIScreen.width, height: 44) 33 | let titles = ["关注", "推荐", "热榜", "免费小说"] 34 | let pagingTitle = SGPagingTitleView(frame: frame, titles: titles, configure: configure) 35 | pagingTitle.delegate = self 36 | return pagingTitle 37 | }() 38 | 39 | lazy var pagingContentView: SGPagingContentCollectionView = { 40 | let vc1 = UIViewController() 41 | vc1.view.backgroundColor = .orange 42 | let vc2 = UIViewController() 43 | vc2.view.backgroundColor = .purple 44 | let vc3 = UIViewController() 45 | vc3.view.backgroundColor = .green 46 | let vc4 = UIViewController() 47 | vc4.view.backgroundColor = .brown 48 | let vcs = [vc1, vc2, vc3, vc4] 49 | 50 | let y: CGFloat = pagingTitleView.frame.maxY 51 | let tempRect: CGRect = CGRect.init(x: 0, y: y, width: UIScreen.width, height: UIScreen.height - y) 52 | let pagingContent = SGPagingContentCollectionView(frame: tempRect, parentVC: self, childVCs: vcs) 53 | pagingContent.delegate = self 54 | return pagingContent 55 | }() 56 | 57 | 58 | func pagingTitleView(titleView: SGPagingTitleView, index: Int) { 59 | pagingContentView.setPagingContentView(index: index) 60 | } 61 | 62 | func pagingContentView(contentView: SGPagingContentView, progress: CGFloat, currentIndex: Int, targetIndex: Int) { 63 | pagingTitleView.setPagingTitleView(progress: progress, currentIndex: currentIndex, targetIndex: targetIndex) 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /SGPagingView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIApplicationSceneManifest 6 | 7 | UIApplicationSupportsMultipleScenes 8 | 9 | UISceneConfigurations 10 | 11 | UIWindowSceneSessionRoleApplication 12 | 13 | 14 | UISceneConfigurationName 15 | Default Configuration 16 | UISceneDelegateClassName 17 | $(PRODUCT_MODULE_NAME).SceneDelegate 18 | UISceneStoryboardFile 19 | Main 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /SGPagingView/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2021/12/10. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /SGPagingView/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2021/12/10. 6 | // 7 | 8 | import UIKit 9 | 10 | class ViewController: UIViewController { 11 | @IBOutlet weak var tableView: UITableView! 12 | 13 | var dataSource = [ 14 | ["固定样式一(回弹效果)": FixedOneVC.self], 15 | ["固定样式二(动画效果)": FixedTwoVC.self], 16 | ["滚动样式(指定下标值)": ScrollVC.self], 17 | ["富文本样式": AttributedVC.self], 18 | ["文字渐变效果": GradientEffectVC.self], 19 | ["文字缩放效果": ZoomVC.self], 20 | ["通知消息样式": BadgeVC.self], 21 | ["指示器固定样式(爱奇艺首页效果)": IFixedVC.self], 22 | ["指示器动态样式": IDynamicVC.self], 23 | ["指示器遮盖样式": CoverOneVC.self], 24 | ["百度网盘传输界面样式": CoverTwoVC.self], 25 | ["悬浮效果": SuspensionVC.self], 26 | ["悬浮效果Pro": SuspensionProVC.self] 27 | ] 28 | 29 | override func viewDidLoad() { 30 | super.viewDidLoad() 31 | // Do any additional setup after loading the view. 32 | 33 | tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cellID") 34 | tableView.tableFooterView = UIView() 35 | } 36 | 37 | } 38 | 39 | extension ViewController: UITableViewDataSource { 40 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 41 | dataSource.count 42 | } 43 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 44 | let cell = tableView.dequeueReusableCell(withIdentifier: "cellID", for: indexPath) 45 | cell.accessoryType = .disclosureIndicator 46 | cell.backgroundColor = .clear 47 | cell.selectionStyle = .none 48 | cell.textLabel?.text = dataSource[indexPath.row].keys.first 49 | return cell 50 | } 51 | } 52 | 53 | extension ViewController: UITableViewDelegate { 54 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 55 | let vc = dataSource[indexPath.row].values.first 56 | if let tempVC = vc { 57 | navigationController?.pushViewController(tempVC.init(), animated: true) 58 | } 59 | } 60 | } 61 | 62 | -------------------------------------------------------------------------------- /SGPagingViewTests/SGPagingViewTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SGPagingViewTests.swift 3 | // SGPagingViewTests 4 | // 5 | // Created by kingsic on 2021/12/10. 6 | // 7 | 8 | import XCTest 9 | @testable import SGPagingView 10 | 11 | class SGPagingViewTests: XCTestCase { 12 | 13 | override func setUpWithError() throws { 14 | // Put setup code here. This method is called before the invocation of each test method in the class. 15 | } 16 | 17 | override func tearDownWithError() throws { 18 | // Put teardown code here. This method is called after the invocation of each test method in the class. 19 | } 20 | 21 | func testExample() throws { 22 | // This is an example of a functional test case. 23 | // Use XCTAssert and related functions to verify your tests produce the correct results. 24 | } 25 | 26 | func testPerformanceExample() throws { 27 | // This is an example of a performance test case. 28 | self.measure { 29 | // Put the code you want to measure the time of here. 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /SGPagingViewUITests/SGPagingViewUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SGPagingViewUITests.swift 3 | // SGPagingViewUITests 4 | // 5 | // Created by kingsic on 2021/12/10. 6 | // 7 | 8 | import XCTest 9 | 10 | class SGPagingViewUITests: XCTestCase { 11 | 12 | override func setUpWithError() throws { 13 | // Put setup code here. This method is called before the invocation of each test method in the class. 14 | 15 | // In UI tests it is usually best to stop immediately when a failure occurs. 16 | continueAfterFailure = false 17 | 18 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 19 | } 20 | 21 | override func tearDownWithError() throws { 22 | // Put teardown code here. This method is called after the invocation of each test method in the class. 23 | } 24 | 25 | func testExample() throws { 26 | // UI tests must launch the application that they test. 27 | let app = XCUIApplication() 28 | app.launch() 29 | 30 | // Use recording to get started writing UI tests. 31 | // Use XCTAssert and related functions to verify your tests produce the correct results. 32 | } 33 | 34 | func testLaunchPerformance() throws { 35 | if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { 36 | // This measures how long it takes to launch your application. 37 | measure(metrics: [XCTApplicationLaunchMetric()]) { 38 | XCUIApplication().launch() 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /SGPagingViewUITests/SGPagingViewUITestsLaunchTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SGPagingViewUITestsLaunchTests.swift 3 | // SGPagingViewUITests 4 | // 5 | // Created by kingsic on 2021/12/10. 6 | // 7 | 8 | import XCTest 9 | 10 | class SGPagingViewUITestsLaunchTests: XCTestCase { 11 | 12 | override class var runsForEachTargetApplicationUIConfiguration: Bool { 13 | true 14 | } 15 | 16 | override func setUpWithError() throws { 17 | continueAfterFailure = false 18 | } 19 | 20 | func testLaunch() throws { 21 | let app = XCUIApplication() 22 | app.launch() 23 | 24 | // Insert steps here to perform after app launch but before taking a screenshot, 25 | // such as logging into a test account or navigating somewhere in the app 26 | 27 | let attachment = XCTAttachment(screenshot: app.screenshot()) 28 | attachment.name = "Launch Screen" 29 | attachment.lifetime = .keepAlways 30 | add(attachment) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Sources/Extensions/UIButton+SGPagingView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIButton+SGPagingView.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2021/11/17. 6 | // Copyright © 2021 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @objc public enum ImageLocation: Int { 12 | case left, right, top, bottom 13 | } 14 | 15 | public extension UIButton { 16 | /// Set image location 17 | /// 18 | /// Image and title must be set before this method will work, It is recommended to set it inside the block 19 | /// 20 | /// - parameter location: location of image relative to title 21 | /// - parameter space: space between image and title 22 | /// - parameter completion: set image and title 23 | @objc func setImage(location: ImageLocation, space: CGFloat, completion: (UIButton) -> ()) { 24 | completion(self) 25 | setImage(location: location, space: space) 26 | } 27 | 28 | /// Set image location 29 | /// 30 | /// Image and title must be set before this method will work 31 | /// 32 | /// - parameter location: Location of image relative to title 33 | /// - parameter space: Space between image and title 34 | @objc func setImage(location: ImageLocation, space: CGFloat) { 35 | 36 | let imageView_Width = imageView?.frame.size.width 37 | let imageView_Height = imageView?.frame.size.height 38 | let titleLabel_iCSWidth = titleLabel?.intrinsicContentSize.width 39 | let titleLabel_iCSHeight = titleLabel?.intrinsicContentSize.height 40 | 41 | switch location { 42 | case .left: 43 | if contentHorizontalAlignment == .left { 44 | titleEdgeInsets = UIEdgeInsets.init(top: 0, left: space, bottom: 0, right: 0) 45 | } else if contentHorizontalAlignment == .right { 46 | imageEdgeInsets = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: space) 47 | } else { 48 | let spacing_half = 0.5 * space; 49 | imageEdgeInsets = UIEdgeInsets.init(top: 0, left: -spacing_half, bottom: 0, right: spacing_half) 50 | titleEdgeInsets = UIEdgeInsets.init(top: 0, left: spacing_half, bottom: 0, right: -spacing_half) 51 | } 52 | case .right: 53 | let titleLabelWidth = titleLabel?.frame.size.width 54 | if contentHorizontalAlignment == .left { 55 | imageEdgeInsets = UIEdgeInsets.init(top: 0, left: titleLabelWidth! + space, bottom: 0, right: 0) 56 | titleEdgeInsets = UIEdgeInsets.init(top: 0, left: -imageView_Width!, bottom: 0, right: 0) 57 | } else if contentHorizontalAlignment == .right { 58 | imageEdgeInsets = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: -titleLabelWidth!) 59 | titleEdgeInsets = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: imageView_Width! + space) 60 | } else { 61 | let imageOffset = titleLabelWidth! + 0.5 * space 62 | let titleOffset = imageView_Width! + 0.5 * space 63 | imageEdgeInsets = UIEdgeInsets.init(top: 0, left: imageOffset, bottom: 0, right: -imageOffset) 64 | titleEdgeInsets = UIEdgeInsets.init(top: 0, left: -titleOffset, bottom: 0, right: titleOffset) 65 | } 66 | case .top: 67 | imageEdgeInsets = UIEdgeInsets.init(top: -(titleLabel_iCSHeight! + space), left: 0, bottom: 0, right: -titleLabel_iCSWidth!) 68 | titleEdgeInsets = UIEdgeInsets.init(top: 0, left: -imageView_Width!, bottom: -(imageView_Height! + space), right: 0) 69 | case .bottom: 70 | imageEdgeInsets = UIEdgeInsets.init(top: titleLabel_iCSHeight! + space, left: 0, bottom: 0, right: -titleLabel_iCSWidth!) 71 | titleEdgeInsets = UIEdgeInsets.init(top: 0, left: -imageView_Width!, bottom: imageView_Height! + space, right: 0) 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Sources/Extensions/UIScreen+SGPagingView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIScreen+SGPagingView.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2021/11/17. 6 | // Copyright © 2021 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public extension UIScreen { 12 | /// Gets the size of the screen 13 | @objc static var size: CGSize { return UIScreen.main.bounds.size } 14 | 15 | /// Gets the width of the screen 16 | @objc static var width: CGFloat { return UIScreen.main.bounds.size.width } 17 | 18 | /// Gets the height of the screen 19 | @objc static var height: CGFloat { return UIScreen.main.bounds.size.height } 20 | 21 | /// Gets status bar height 22 | @objc static var statusBarHeight: CGFloat { 23 | if #available(iOS 13, *) { 24 | return (UIApplication.shared.windows.first?.windowScene?.statusBarManager?.statusBarFrame.size.height)! 25 | } else { 26 | return UIApplication.shared.statusBarFrame.size.height 27 | } 28 | } 29 | 30 | /// Gets navigation bar height 31 | @objc static var navBarHeight: CGFloat { return statusBarHeight + 44 } 32 | 33 | /// Gets tab bar height 34 | @objc static var tabBarHeight: CGFloat { return statusBarHeight == 20 ? 49 : 83 } 35 | 36 | /// Gets bottom safeArea height 37 | @objc static var safeAreaInsetBottom: CGFloat { return statusBarHeight == 20 ? 0 : 34 } 38 | } 39 | -------------------------------------------------------------------------------- /Sources/PagingContent/SGPagingContentCollectionView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SGPagingContentCollectionView.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2020/12/23. 6 | // Copyright © 2020 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public class SGPagingContentCollectionView: SGPagingContentView { 12 | @objc public init(frame: CGRect, parentVC: UIViewController, childVCs: [UIViewController]) { 13 | super.init(frame: frame) 14 | 15 | parentViewController = parentVC 16 | childViewControllers = childVCs 17 | 18 | addSubview(collectionView) 19 | } 20 | required init?(coder: NSCoder) { 21 | fatalError("init(coder:) has not been implemented") 22 | } 23 | 24 | public override var isScrollEnabled: Bool { 25 | willSet { 26 | collectionView.isScrollEnabled = newValue 27 | } 28 | } 29 | 30 | public override var isBounces: Bool { 31 | willSet { 32 | collectionView.bounces = newValue 33 | } 34 | } 35 | 36 | public override func setPagingContentView(index: Int) { 37 | setPagingContentCollectionView(index: index) 38 | } 39 | 40 | // MARK: 内部属性 41 | private weak var parentViewController: UIViewController? 42 | private var childViewControllers: [UIViewController] = [] 43 | private var startOffsetX: CGFloat = 0.0 44 | private var previousChildVC: UIViewController? 45 | private var previousChildVCIndex: Int = -1 46 | private var scroll: Bool = false 47 | 48 | private lazy var collectionView: UICollectionView = { 49 | let flowLayout = UICollectionViewFlowLayout() 50 | flowLayout.itemSize = bounds.size 51 | flowLayout.minimumLineSpacing = 0 52 | flowLayout.minimumInteritemSpacing = 0 53 | flowLayout.scrollDirection = .horizontal 54 | 55 | let tempCollectionView = UICollectionView(frame: bounds, collectionViewLayout: flowLayout) 56 | tempCollectionView.showsVerticalScrollIndicator = false 57 | tempCollectionView.showsHorizontalScrollIndicator = false 58 | tempCollectionView.isPagingEnabled = true 59 | tempCollectionView.bounces = isBounces 60 | tempCollectionView.backgroundColor = .white 61 | tempCollectionView.delegate = self 62 | tempCollectionView.dataSource = self 63 | tempCollectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: cellID) 64 | return tempCollectionView 65 | }() 66 | } 67 | 68 | extension SGPagingContentCollectionView { 69 | func setPagingContentCollectionView(index: Int) { 70 | let offsetX = CGFloat(index) * collectionView.frame.size.width 71 | startOffsetX = offsetX 72 | if previousChildVCIndex != index { 73 | collectionView.setContentOffset(CGPoint(x: offsetX, y: 0), animated: isAnimated) 74 | } 75 | previousChildVCIndex = index 76 | if delegate != nil && ((delegate?.responds(to: #selector(delegate?.pagingContentView(index:)))) != nil) { 77 | delegate?.pagingContentView?(index: index) 78 | } 79 | } 80 | } 81 | 82 | private let cellID = "cellID" 83 | 84 | extension SGPagingContentCollectionView: UICollectionViewDataSource { 85 | public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 86 | return childViewControllers.count 87 | } 88 | 89 | public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 90 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellID, for: indexPath) 91 | cell.contentView.subviews.forEach { (subView) in 92 | subView.removeFromSuperview() 93 | } 94 | let childVC = childViewControllers[indexPath.item] 95 | parentViewController?.addChild(childVC) 96 | cell.contentView.addSubview(childVC.view) 97 | childVC.view.frame = cell.contentView.frame 98 | childVC.didMove(toParent: parentViewController) 99 | return cell 100 | } 101 | } 102 | 103 | extension SGPagingContentCollectionView: UICollectionViewDelegate { 104 | public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { 105 | startOffsetX = scrollView.contentOffset.x 106 | scroll = true 107 | if delegate != nil && ((delegate?.responds(to: #selector(delegate?.pagingContentViewWillBeginDragging))) != nil) { 108 | delegate?.pagingContentViewWillBeginDragging?() 109 | } 110 | } 111 | 112 | public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { 113 | scroll = false 114 | let offsetX = scrollView.contentOffset.x 115 | previousChildVCIndex = Int(offsetX / scrollView.frame.size.width) 116 | if delegate != nil && ((delegate?.responds(to: #selector(delegate?.pagingContentView(index:)))) != nil) { 117 | delegate?.pagingContentView?(index: previousChildVCIndex) 118 | } 119 | if delegate != nil && ((delegate?.responds(to: #selector(delegate?.pagingContentViewDidEndDecelerating))) != nil) { 120 | delegate?.pagingContentViewDidEndDecelerating?() 121 | } 122 | } 123 | 124 | public func scrollViewDidScroll(_ scrollView: UIScrollView) { 125 | if isAnimated == true && scroll == false { 126 | return 127 | } 128 | // 1、定义获取需要的数据 129 | var progress: CGFloat = 0.0 130 | var currentIndex: Int = 0 131 | var targetIndex: Int = 0 132 | 133 | // 2、判断是左滑还是右滑 134 | let currentOffsetX: CGFloat = scrollView.contentOffset.x 135 | let scrollViewW: CGFloat = scrollView.bounds.size.width 136 | if currentOffsetX > startOffsetX { // 左滑 137 | if currentOffsetX > CGFloat(childViewControllers.count - 1) * scrollViewW && isBounces == true { 138 | return 139 | } 140 | // 1、计算 progress 141 | progress = currentOffsetX / scrollViewW - floor(currentOffsetX / scrollViewW); 142 | // 2、计算 currentIndex 143 | currentIndex = Int(currentOffsetX / scrollViewW); 144 | // 3、计算 targetIndex 145 | targetIndex = currentIndex + 1; 146 | if targetIndex >= childViewControllers.count { 147 | progress = 1; 148 | targetIndex = currentIndex; 149 | } 150 | // 4、如果完全划过去 151 | if currentOffsetX - startOffsetX == scrollViewW { 152 | progress = 1; 153 | targetIndex = currentIndex; 154 | } 155 | } else { // 右滑 156 | if currentOffsetX < 0 && isBounces == true { 157 | return 158 | } 159 | // 1、计算 progress 160 | progress = 1 - (currentOffsetX / scrollViewW - floor(currentOffsetX / scrollViewW)); 161 | // 2、计算 targetIndex 162 | targetIndex = Int(currentOffsetX / scrollViewW); 163 | // 3、计算 currentIndex 164 | currentIndex = targetIndex + 1; 165 | if currentIndex >= childViewControllers.count { 166 | currentIndex = childViewControllers.count - 1; 167 | } 168 | } 169 | 170 | if delegate != nil && ((delegate?.responds(to: #selector(delegate?.pagingContentView(contentView:progress:currentIndex:targetIndex:)))) != nil) { 171 | delegate?.pagingContentView?(contentView: self, progress: progress, currentIndex: currentIndex, targetIndex: targetIndex) 172 | } 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /Sources/PagingContent/SGPagingContentScrollView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SGPagingContentScrollView.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2020/12/23. 6 | // Copyright © 2020 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public class SGPagingContentScrollView: SGPagingContentView { 12 | @objc public init(frame: CGRect, parentVC: UIViewController, childVCs: [UIViewController]) { 13 | super.init(frame: frame) 14 | 15 | parentViewController = parentVC 16 | childViewControllers = childVCs 17 | 18 | addSubview(scrollView) 19 | } 20 | required init?(coder: NSCoder) { 21 | fatalError("init(coder:) has not been implemented") 22 | } 23 | 24 | public override var isScrollEnabled: Bool { 25 | willSet { 26 | scrollView.isScrollEnabled = newValue 27 | } 28 | } 29 | 30 | public override var isBounces: Bool { 31 | willSet { 32 | scrollView.bounces = newValue 33 | } 34 | } 35 | 36 | public override func setPagingContentView(index: Int) { 37 | setPagingContentScrollView(index: index) 38 | } 39 | 40 | // MARK: 内部属性 41 | private weak var parentViewController: UIViewController? 42 | private var childViewControllers: [UIViewController] = [] 43 | private var startOffsetX: CGFloat = 0.0 44 | private var previousChildVC: UIViewController? 45 | private var previousChildVCIndex: Int = -1 46 | private var scroll: Bool = false 47 | 48 | private lazy var scrollView: UIScrollView = { 49 | let tempScrollView = UIScrollView() 50 | tempScrollView.frame = bounds 51 | tempScrollView.bounces = isBounces 52 | tempScrollView.delegate = self 53 | tempScrollView.isPagingEnabled = true 54 | tempScrollView.showsVerticalScrollIndicator = false 55 | tempScrollView.showsHorizontalScrollIndicator = false 56 | let contentWidth: CGFloat = CGFloat(childViewControllers.count) * tempScrollView.frame.size.width 57 | tempScrollView.contentSize = CGSize(width: contentWidth, height: 0) 58 | return tempScrollView 59 | }() 60 | } 61 | 62 | extension SGPagingContentScrollView { 63 | func setPagingContentScrollView(index: Int) { 64 | let offsetX = CGFloat(index) * scrollView.frame.size.width 65 | // 1、切换子控制器的时候,执行上个子控制器的 viewWillDisappear 方法 66 | if previousChildVC != nil && previousChildVCIndex != index { 67 | previousChildVC?.beginAppearanceTransition(false, animated: false) 68 | } 69 | // 2、添加子控制器及子控制器的 view 到父控制器及父控制器 view 中 70 | if previousChildVCIndex != index { 71 | let childVC: UIViewController = childViewControllers[index] 72 | var firstAdd = false 73 | if !(parentViewController?.children.contains(childVC))! { 74 | parentViewController?.addChild(childVC) 75 | firstAdd = true 76 | } 77 | childVC.beginAppearanceTransition(true, animated: false) 78 | 79 | if (firstAdd) { 80 | scrollView.addSubview(childVC.view) 81 | childVC.view.frame = CGRect(x: offsetX, y: 0, width: scrollView.frame.size.width, height: scrollView.frame.size.height) 82 | } 83 | 84 | // 切换子控制器的时候,执行上个子控制器的 viewDidDisappear 方法 85 | if previousChildVC != nil && previousChildVCIndex != index { 86 | previousChildVC?.endAppearanceTransition() 87 | } 88 | childVC.endAppearanceTransition() 89 | 90 | if (firstAdd) { 91 | childVC.didMove(toParent: parentViewController) 92 | } 93 | 94 | // 记录上个子控制器 95 | previousChildVC = childVC 96 | // 处理内容偏移 97 | scrollView.setContentOffset(CGPoint(x: offsetX, y: 0), animated: isAnimated) 98 | } 99 | // 3.2、记录上个子控制器下标 100 | previousChildVCIndex = index 101 | // 3.3、重置 startOffsetX 102 | startOffsetX = offsetX 103 | 104 | // 4、pagingContentView:index: 105 | if delegate != nil && ((delegate?.responds(to: #selector(delegate?.pagingContentView(index:)))) != nil) { 106 | delegate?.pagingContentView?(index: index) 107 | } 108 | } 109 | } 110 | 111 | extension SGPagingContentScrollView: UIScrollViewDelegate { 112 | public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { 113 | startOffsetX = scrollView.contentOffset.x 114 | scroll = true 115 | if delegate != nil && ((delegate?.responds(to: #selector(delegate?.pagingContentViewWillBeginDragging))) != nil) { 116 | delegate?.pagingContentViewWillBeginDragging?() 117 | } 118 | } 119 | public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { 120 | scroll = false 121 | // 1、根据标题下标计算 pageContent 偏移量 122 | let offsetX: CGFloat = scrollView.contentOffset.x 123 | // 2、切换子控制器的时候,执行上个子控制器的 viewWillDisappear 方法 124 | if startOffsetX != offsetX { 125 | previousChildVC?.beginAppearanceTransition(false, animated: false) 126 | } 127 | // 3、获取当前显示子控制器的下标 128 | let index: Int = Int(offsetX / scrollView.frame.size.width) 129 | // 4、添加子控制器及子控制器的 view 到父控制器以及父控制器 view 中 130 | let childVC: UIViewController = childViewControllers[index] 131 | 132 | var firstAdd = false 133 | if !(parentViewController?.children.contains(childVC))! { 134 | parentViewController?.addChild(childVC) 135 | firstAdd = true 136 | } 137 | 138 | childVC.beginAppearanceTransition(true, animated: false) 139 | 140 | if (firstAdd) { 141 | scrollView.addSubview(childVC.view) 142 | childVC.view.frame = CGRect(x: offsetX, y: 0, width: scrollView.frame.size.width, height: scrollView.frame.size.height) 143 | } 144 | 145 | // 2.1、切换子控制器的时候,执行上个子控制器的 viewDidDisappear 方法 146 | if startOffsetX != offsetX { 147 | previousChildVC?.endAppearanceTransition() 148 | } 149 | childVC.endAppearanceTransition() 150 | 151 | if (firstAdd) { 152 | childVC.didMove(toParent: parentViewController) 153 | } 154 | 155 | // 4.1、记录上个展示的子控制器、记录当前子控制器偏移量 156 | previousChildVC = childVC 157 | previousChildVCIndex = index 158 | 159 | // 5、pagingContentScrollView:index: 160 | if delegate != nil && ((delegate?.responds(to: #selector(delegate?.pagingContentView(index:)))) != nil) { 161 | delegate?.pagingContentView?(index: index) 162 | } 163 | // 6、pagingContentScrollViewDidEndDecelerating 164 | if delegate != nil && ((delegate?.responds(to: #selector(delegate?.pagingContentViewDidEndDecelerating))) != nil) { 165 | delegate?.pagingContentViewDidEndDecelerating?() 166 | } 167 | } 168 | public func scrollViewDidScroll(_ scrollView: UIScrollView) { 169 | 170 | if delegate != nil && ((delegate?.responds(to: #selector(delegate?.pagingContentViewDidScroll))) != nil) { 171 | delegate?.pagingContentViewDidScroll?() 172 | } 173 | 174 | if isAnimated == true && scroll == false { return } 175 | // 1、定义获取需要的数据 176 | var progress: CGFloat = 0.0 177 | var originalIndex: Int = 0 178 | var targetIndex: Int = 0 179 | 180 | // 2、判断是左滑还是右滑 181 | let currentOffsetX: CGFloat = scrollView.contentOffset.x 182 | let scrollViewW: CGFloat = scrollView.bounds.size.width 183 | if currentOffsetX > startOffsetX { // 左滑 184 | if currentOffsetX > CGFloat(childViewControllers.count - 1) * scrollViewW && isBounces == true { 185 | return 186 | } 187 | // 1、计算 progress 188 | progress = currentOffsetX / scrollViewW - floor(currentOffsetX / scrollViewW); 189 | // 2、计算 originalIndex 190 | originalIndex = Int(currentOffsetX / scrollViewW); 191 | // 3、计算 targetIndex 192 | targetIndex = originalIndex + 1; 193 | if targetIndex >= childViewControllers.count { 194 | progress = 1; 195 | targetIndex = originalIndex; 196 | } 197 | // 4、如果完全划过去 198 | if currentOffsetX - startOffsetX == scrollViewW { 199 | progress = 1; 200 | targetIndex = originalIndex; 201 | } 202 | } else { // 右滑 203 | if currentOffsetX < 0 && isBounces == true { 204 | return 205 | } 206 | // 1、计算 progress 207 | progress = 1 - (currentOffsetX / scrollViewW - floor(currentOffsetX / scrollViewW)); 208 | // 2、计算 targetIndex 209 | targetIndex = Int(currentOffsetX / scrollViewW); 210 | // 3、计算 originalIndex 211 | originalIndex = targetIndex + 1; 212 | if originalIndex >= childViewControllers.count { 213 | originalIndex = childViewControllers.count - 1; 214 | } 215 | } 216 | 217 | // 3、将 progress/currentIndex/targetIndex 传递给 PagingTitleView 218 | if delegate != nil && ((delegate?.responds(to: #selector(delegate?.pagingContentView(contentView:progress:currentIndex:targetIndex:)))) != nil) { 219 | delegate?.pagingContentView?(contentView: self, progress: progress, currentIndex: originalIndex, targetIndex: targetIndex) 220 | } 221 | } 222 | } 223 | -------------------------------------------------------------------------------- /Sources/PagingContent/SGPagingContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SGPagingContentView.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2021/11/17. 6 | // Copyright © 2021 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public class SGPagingContentView: UIView { 12 | /// SGPagingContentView 的代理 13 | @objc public weak var delegate: SGPagingContentViewDelegate? 14 | 15 | /// 内容视图的子视图是否需要动画效果,默认为 false 16 | /// 17 | /// 为 true 时,点击标题如果指示器出现异常跳动,设置 isBounces = true,即可避免这个问题 18 | @objc public var isAnimated = false 19 | 20 | /// 内容视图的子视图是否可以左右滚动,默认为 true;为 false 时,不需要设置代理及其方法 21 | @objc public var isScrollEnabled: Bool = true 22 | 23 | /// 当内容视图的子视图滚动到最左边或最右边时,是否需要回弹效果,默认为 false 24 | @objc public var isBounces: Bool = false 25 | 26 | /// 根据外界提供的下标值设置内容视图对应的子视图 27 | @objc public func setPagingContentView(index: Int){} 28 | } 29 | -------------------------------------------------------------------------------- /Sources/PagingContent/SGPagingContentViewDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SGPagingContentViewDelegate.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2021/11/17. 6 | // Copyright © 2021 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @objc public protocol SGPagingContentViewDelegate: NSObjectProtocol { 12 | /// 滚动当前子视图时对应的相关数据 13 | /// 14 | /// - parameter contentView: 分页滚动内容视图 15 | /// - parameter progress: 滚动进度值 16 | /// - parameter currentIndex: 当前子视图的下标值 17 | /// - parameter targetIndex: 目标子视图的下标值 18 | @objc optional func pagingContentView(contentView: SGPagingContentView, progress: CGFloat, currentIndex: Int, targetIndex: Int) 19 | 20 | /// 内容视图当前对应子视图的下标值 21 | /// 22 | /// - parameter index: 当前子视图的下标值 23 | @objc optional func pagingContentView(index: Int) 24 | 25 | /// 内容视图滚动的方法(仅 SGPagingContentScrollView 实现了该方法) 26 | @objc optional func pagingContentViewDidScroll() 27 | 28 | /// 内容视图开始拖拽的方法 29 | @objc optional func pagingContentViewWillBeginDragging() 30 | 31 | /// 内容视图结束拖拽的方法 32 | @objc optional func pagingContentViewDidEndDecelerating() 33 | } 34 | -------------------------------------------------------------------------------- /Sources/PagingTitle/SGPagingTitleViewConfigure.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SGPagingTitleViewConfigure.swift 3 | // SGPagingView 4 | // 5 | // Created by kingsic on 2020/12/23. 6 | // Copyright © 2020 kingsic. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | /// 指示器样式 12 | @objc public enum IndicatorType: Int { 13 | case Default, Cover, Fixed, Dynamic 14 | } 15 | 16 | /// 指示器随内容子视图滚动而滚动的样式 17 | @objc public enum IndicatorScrollStyle: Int { 18 | case Default, Half, End 19 | } 20 | 21 | /// 指示器添加到父视图上的层级位置,(Default:标题之下,Top:标题之上) 22 | @objc public enum IndicatorLocation: Int { 23 | case Default, Top 24 | } 25 | 26 | 27 | public class SGPagingTitleViewConfigure: NSObject { 28 | // MARK: SGPagingTitleView 相关属性 29 | /// SGPagingTitleView 固定样式下,是否需要回弹效果,默认为 false 30 | @objc public var bounce = false 31 | 32 | /// SGPagingTitleView 滚动样式下,是否需要回弹效果,默认为 true 33 | @objc public var bounces = true 34 | 35 | /// SGPagingTitleView 固定样式下标题是否均分布局,默认为 true 36 | @objc public var equivalence = true 37 | 38 | /// SGPagingTitleView 是否显示底部分割线,默认为 true 39 | @objc public var showBottomSeparator = true 40 | 41 | /// SGPagingTitleView 底部分割线颜色,默认为 lightGray 42 | @objc public var bottomSeparatorColor: UIColor = .lightGray 43 | 44 | 45 | // MARK: 标题相关属性 46 | /// 标题文字大小,默认为 .systemFont(ofSize: 15) 47 | @objc public var font: UIFont = .systemFont(ofSize: 15) 48 | 49 | /// 标题文字选中时大小,默认为 .systemFont(ofSize: 15),一旦设置此属性,textZoom 属性将不起作用 50 | @objc public var selectedFont: UIFont = .systemFont(ofSize: 15) 51 | 52 | /// 普通状态下标题颜色,默认为 black 53 | @objc public var color: UIColor = .black 54 | 55 | /// 选中状态下标题颜色,默认为 red 56 | @objc public var selectedColor: UIColor = .red 57 | 58 | /// 标题文字是否具有渐变效果,默认为 false 59 | @objc public var gradientEffect = false 60 | 61 | /// 标题文字是否具有缩放效果,默认为 false。为 true 时,请与 textZoomRatio 属性结合使用,否则不起作用。(特别需要注意的是:此属性为 true 时,与 indicatorScrollStyle 属性不兼容) 62 | @objc public var textZoom = false 63 | 64 | /// 标题文字缩放比,默认为 0.0f,取值范围 0.0 ~ 1.0f。请与 textZoom = true 时结合使用,否则不起作用 65 | @objc public var textZoomRatio: CGFloat = 0.0 66 | 67 | /// 标题额外需要增加的宽度,默认为 20.0(标题宽度 = 文字宽度 + additionalWidth) 68 | @objc public var additionalWidth: CGFloat = 20.0 69 | 70 | 71 | // MARK: 指示器相关属性 72 | /// 是否显示指示器,默认为 true 73 | @objc public var showIndicator = true 74 | 75 | /// 指示器颜色,默认为 red 76 | @objc public var indicatorColor: UIColor = .red 77 | 78 | /// 指示器高度,默认为 2.0f 79 | @objc public var indicatorHeight: CGFloat = 2.0 80 | 81 | /// 指示器动画时间,默认为 0.1f,取值范围 0.0 ~ 0.3f 82 | @objc public var indicatorAnimationTime: TimeInterval = 0.1 83 | 84 | /// 指示器圆角大小,默认为 0.0f 85 | @objc public var indicatorCornerRadius: CGFloat = 0.0 86 | 87 | /// 指示器 Cover 样式下的边框宽度,默认为 0.0f 88 | @objc public var indicatorBorderWidth: CGFloat = 0.0 89 | 90 | /// 指示器 Cover 样式下的边框颜色,默认为 clear 91 | @objc public var indicatorBorderColor: UIColor = .clear 92 | 93 | /// 指示器 Cover、Default 样式下额外增加的宽度,默认为 0.0f;指示器默认宽度等于标题文字宽度 94 | @objc public var indicatorAdditionalWidth: CGFloat = 0.0 95 | 96 | /// 指示器 Fixed 样式下的宽度,默认为 20.0f;最大宽度并没有做限制,请根据实际情况妥善设置 97 | @objc public var indicatorFixedWidth: CGFloat = 20.0 98 | 99 | /// 指示器 Dynamic 样式下的宽度,默认为 20.0f;最大宽度并没有做限制,请根据实际情况妥善设置 100 | @objc public var indicatorDynamicWidth: CGFloat = 20.0 101 | 102 | /// 指示器距 SGPagingTitleView 底部间的距离,默认为 0.0f 103 | @objc public var indicatorToBottomDistance: CGFloat = 0.0 104 | 105 | /// 指示器样式,默认为 Default 106 | @objc public var indicatorType: IndicatorType = .Default 107 | 108 | /// 滚动内容视图时,指示器切换样式,默认为 Default。(特别需要注意的是:此属性与 textZoom = true 时不兼容) 109 | @objc public var indicatorScrollStyle: IndicatorScrollStyle = .Default 110 | 111 | /// 指示器添加在父视图上的层级位置,默认为 Default 112 | @objc public var indicatorLocation: IndicatorLocation = .Default 113 | 114 | 115 | // MARK: 标题间分割线相关属性 116 | /// 是否显示标题间分割线,默认为 false 117 | @objc public var showSeparator = false 118 | 119 | /// 标题间分割线颜色,默认为 red 120 | @objc public var separatorColor: UIColor = .red 121 | 122 | /// 标题间分割线额外减少的长度,默认为 20.0f 123 | @objc public var separatorAdditionalReduceLength: CGFloat = 20.0 124 | 125 | 126 | // MARK: badge 相关属性,默认所在位置以标题文字右上角为起点 127 | /// badge 颜色,默认为 red 128 | @objc public var badgeColor: UIColor = .red 129 | 130 | /// badge 的高,默认为 7.0f 131 | @objc public var badgeHeight: CGFloat = 7.0 132 | 133 | /// badge 的偏移量,默认为 zero 134 | @objc public var badgeOff: CGPoint = .zero 135 | 136 | /// badge 的文字颜色,默认为 white(只针对:addBadge(text:index:) 方法有效) 137 | @objc public var badgeTextColor: UIColor = .white 138 | 139 | /// badge 的文字大小,默认为 .systemFont(ofSize: 10)(只针对:addBadge(text:index:) 方法有效) 140 | @objc public var badgeTextFont: UIFont = .systemFont(ofSize: 10) 141 | 142 | /// badge 额外需要增加的宽度,默认为 10.0f(只针对:addBadge(text:index:) 方法有效) 143 | @objc public var badgeAdditionalWidth: CGFloat = 10.0 144 | 145 | /// badge 边框的宽度,默认为 0(只针对:addBadge(text:index:) 方法有效) 146 | @objc public var badgeBorderWidth: CGFloat = 0.0 147 | 148 | /// badge 边框的颜色,默认为 clear(只针对:addBadge(text:index:) 方法有效) 149 | @objc public var badgeBorderColor: UIColor = .clear 150 | 151 | /// badge 圆角大小,默认为 5.0f(只针对:addBadge(text:index:) 方法有效) 152 | @objc public var badgeCornerRadius: CGFloat = 5.0 153 | } 154 | --------------------------------------------------------------------------------