https://github.com/gsyhei/GXSegmentPageView
Swift版分段分页组件,(网易新闻、腾讯新闻、新浪微博、今日头条等Tab效果)
https://github.com/gsyhei/GXSegmentPageView
Last synced: 4 months ago
JSON representation
Swift版分段分页组件,(网易新闻、腾讯新闻、新浪微博、今日头条等Tab效果)
- Host: GitHub
- URL: https://github.com/gsyhei/GXSegmentPageView
- Owner: gsyhei
- License: mit
- Created: 2020-08-17T08:11:33.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2025-05-22T12:16:40.000Z (6 months ago)
- Last Synced: 2025-06-23T17:51:01.755Z (4 months ago)
- Language: Swift
- Homepage:
- Size: 439 KB
- Stars: 30
- Watchers: 1
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - GXSegmentPageView - Swift版分段分页组件,(网易新闻、腾讯新闻、新浪微博、今日头条等Tab效果) (iOS / PageView)
- awesome - GXSegmentPageView - Swift版分段分页组件,(网易新闻、腾讯新闻、新浪微博、今日头条等Tab效果) (iOS / PageView)
README
# GXSegmentPageView
Swift版分段分页组件,(网易新闻、腾讯新闻、新浪微博、今日头条等Tab效果)。
有建议可以联系QQ交流群:1101980843,喜欢就给个star哦,谢谢关注!
先上Demo效果图
--
Requirements
--
Usage in you Podfile:
--
```
pod 'GXSegmentPageView'
```
GXSegmentTitleView
--
```swift
// 代码创建
let config = GXSegmentTitleView.Configuration()
config.positionStyle = .none
config.indicatorStyle = .dynamic
config.indicatorFixedWidth = 30.0
config.indicatorFixedHeight = 2.0
config.indicatorAdditionWidthMargin = 5.0
config.indicatorAdditionHeightMargin = 2.0
config.isShowSeparator = true
config.separatorInset = UIEdgeInsets(top: 10, left: 0, bottom: 10, right: 0)
let titleView = GXSegmentTitleView(frame: self.bounds, config: config, titles: titles)
// XIB创建需要调用此方法配置数据
@IBOutlet weak var titleView: GXSegmentTitleView!
self.titleView.setupSegmentTitleView(config: config, titles: self.items)
// 回调代理方法
@objc protocol GXSegmentTitleViewDelegate: NSObjectProtocol {
@objc optional func segmentTitleView(_ page: GXSegmentTitleView, at index: Int)
}
```
GXSegmentPageView
--
```swift
// 代码创建
let pageView: GXSegmentPageView = GXSegmentPageView(parent: self, children: childVCs)
// XIB创建需要调用此方法配置数据
@IBOutlet weak var pageView: GXSegmentPageView!
self.pageView.setupSegmentPageView(parent: self, children: childVCs)
```
GXSegmentTitleView & GXSegmentPageView
--
```swift
// 两个控件联动使用只需实现两者的代理
extension ViewController: GXSegmentPageViewDelegate {
func segmentPageView(_ segmentPageView: GXSegmentPageView, at index: Int) {
NSLog("index = %d", index)
}
func segmentPageView(_ page: GXSegmentPageView, progress: CGFloat) {
self.titleView.setSegmentTitleView(currentIndex: page.selectIndex, willIndex: page.willSelectIndex, progress: progress)
}
}
extension ViewController: GXSegmentTitleViewDelegate {
func segmentTitleView(_ page: GXSegmentTitleView, at index: Int) {
self.pageView.scrollToItem(to: index, animated: true)
}
}
```
License
--
MIT