Latest 0.6.0
Homepage https://github.com/WJCha/WJPageView
License MIT
Platforms ios 8.0, requires ARC
Authors

Version
License
Platform

WJPageView是一个纯swift编写的易用的标题栏和控制器切换交互工具视图。

Demo

WJPageView
WJPageView

Components

Components

  • WJPageTitleBarView对应用于创建标题栏titleBar,通过WJPageViewConfig来控制器样式,
  • WJPageContainerView对应用于创建内容页,通过WJPageViewConfig来控制器样式
  • WJPageView包含两个属性,即分别对应标题栏和内容页视图,通过该类可以快速创建含有标题栏和内容页的处理交互页面
  • WJPageTitleBarViewWJPageContainerView之间通过代理完成标题栏和内容页的交互操作

WJPageTitleBarView 样式结构

为了方便大家控制该类创建标题栏样式,现针对其做一个简要图示说明

titleBarView

Requirements

  • iOS 8.0+
  • Xcode 9.0+
  • Swift 4.0+

Installation

CocoaPods

Podfile 文件编写

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target 'TargetName' do
  pod 'WJPageView'
end

执行安装

pod install

Manually

如果要手工导入的话,只需下载该项目,将 WJPageView目录拖入项目即可

Usage

快速创建标题栏和内容页

    // titles
    private lazy var titles: [String] = ["音乐", "视频", "推荐"]
    // childViewControllers
    let childVCs: [UIViewController] = [
        WJMusicViewController(),
        WJVideoViewController(),
        WJRecommendViewController()
    ]
    // WJPageViewConfig style
    private lazy var config: WJPageViewConfig = {
        let config = WJPageViewConfig()
        config.titleBarBgColor = UIColor(red: 240/255, green: 240/255, blue: 240/255, alpha: 1.0)
        config.titleSelectedColor = .red
        config.indecatorBottomOffset = 2
        return config
    }()
    // create WJPageView
    let pageView = WJPageView(config: config, titles: titles, childViewControllers: childVCs)
    // 注意 pageContainerView 和 titleBarView 的添加顺序,确保布局时 titleBarView 不会被 pageContainerView 遮盖
    view.addSubview(pageView.pageContainerView)
    view.addSubview(pageView.titleBarView)

     // 分别布局titleBarView和pageContainerView,可以使用Autolayout或frame布局
    pageView.titleBarView.snp.makeConstraints { (make) in
        make.left.right.equalToSuperview()
        make.top.equalTo(kNavigationBarHeight)
        make.height.equalTo(44)
    }
    pageView.pageContainerView.snp.makeConstraints { (make) in
        make.top.equalTo(pageView.titleBarView.snp.bottom)
        make.left.right.bottom.equalToSuperview()
    }

更多案例请下载该项目运行查看

监听标题重复点击

要想监听标题重复点击事件,可以在子控制器中遵守WJPageReloadable协议,实现 titleBarViewTitleDidRepeatClicked()方法即可

extension WJMusicViewController: WJPageReloadable {
    func titleBarViewTitleDidRepeatClicked() {
        print("音乐标题重复点击")
    }
}

该监听代理属于 WJPageTitleBarViewDelegat 中一个可选属性,通过其还可以获取内容页滚动停止的事件

@objc public protocol WJPageReloadable: NSObjectProtocol {

    /// 监听标题重复点击事件
    @objc optional func titleBarViewTitleDidRepeatClicked()

    /// 监听 pageContentView 滚动停止
    @objc optional func pageContaionerViewDidEndScroll()
}

License

WJPageView is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "WJPageView",
    "version": "0.6.0",
    "summary": "WJPageView is a title bar  and controller interactive tool",
    "swift_version": "4.0",
    "description": "An easy to use the title bar of the view and controller interactive tool",
    "homepage": "https://github.com/WJCha/WJPageView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "WJCha": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/WJCha/WJPageView.git",
        "tag": "0.6.0"
    },
    "source_files": "WJPageView/WJPageView/WJPageView/*.swift",
    "requires_arc": true,
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "4.0"
    }
}

Pin It on Pinterest

Share This