teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

修正

2016/07/26 12:22

投稿

_Kentarou
_Kentarou

スコア8490

answer CHANGED
@@ -1,33 +1,83 @@
1
- 以下のようにすることでできるとおもいます。
1
+ サブクラスを作成して以下のようにすることでできるといます。
2
- 分からなければコメトで聞いてください、、、と思いましたが、サブクラス化したいということでしたね
2
+ ※本家のサプルを変更してるので、関係ある部分のみ見てください。
3
- 夜にでも追記します。
4
3
 
5
4
  ```swift
5
+ import UIKit
6
+ import TabPageViewController
7
+
8
+ class ViewController: UIViewController {
9
+
10
+ override func viewDidLoad() {
11
+ super.viewDidLoad()
12
+ // Do any additional setup after loading the view, typically from a nib
13
+ }
14
+
15
+ override func didReceiveMemoryWarning() {
16
+ super.didReceiveMemoryWarning()
17
+ // Dispose of any resources that can be recreated.
18
+ }
19
+
20
+ @IBAction func LimitedButton(button: UIButton) {
21
+ let tc = TabPageViewController.create()
22
+ let vc1 = UIViewController()
23
+ vc1.view.backgroundColor = UIColor.whiteColor()
24
+ let vc2 = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("ListViewController")
25
+ tc.tabItems = [(vc1, "First"), (vc2, "Second")]
26
+ tc.displayControllerWithIndex(1, direction: .Forward, animated: false)
27
+ var option = TabPageOption()
28
+ option.tabWidth = view.frame.width / CGFloat(tc.tabItems.count)
29
+ tc.option = option
30
+ navigationController?.pushViewController(tc, animated: true)
31
+ }
32
+
6
- @IBAction func InfinityButton(button: UIButton) {
33
+ @IBAction func InfinityButton(button: UIButton) {
34
+
35
+ let tc = storyboard?.instantiateViewControllerWithIdentifier("pageView") as! PagenewViewController
36
+
37
+ let vc1 = UIViewController()
38
+ vc1.view.backgroundColor = UIColor(red: 251/255, green: 252/255, blue: 149/255, alpha: 1.0)
39
+ let vc2 = UIViewController()
40
+ vc2.view.backgroundColor = UIColor(red: 252/255, green: 150/255, blue: 149/255, alpha: 1.0)
41
+ let vc3 = UIViewController()
42
+ vc3.view.backgroundColor = UIColor(red: 149/255, green: 218/255, blue: 252/255, alpha: 1.0)
43
+ let vc4 = UIViewController()
44
+ vc4.view.backgroundColor = UIColor(red: 149/255, green: 252/255, blue: 197/255, alpha: 1.0)
45
+ let vc5 = UIViewController()
46
+ vc5.view.backgroundColor = UIColor(red: 252/255, green: 182/255, blue: 106/255, alpha: 1.0)
47
+ tc.tabItems = [(vc1, "Mon."), (vc2, "Tue."), (vc3, "Wed."), (vc4, "Thu."), (vc5, "Fri.")]
48
+ tc.isInfinity = true
49
+
50
+ let nc = UINavigationController()
51
+ nc.viewControllers = [tc]
52
+
53
+ var option = TabPageOption()
54
+ option.currentColor = UIColor(red: 246/255, green: 175/255, blue: 32/255, alpha: 1.0)
55
+ tc.option = option
56
+ navigationController?.pushViewController(tc, animated: true)
57
+ }
58
+ }
59
+
60
+
61
+ // --------------------------------------------------
62
+
63
+ import UIKit
64
+ import TabPageViewController
65
+
66
+ class PagenewViewController: TabPageViewController {
67
+
68
+ override func viewDidLoad() {
69
+ super.viewDidLoad()
70
+ }
71
+
72
+ @IBAction func pushItem(sender: UIBarButtonItem) {
73
+ print("PUsh Navi Item")
74
+ }
7
75
 
8
- let tc = storyboard?.instantiateViewControllerWithIdentifier("pageView") as! TabPageViewController
76
+ override func didReceiveMemoryWarning() {
9
-
10
- let vc1 = UIViewController()
77
+ super.didReceiveMemoryWarning()
11
- vc1.view.backgroundColor = UIColor(red: 251/255, green: 252/255, blue: 149/255, alpha: 1.0)
12
- let vc2 = UIViewController()
13
- vc2.view.backgroundColor = UIColor(red: 252/255, green: 150/255, blue: 149/255, alpha: 1.0)
14
- let vc3 = UIViewController()
15
- vc3.view.backgroundColor = UIColor(red: 149/255, green: 218/255, blue: 252/255, alpha: 1.0)
16
- let vc4 = UIViewController()
17
- vc4.view.backgroundColor = UIColor(red: 149/255, green: 252/255, blue: 197/255, alpha: 1.0)
18
- let vc5 = UIViewController()
19
- vc5.view.backgroundColor = UIColor(red: 252/255, green: 182/255, blue: 106/255, alpha: 1.0)
20
- tc.tabItems = [(vc1, "Mon."), (vc2, "Tue."), (vc3, "Wed."), (vc4, "Thu."), (vc5, "Fri.")]
21
- tc.isInfinity = true
22
-
23
- let nc = UINavigationController()
24
- nc.viewControllers = [tc]
25
-
26
- var option = TabPageOption()
27
- option.currentColor = UIColor(red: 246/255, green: 175/255, blue: 32/255, alpha: 1.0)
28
- tc.option = option
78
+ }
29
- navigationController?.pushViewController(tc, animated: true)
30
79
  }
31
80
  ```
32
81
 
33
- ![e](8b41b2dfda13d9d22262e41f7c458e67.png)
82
+ ![e](af34134fb08b1b4ac74a61bc247e1108.png)
83
+ ![g](123ca4252bdd85a12e9125a14d3e8daf.png)

1

修正

2016/07/26 12:22

投稿

_Kentarou
_Kentarou

スコア8490

answer CHANGED
@@ -1,5 +1,6 @@
1
1
  以下のようにすることでできるとおもいます。
2
- 分からなければコメントで聞いてください。
2
+ 分からなければコメントで聞いてください、、、と思いましたが、サブクラス化したいということでしたね
3
+ 夜にでも追記します。
3
4
 
4
5
  ```swift
5
6
  @IBAction func InfinityButton(button: UIButton) {