ios - drawRect on a UINavigationBar subclass makes the status bar go black -
i have same issue thread here. can manage make status bar visible making text white isn't goal. mean color on top of bar, navigation bars do. i've been able achieve adding shapes want views, under layoutsubviews, way can't interact or see uinavigationitem. code:
- (void)drawrect:(cgrect)rect { [super drawrect:rect]; cgcontextref context = uigraphicsgetcurrentcontext(); [[uicolor yellowcolor] setfill]; uirectfill(rect);
this result:
this bast can achieved drawrect:
and happens if under layoutsubviews:
as can see, text, arrow, lost. i'm looking way make drawrect work! in advance help!
first, set navbar invisible with:
navcontroller.navigationbar.translucent = true navcontroller.navigationbar.setbackgroundimage(uiimage(), forbarmetrics: .default) navcontroller.navigationbar.shadowimage = uiimage() navcontroller.navigationbar.backgroundcolor = uicolor.clearcolor()
create view in storyboard or xib , make property in vc, add with:
navcontroller.view.insertsubview(navbarview, belowsubview: (navigationcontroller?.navigationbar)!)
after subview should appear behind bar buttons , can work custom navbarview
, remember remove navbarview
, return navbar default when view disappear:
navcontroller.navigationbar.translucent = false navcontroller.navigationbar.shadowimage = nil navcontroller.navigationbar.setbackgroundimage(nil, forbarmetrics: .default) navcontroller.navigationbar.backgroundcolor = uicolor.whitecolor()
Comments
Post a Comment