Extension homeviewcontroller{private func Setupnavigationbar () {/*** set navigation bar background color ***/ Navigationcontroller?. Navigationbar.bartintcolor = uicolor.red/*** Set nav bar title ***///Self.title = "NetEase News "Navigationcontroller?"
Navigationbar.titletextattributes = [NSAttributedStringKey.foregroundColor:UIColor.white]//Custom View settings title Let Titlelabel = UILabel (Frame:cgrect (x:0, y:0, width:40, height:40)) Titlelabel.text = "NetEase News" Ti Tlelabel.textcolor = Uicolor.white Navigationitem.titleview = titlelabel//Picture Let ImageView = UII
Mageview (Image:uiimage (named: "Contentview_imagebg_logo")) Navigationitem.titleview = ImageView/*** Set the navigation bar left and Right buttons ***///text Let Leftbarbuttonitem = Uibarbuttonitem (title: "LeftButton", style:. pl Ain, target:self, Action: #selector (Self.leftclick)) Let Rightbarbuttonitem = UIBarbuttonitem (title: "Rightbutton", Style:. Plain, target:self, Action: #selector (Self.rightclick)) Navigationit
Em.leftbarbuttonitem = Leftbarbuttonitem Navigationitem.rightbarbuttonitem = rightbarbuttonitem//Picture Navigationitem.leftbarbuttonitem = Uibarbuttonitem (Image:uiimage (named: "Fog"), style:. Plain, target:self, action: #selector (self.leftclick)) Navigationitem.rightbarbuttonitem = Uibarbuttonitem (Image:uiimage (named: "Fog"), style :. Plain, target:self, Action: #selector (Self.rightclick))//Custom Let LeftButton = UIButton (frame:cgrect
(x:0, y:0, width:40, height:40)) Let Rightbutton = UIButton (Frame:cgrect (x:0, y:0, width:40, height:40)) Leftbutton.settitlecolor (Uicolor.blac K, For:UIControlState.normal) Rightbutton.settitlecolor (Uicolor.black, For:UIControlState.normal) LEFTBU Tton.settitle ("LeftButton", For:UIControlState.normal) rightbutton.settitle ("Rightbutton", FOr:UIControlState.normal) Leftbutton.addtarget (Self, Action: #selector (Leftclick), for:UIControlEvents.touchUpIn side) Rightbutton.addtarget (Self, Action: #selector (RightClick), for:UIControlEvents.touchUpInside) Navig Ationitem.leftbarbuttonitem = Uibarbuttonitem (customview:leftbutton) Navigationitem.rightbarbuttonitem = UIBarBut
Tonitem (Customview:rightbutton)//Barbuttonitem Color leftbarbuttonitem.tintcolor = uicolor.black} @objc private func Leftclick () {print ("Leftclick")} @objc private Func RightClick () {print (" RightClick ")}}