回答編集履歴
2
修正
test
CHANGED
@@ -11,3 +11,53 @@
|
|
11
11
|
|
12
12
|
|
13
13
|
![s](8e84960011c6b17fc101f2bc3ad7ef67.png)
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
コードで追加する場合
|
18
|
+
|
19
|
+
```swift
|
20
|
+
|
21
|
+
import UIKit
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
class ViewController: UIViewController {
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
var titleButton = UIButton(type: .Custom)
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
override func viewDidLoad() {
|
34
|
+
|
35
|
+
super.viewDidLoad()
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
titleButton.setTitle("タイトル名", forState: .Normal)
|
40
|
+
|
41
|
+
titleButton.backgroundColor = UIColor.redColor()
|
42
|
+
|
43
|
+
titleButton.frame = CGRect(x: 0, y: 0, width: 100, height: 40)
|
44
|
+
|
45
|
+
titleButton.addTarget(self, action: #selector(ViewController.pushTittle(_:)), forControlEvents: .TouchUpInside)
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
self.navigationItem.titleView = titleButton
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
func pushTittle(sender: UIButton) {
|
56
|
+
|
57
|
+
print("Push Button!")
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
```
|
1
修正
test
CHANGED
@@ -7,3 +7,7 @@
|
|
7
7
|
`@IBOutlet`も`UIViewController`に対して結んでアクションを定義できます。
|
8
8
|
|
9
9
|
そこで遷移等の処理をすれば良いと思います。
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
![s](8e84960011c6b17fc101f2bc3ad7ef67.png)
|