facebook twitter hatena line google mixi email

Ios/swift/外部ライブラリ/TabPageViewController

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

TabPageViewControllerとは

無限スクロール付きPageViewライブラリ

Ios/swift/外部ライブラリ/PagingMenuController [ショートカット]

よりこちらの方が良い

公式:https://github.com/EndouMari/TabPageViewController

参考:http://tech.vasily.jp/entry/tab_page_viewcontroller

公式サンプル

       let tc = TabPageViewController.create()
       let vc1 = UIViewController()
       vc1.view.backgroundColor = UIColor(red: 251/255, green: 252/255, blue: 149/255, alpha: 1.0)
       let vc2 = UIViewController()
       vc2.view.backgroundColor = UIColor(red: 252/255, green: 150/255, blue: 149/255, alpha: 1.0)
       let vc3 = UIViewController()
       vc3.view.backgroundColor = UIColor(red: 149/255, green: 218/255, blue: 252/255, alpha: 1.0)
       let vc4 = UIViewController()
       vc4.view.backgroundColor = UIColor(red: 149/255, green: 252/255, blue: 197/255, alpha: 1.0)
       let vc5 = UIViewController()
       vc5.view.backgroundColor = UIColor(red: 252/255, green: 182/255, blue: 106/255, alpha: 1.0)
       tc.tabItems = [(vc1, "Mon."), (vc2, "Tue."), (vc3, "Wed."), (vc4, "Thu."), (vc5, "Fri.")]
       tc.isInfinity = true
       let nc = UINavigationController()
       nc.viewControllers = [tc]
       var option = TabPageOption()
       option.currentColor = UIColor(red: 246/255, green: 175/255, blue: 32/255, alpha: 1.0)
       tc.option = option
       navigationController?.pushViewController(tc, animated: true)

サブクラスで継承してタイプのサンプル

-AppDelegate.swift

import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
   var window: UIWindow?
   var navigationController: UINavigationController!
   func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
       let tc = storyboard?.instantiateViewControllerWithIdentifier("CustomTabPageViewControllerId") as! CustomTabPageViewController
       let vc1 = UIViewController()
       vc1.view.backgroundColor = UIColor(red: 251/255, green: 252/255, blue: 149/255, alpha: 1.0)
       let vc2 = UIViewController()
       vc2.view.backgroundColor = UIColor(red: 252/255, green: 150/255, blue: 149/255, alpha: 1.0)
       let vc3 = UIViewController()
       vc3.view.backgroundColor = UIColor(red: 149/255, green: 218/255, blue: 252/255, alpha: 1.0)
       let vc4 = UIViewController()
       vc4.view.backgroundColor = UIColor(red: 149/255, green: 252/255, blue: 197/255, alpha: 1.0)
       let vc5 = UIViewController()
       vc5.view.backgroundColor = UIColor(red: 252/255, green: 182/255, blue: 106/255, alpha: 1.0)
       tc.tabItems = [(vc1, "Mon."), (vc2, "Tue."), (vc3, "Wed."), (vc4, "Thu."), (vc5, "Fri.")]
       tc.isInfinity = true
       let nc = UINavigationController()
       nc.viewControllers = [tc]
       var option = TabPageOption()
       option.currentColor = UIColor(red: 246/255, green: 175/255, blue: 32/255, alpha: 1.0)
       tc.option = option
       navigationController?.pushViewController(tc, animated: true)
   }
}

-CustomTabPageViewController.swift

import UIKit
import TabPageViewController
class CustomTabPageViewController: TabPageViewController {
   override func viewDidLoad() {
       super.viewDidLoad()   
   }
   @IBAction func pushItem(sender: UIBarButtonItem) {
       print("Push Navi Item")
   }
   override func didReceiveMemoryWarning() {
       super.didReceiveMemoryWarning()
   }
}

参考:https://teratail.com/questions/42126