Coder Social home page Coder Social logo

zhaocw8888 / swiftttpagecontroller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from light413/swiftttpagecontroller

0.0 0.0 0.0 328 KB

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

License: MIT License

Swift 93.90% Ruby 6.10%

swiftttpagecontroller's Introduction

SwiftTTPageController

仿网易新闻、头条等首页列表切换效果

Swift 3.0+ ,Xcode8.0 +

实现多个ViewController列表切换;

效果如下:

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

swiftttpagecontroller's People

Contributors

light413 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.