回答編集履歴
2
修正
test
CHANGED
@@ -1,60 +1,158 @@
|
|
1
|
-
以下のようにすることでできると
|
1
|
+
サブクラスを作成して以下のようにすることでできると思います。
|
2
2
|
|
3
|
-
|
3
|
+
※本家のサンプルを変更しているので、関係ある部分のみ見てください。
|
4
|
-
|
5
|
-
夜にでも追記します。
|
6
4
|
|
7
5
|
|
8
6
|
|
9
7
|
```swift
|
10
8
|
|
9
|
+
import UIKit
|
10
|
+
|
11
|
+
import TabPageViewController
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
class ViewController: UIViewController {
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
override func viewDidLoad() {
|
20
|
+
|
21
|
+
super.viewDidLoad()
|
22
|
+
|
23
|
+
// Do any additional setup after loading the view, typically from a nib
|
24
|
+
|
25
|
+
}
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
override func didReceiveMemoryWarning() {
|
30
|
+
|
31
|
+
super.didReceiveMemoryWarning()
|
32
|
+
|
33
|
+
// Dispose of any resources that can be recreated.
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
@IBAction func LimitedButton(button: UIButton) {
|
40
|
+
|
41
|
+
let tc = TabPageViewController.create()
|
42
|
+
|
43
|
+
let vc1 = UIViewController()
|
44
|
+
|
45
|
+
vc1.view.backgroundColor = UIColor.whiteColor()
|
46
|
+
|
47
|
+
let vc2 = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("ListViewController")
|
48
|
+
|
49
|
+
tc.tabItems = [(vc1, "First"), (vc2, "Second")]
|
50
|
+
|
51
|
+
tc.displayControllerWithIndex(1, direction: .Forward, animated: false)
|
52
|
+
|
53
|
+
var option = TabPageOption()
|
54
|
+
|
55
|
+
option.tabWidth = view.frame.width / CGFloat(tc.tabItems.count)
|
56
|
+
|
57
|
+
tc.option = option
|
58
|
+
|
59
|
+
navigationController?.pushViewController(tc, animated: true)
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
|
11
|
-
@IBAction func InfinityButton(button: UIButton) {
|
65
|
+
@IBAction func InfinityButton(button: UIButton) {
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
let tc = storyboard?.instantiateViewControllerWithIdentifier("pageView") as! PagenewViewController
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
let vc1 = UIViewController()
|
74
|
+
|
75
|
+
vc1.view.backgroundColor = UIColor(red: 251/255, green: 252/255, blue: 149/255, alpha: 1.0)
|
76
|
+
|
77
|
+
let vc2 = UIViewController()
|
78
|
+
|
79
|
+
vc2.view.backgroundColor = UIColor(red: 252/255, green: 150/255, blue: 149/255, alpha: 1.0)
|
80
|
+
|
81
|
+
let vc3 = UIViewController()
|
82
|
+
|
83
|
+
vc3.view.backgroundColor = UIColor(red: 149/255, green: 218/255, blue: 252/255, alpha: 1.0)
|
84
|
+
|
85
|
+
let vc4 = UIViewController()
|
86
|
+
|
87
|
+
vc4.view.backgroundColor = UIColor(red: 149/255, green: 252/255, blue: 197/255, alpha: 1.0)
|
88
|
+
|
89
|
+
let vc5 = UIViewController()
|
90
|
+
|
91
|
+
vc5.view.backgroundColor = UIColor(red: 252/255, green: 182/255, blue: 106/255, alpha: 1.0)
|
92
|
+
|
93
|
+
tc.tabItems = [(vc1, "Mon."), (vc2, "Tue."), (vc3, "Wed."), (vc4, "Thu."), (vc5, "Fri.")]
|
94
|
+
|
95
|
+
tc.isInfinity = true
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
let nc = UINavigationController()
|
100
|
+
|
101
|
+
nc.viewControllers = [tc]
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
var option = TabPageOption()
|
106
|
+
|
107
|
+
option.currentColor = UIColor(red: 246/255, green: 175/255, blue: 32/255, alpha: 1.0)
|
108
|
+
|
109
|
+
tc.option = option
|
110
|
+
|
111
|
+
navigationController?.pushViewController(tc, animated: true)
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
// --------------------------------------------------
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
import UIKit
|
126
|
+
|
127
|
+
import TabPageViewController
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
class PagenewViewController: TabPageViewController {
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
override func viewDidLoad() {
|
136
|
+
|
137
|
+
super.viewDidLoad()
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
@IBAction func pushItem(sender: UIBarButtonItem) {
|
144
|
+
|
145
|
+
print("PUsh Navi Item")
|
146
|
+
|
147
|
+
}
|
12
148
|
|
13
149
|
|
14
150
|
|
15
|
-
|
151
|
+
override func didReceiveMemoryWarning() {
|
16
152
|
|
17
|
-
|
153
|
+
super.didReceiveMemoryWarning()
|
18
154
|
|
19
|
-
let vc1 = UIViewController()
|
20
|
-
|
21
|
-
vc1.view.backgroundColor = UIColor(red: 251/255, green: 252/255, blue: 149/255, alpha: 1.0)
|
22
|
-
|
23
|
-
let vc2 = UIViewController()
|
24
|
-
|
25
|
-
vc2.view.backgroundColor = UIColor(red: 252/255, green: 150/255, blue: 149/255, alpha: 1.0)
|
26
|
-
|
27
|
-
let vc3 = UIViewController()
|
28
|
-
|
29
|
-
vc3.view.backgroundColor = UIColor(red: 149/255, green: 218/255, blue: 252/255, alpha: 1.0)
|
30
|
-
|
31
|
-
let vc4 = UIViewController()
|
32
|
-
|
33
|
-
vc4.view.backgroundColor = UIColor(red: 149/255, green: 252/255, blue: 197/255, alpha: 1.0)
|
34
|
-
|
35
|
-
let vc5 = UIViewController()
|
36
|
-
|
37
|
-
vc5.view.backgroundColor = UIColor(red: 252/255, green: 182/255, blue: 106/255, alpha: 1.0)
|
38
|
-
|
39
|
-
tc.tabItems = [(vc1, "Mon."), (vc2, "Tue."), (vc3, "Wed."), (vc4, "Thu."), (vc5, "Fri.")]
|
40
|
-
|
41
|
-
tc.isInfinity = true
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
let nc = UINavigationController()
|
46
|
-
|
47
|
-
nc.viewControllers = [tc]
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
var option = TabPageOption()
|
52
|
-
|
53
|
-
option.currentColor = UIColor(red: 246/255, green: 175/255, blue: 32/255, alpha: 1.0)
|
54
|
-
|
55
|
-
|
155
|
+
}
|
56
|
-
|
57
|
-
navigationController?.pushViewController(tc, animated: true)
|
58
156
|
|
59
157
|
}
|
60
158
|
|
@@ -62,4 +160,6 @@
|
|
62
160
|
|
63
161
|
|
64
162
|
|
65
|
-
![e](8b
|
163
|
+
![e](af34134fb08b1b4ac74a61bc247e1108.png)
|
164
|
+
|
165
|
+
![g](123ca4252bdd85a12e9125a14d3e8daf.png)
|
1
修正
test
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
以下のようにすることでできるとおもいます。
|
2
2
|
|
3
|
-
分からなければコメントで聞いてください。
|
3
|
+
分からなければコメントで聞いてください、、、と思いましたが、サブクラス化したいということでしたね。
|
4
|
+
|
5
|
+
夜にでも追記します。
|
4
6
|
|
5
7
|
|
6
8
|
|