/SwiftTTPageController

最常见的标签控制器,仿今日头条首页、网易新闻首页 ,实现多个ViewController列表切换(更新适配Swift5)

Primary LanguageSwiftMIT LicenseMIT

SwiftTTPageController

仿网易新闻、头条等首页列表切换效果,实现多个ViewController列表切换;

  • Swift 5.0+ ,Xcode 11.4

效果如下:

TTTagListController

安装

pod 'SwiftTTPageController'

应用

  • 创建HeadView
let titles = ["新闻","视频","最新","新闻","视频","最新","军事","头条"]
        
let headView = TTHeadView (frame: CGRect (x: 0, y: 0, width: UIScreen.main.bounds.width, height: 30), titles: titles, delegate: self)
        
navigationItem.titleView = headView;
        
  • 创建列表控制器,并添加到父控制器之上
let vcs = [TableViewController(),TableViewController(),TableViewController(),TableViewController(),TableViewController(),TableViewController(),TableViewController(),TableViewController(),]
        
let frame = CGRect (x: 0, y: 0, width: view.frame.width, height: view.frame.height)

let pagevc = TTPageViewController.init(controllers: vcs, frame: frame, delegate: self)
        
self.addChildViewController(pagevc)
self.view.addSubview(pagevc.view)
        
  • 遵守协议TTHeadViewDelegate,TTPageViewControllerDelegate 实现代理方法,处理事件
    /////Delegate methods
    func tt_headViewSelectedAt(_ index: Int) {
        pagevc.scrollToPageAtIndex(index)
    }
    
    func tt_pageControllerSelectedAt(_ index: Int) {
        headView.scrollToItemAtIndex(index)
    }

License

See LICENSE file for details