ios - Small gap between UINavigationBar and UISearchBar -
i added uisearch programmatically app , uinavigation bar added in interface builder. when added search bar left tiny gap between search bar , nav bar. there way merge them together? thanks.
self.searchbar = [[uisearchbar alloc] initwithframe:cgrectmake(0.0, 0.0, self.view.bounds.size.width, 44.0)]; self.searchbar.delegate = self; self.searchbar.autoresizingmask = uiviewautoresizingflexiblewidth; self.searchbar.showscancelbutton = no; [self.view addsubview:self.searchbar];
if making sure searchbar right under navigation bar, use autolayout so:
self.searchbar = [[uisearchbar alloc] init]; self.searchbar.translatesautoresizingmaskintoconstraints = no; self.searchbar.delegate = self; self.searchbar.showscancelbutton = no; [self.view addsubview:self.searchbar]; id toplayoutguide = self.toplayoutguide; uisearchbar *searchbar = self.searchbar; //updated [self.view addconstraints:[nslayoutconstraint constraintswithvisualformat:@"h:|[searchbar]|" options:0 metrics:0 views:nsdictionaryofvariablebindings(searchbar)]]; [self.view addconstraints:[nslayoutconstraint constraintswithvisualformat:@"v:[toplayoutguide][searchbar]" options:0 metrics:0 views:nsdictionaryofvariablebindings(searchbar, toplayoutguide)]];
edit:
i did searching , found not gap. image apple uses divide things place. there many options can approach
1.) search , destroy - find uiimageview, , remove bar.
remove uitoolbar hairline in ios 7
2.) set custom background bar
[self.navigationcontroller.navigationbar setbackgroundimage:[uiimage new] forbarmetrics:uibarmetricsdefault]; self.navigationcontroller.navigationbar.shadowimage = [uiimage new];
Comments
Post a Comment