swift - iOS navigationBar not changing color when I set new font -


i'm working on simple church app. , i've started slide-out menu , can't seem change color of font of navigationbar when set new font. colors change when don't have line of code written font change. but, add line of code font change, color goes default. i've provided code below, , pictures go along them. i've tried putting function in appdelegate (i saw multiple forums saying trick), nothing seems working.

when this, color changed.

    func customizenavbar() {      navigationcontroller?.navigationbar.tintcolor = uicolor(colorliteralred: 255/255, green: 255/255, blue: 255/255, alpha: 1)     navigationcontroller?.navigationbar.bartintcolor = uicolor(colorliteralred: 0/255, green: 0/255, blue: 0/255, alpha: 1)       navigationcontroller?.navigationbar.titletextattributes = [nsforegroundcolorattributename: uicolor.white]  } 

enter image description here

when add nsfontattributename line of code, font type changes, color goes black.

    func customizenavbar() {      navigationcontroller?.navigationbar.tintcolor = uicolor(colorliteralred: 255/255, green: 255/255, blue: 255/255, alpha: 1)     navigationcontroller?.navigationbar.bartintcolor = uicolor(colorliteralred: 0/255, green: 0/255, blue: 0/255, alpha: 1)       navigationcontroller?.navigationbar.titletextattributes = [nsforegroundcolorattributename: uicolor.white]     navigationcontroller?.navigationbar.titletextattributes = [nsfontattributename: uifont(name: "avenirnext-regular", size: 21)!]  } 

enter image description here

you've replaced foreground color second attribute. need combine them

try this

navigationcontroller?.navigationbar.titletextattributes = [nsforegroundcolorattributename: uicolor.white, nsfontattributename: uifont(name: "avenirnext-regular", size: 21)!] 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -