smartnews風UIのライブラリ
https://github.com/EndouMari/TabPageViewController
こちらのサンプルにあった以下
https://github.com/EndouMari/TabPageViewController/blob/master/Example/TabPageViewController/ViewController.swift
は実行できました。
swift
1let tc = TabPageViewController.create() 2 let vc1 = UIViewController() 3 vc1.view.backgroundColor = UIColor(red: 2/255, green: 2/255, blue: 1/255, alpha: 1.0) 4 let vc2 = UIViewController() 5 vc2.view.backgroundColor = UIColor(red: 252/255, green: 150/255, blue: 149/255, alpha: 1.0) 6 let vc3 = UIViewController() 7 vc3.view.backgroundColor = UIColor(red: 149/255, green: 218/255, blue: 252/255, alpha: 1.0) 8 let vc4 = UIViewController() 9 vc4.view.backgroundColor = UIColor(red: 149/255, green: 252/255, blue: 197/255, alpha: 1.0) 10 let vc5 = UIViewController() 11 vc5.view.backgroundColor = UIColor(red: 252/255, green: 182/255, blue: 106/255, alpha: 1.0) 12 tc.tabItems = [(vc1, "Mon."), (vc2, "Tue."), (vc3, "Wed."), (vc4, "Thu."), (vc5, "Fri.")] 13 tc.isInfinity = true 14 let nc = UINavigationController() 15 nc.viewControllers = [tc] 16 var option = TabPageOption() 17 option.currentColor = UIColor(red: 246/255, green: 175/255, blue: 32/255, alpha: 1.0) 18 tc.option = option 19 navigationController?.pushViewController(tc, animated: true)
ただ、左上や右上にナビゲーションのボタンなども設置した方ため、
TabPageViewController.create()で生成されるPageViewControllerのインスタンスにそういうコードを追加したいと思ってます。
思いつく方法として以下のようにTabPageViewControllerを継承してサブクラスを作り、そこに色々コードを記述するのが良いかと思ったのですが、
swift
1 2import UIKit 3import TabPageViewController 4 5class PagenewViewController: TabPageViewController { 6 override func viewDidAppear(animated: Bool) { 7 super.viewDidAppear(animated) 8 let vc1 = UIViewController() 9 vc1.view.backgroundColor = UIColor(red: 251/255, green: 252/255, blue: 149/255, alpha: 1.0) 10 let vc2 = UIViewController() 11 vc2.view.backgroundColor = UIColor(red: 252/255, green: 150/255, blue: 149/255, alpha: 1.0) 12 let vc3 = UIViewController() 13 vc3.view.backgroundColor = UIColor(red: 149/255, green: 218/255, blue: 252/255, alpha: 1.0) 14 let vc4 = UIViewController() 15 vc4.view.backgroundColor = UIColor(red: 149/255, green: 252/255, blue: 197/255, alpha: 1.0) 16 let vc5 = UIViewController() 17 vc5.view.backgroundColor = UIColor(red: 252/255, green: 182/255, blue: 106/255, alpha: 1.0) 18 self.tabItems = [(vc1, "Mon."), (vc2, "Tue."), (vc3, "Wed."), (vc4, "Thu."), (vc5, "Fri.")] 19 self.isInfinity = true 20 21 let nc = UINavigationController() 22 nc.viewControllers = [self] 23 var option = TabPageOption() 24 option.currentColor = UIColor(red: 246/255, green: 175/255, blue: 32/255, alpha: 1.0) 25 self.option = option 26 navigationController?.pushViewController(self, animated: true)
アボートしてしまいました。
tabItemsにデータ入れているはずだし・・・、どこがおかしいのだろうと思ってます。わかる方お願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/07/27 00:55