ios - UINavigationBar.appearance().translucent is creating a big white space -
update 2: i'm still hoping problem i'm going refine question little i've narrowed down better.
my uiviewcontroller hierarchy looks this:
the filter view appears if user touches filter icon , selects lift type. image on left looks without filter selected , right image looks filter selected. navigation area (outlined in green) i'm trying style.
here's thing can't figure out. if add these 2 things:
uinavigationbar.appearance().translucent = false uinavigationbar.appearance().bartintcolor = uicolor(hexstring: "232b35") then white space appears between navigation area , filter view:
if set translucent property true, white space doesn't appear, bartintcolor has no effect.
note didn't put uinavigationbar in uiviewcontroller. have uinavigationitem i'm adding code.
at point, question - why big white space appearing out of when have uinavigationbar.appearance().translucent = false in code (and can rid of it, still change color of navigation area)?
i'm stuck , appreciate help. thanks!
the following original question information may or may not helpful: i'm trying style app , having difficult time so. on 1 uiviewcontroller i've got thememanager struct function applies theme app , in method code makes navigation bar blend in background color of app:
static func applytheme(theme: theme) { // set background color sharedapplication.delegate?.window??.backgroundcolor = uicolor(hexstring: "232b35") uinavigationbar.appearance().translucent = false // these offenders uinavigationbar.appearance().bartintcolor = uicolor(hexstring: "232b35") // first, set backgroundimage nothing uinavigationbar.appearance().setbackgroundimage( uiimage(), forbarposition: .any, barmetrics: .default) // , set shadowimage nothing uinavigationbar.appearance().shadowimage = uiimage() uistatusbarstyle.lightcontent uilabel.appearance().textcolor = uicolor(hexstring: "768daa") } } my initial viewcontroller looks want - background , navigation components same color:
but on different view controller, it's got big space don't want:
and i've figured out it's uinavigationbar.appearance().translucent , uinavigationbar.appearance().bartintcolor properties causing happen. it's if it's adding uinavigationbar underneath actual navigation area. if comment code out, doesn't have color of course, big space don't want goes away too:
the big difference between 2 vcs this: in first vc looks want, intentionally placed uinavigationbar via storyboard in second vc have not. placed uinavigationitem in one. note, second vc contains uitableview isn't uitableviewcontroller.
how can solid color want in navigation area without adding unwanted space underneath it?
edit #1 here's @ uiviewcontroller problem:
notice hierarchy uiview @iboutlet connection, below uistackview contains filter view (a uiview) expands , collapses height layout constraint, , uitableview. big white space appears isn't in hierarchy.
in case helps, here's viewdidload method in lift log's uiviewcontroller:
class liftlogviewcontroller: uiviewcontroller, uitableviewdatasource, uitableviewdelegate, nsfetchedresultscontrollerdelegate {
//mark: ib outlets @iboutlet var tableview: uitableview! @iboutlet weak var navitem: uinavigationitem! @iboutlet weak var filterviewheightconstraint: nslayoutconstraint! @iboutlet weak var clearfilterbutton: uiimageview! @iboutlet weak var selectedfilter: uilabel! @iboutlet weak var clearbuttonheightconstraint: nslayoutconstraint! @iboutlet weak var clearbuttonview: uiimageview! let coredatastack = coredatastack() var liftevents = [liftevent]() var isfilterviewopen = false override func viewdidload() { let donebutton = uibarbuttonitem(title: "done", style: .plain, target: self, action: #selector(self.dismisslog(_:))) let filterimage = uiimage(named: "filter_icon") let filterbutton = uibarbuttonitem(image: filterimage, style: .plain, target: self, action: #selector(self.actionfilter)) self.navitem.rightbarbuttonitems = [donebutton, filterbutton] let buttontap = uitapgesturerecognizer(target: self, action: #selector(self.clearfilter)) clearfilterbutton.addgesturerecognizer(buttontap) filterviewheightconstraint.constant = 0.0 clearbuttonheightconstraint.constant = 0.0 super.viewdidload() }
did set uinavigationbar in first vc translucent properties false via storyboard keep consistent uinavigationbar.appearance()?
then second vc top bar should inferring first vc.









Comments
Post a Comment