1
2
|
let
item =
UIBarButtonItem
(title:
"返回"
, style: .
Plain
, target:
self
, action:
nil
)
self
.navigationItem.backBarButtonItem = item;
|
1
2
|
let
item =
UIBarButtonItem
(title:
""
, style: .
Plain
, target:
self
, action:
nil
)
self
.navigationItem.backBarButtonItem = item;
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import
UIKit
class
DetailViewController
:
UIViewController
{
override
func
viewDidLoad() {
super
.viewDidLoad()
let
leftBarBtn =
UIBarButtonItem
(title:
"返回"
, style: .
Plain
, target:
self
,
action:
"backToPrevious"
)
self
.navigationItem.leftBarButtonItem = leftBarBtn
}
//返回按钮点击响应
func
backToPrevious(){
self
.navigationController?.popViewControllerAnimated(
true
)
}
override
func
didReceiveMemoryWarning() {
super
.didReceiveMemoryWarning()
}
}
|
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
|
import
UIKit
class
DetailViewController
:
UIViewController
{
override
func
viewDidLoad() {
super
.viewDidLoad()
let
leftBarBtn =
UIBarButtonItem
(title:
""
, style: .
Plain
, target:
self
,
action:
"backToPrevious"
)
leftBarBtn.image =
UIImage
(named:
"back"
)
//用于消除左边空隙,要不然按钮顶不到最前面
let
spacer =
UIBarButtonItem
(barButtonSystemItem: .
FixedSpace
, target:
nil
, action:
nil
)
spacer.width = -10;
self
.navigationItem.leftBarButtonItems = [spacer, leftBarBtn]
}
//返回按钮点击响应
func
backToPrevious(){
self
.navigationController?.popViewControllerAnimated(
true
)
}
override
func
didReceiveMemoryWarning() {
super
.didReceiveMemoryWarning()
}
}
|
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
|
import
UIKit
class
DetailViewController
:
UIViewController
{
override
func
viewDidLoad() {
let
button =
UIButton
(type: .
System
)
button.frame =
CGRectMake
(0, 0, 65, 30)
button.setImage(
UIImage
(named:
"back"
), forState: .
Normal
)
button.setTitle(
"返回"
, forState: .
Normal
)
button.addTarget(
self
, action:
"backToPrevious"
, forControlEvents: .
TouchUpInside
)
let
leftBarBtn =
UIBarButtonItem
(customView: button)
//用于消除左边空隙,要不然按钮顶不到最前面
let
spacer =
UIBarButtonItem
(barButtonSystemItem: .
FixedSpace
, target:
nil
, action:
nil
)
spacer.width = -10;
self
.navigationItem.leftBarButtonItems = [spacer,leftBarBtn]
}
//返回按钮点击响应
func
backToPrevious(){
self
.navigationController?.popViewControllerAnimated(
true
)
}
override
func
didReceiveMemoryWarning() {
super
.didReceiveMemoryWarning()
}
}
|