ios - Set background in UIViewController inside navigation controller -
i want set background color fullscreen (includes navigation bar , status bar also) gradient color. right now, made creating gradient
func setdefaultcolorbackground() { let colortop = uicolor(hexstring: "804b8a").cgcolor let colorbottom = uicolor(hexstring: "42074b").cgcolor let gradientlayer = cagradientlayer() gradientlayer.colors = [ colortop, colorbottom] gradientlayer.locations = [ 0.0, 1.0] gradientlayer.frame = self.view.bounds self.view.layer.insertsublayer(gradientlayer, at: 0) }
so added layer in view
in viewcontroller
. works does't covered status bar , navigation bar. see image:
i think background fill view under navigation bar. anyway, using .xib
, load manually in view controller class.
is there ideas how it? thank much!
i guess change color of navigation bar have write code :
uinavigationbar.appearance().bartintcolor = uicolor.redcolor()
or whatever color want provide :
uinavigationbar.appearance().bartintcolor = uicolor(red: 0, green: 0/255, blue: 205/255, alpha: 1) uinavigationbar.appearance().tintcolor = uicolor.whitecolor() uinavigationbar.appearance().titletextattributes = [nsforegroundcolorattributename:uicolor.whitecolor()]
i hope helpful you. happy coding :)
Comments
Post a Comment