NSPageView一个纯Swift的轻量级、灵活且易于使用的pageView框架,titleView和contentView可以布局在任意地方,可以纯代码初始化,也可以使用xib或者storyboard初始化,并且提供了常见样式属性进行设置。
如果你使用的开发语言是Objective-C,请使用DNSPageView-ObjC
Features:
- 使用简单
- 多种初始化方式
- 灵活布局
- 常见的样式
- 双击titleView的回调
- contentView滑动监听
Requirements
-
iOS 8.0+
-
Xcode 10.0+
-
Swift 4.2+
Installation
CocoaPods
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
CocoaPods 1.1+ is required to build DNSPageView.
To integrate DNSPageView into your Xcode project using CocoaPods, specify it in your Podfile
:
Then, run the following command:
Manually
If you prefer not to use any of the aforementioned dependency managers, you can integrate DNSPageView into your project manually.
Example
To run the example project, clone the repo, and run DNSPageView.xcodeproj
.
Usage
直接使用DNSPageView初始化
使用xib或者storyboard初始化
在xib或者storyboard中拖出2个UIView,让它们分别继承DNSPageTitleView和DNSPageContentView,拖线到代码中
对DNSPageTitleView和DNSPageContentView进行设置
使用DNSPageViewManager初始化,再分别对titleView和contentView进行布局
创建DNSPageViewManager
布局titleView和contentView
样式
DNSPageStyle中提供了常见样式的属性,可以按照不同的需求进行设置,包括可以设置初始显示的页面
事件监听
DNSPageView提供了常见事件监听的代理,它属于DNSPageTitleViewDelegate的中的可选属性
链接:https://swift.ctolib.com/article/wiki/78270