-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUIBarButtonItemVC.swift
44 lines (34 loc) · 1.27 KB
/
UIBarButtonItemVC.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// UIBarButtonItemViewController.swift
// UIKitDemo
//
// Created by Kyrie Miyajima on 2015/02/09.
// Copyright (c) 2015年 Kirie Miyajima. All rights reserved.
//
import UIKit
class UIBarButtonItemViewController:UIViewController {
var myLeftButton:UIBarButtonItem!
var myRightButton:UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad();
self.title = "UIBarButtonItem";
self.view.backgroundColor = UIColor.whiteColor();
self.navigationController?.navigationBar;
myLeftButton = UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: #selector(self.onClick(_:)));
myLeftButton.tag = 1;
myRightButton = UIBarButtonItem(title: "RightButton", style: .Plain, target: self, action: #selector(self.onClick(_:)));
myRightButton.tag = 2;
self.navigationItem.rightBarButtonItem = myLeftButton;
}
func onClick(sender: UIButton){
switch(sender.tag){
case 1:
self.view.backgroundColor = UIColor(red:1, green:0, blue:0, alpha:1);
case 2:
self.view.backgroundColor = UIColor(red:1, green:0.59, blue:0.11, alpha:1);
default:
print("Error");
break;
}
}
}