How to move from custom to transluscent NavigationBar and back? Display problems!

会有一股神秘感。 提交于 2019-12-24 11:28:23

问题


So, i got this Navigation-based App (with a custom NavigationBar - Category) and I have 2 problems here...

@implementation UINavigationBar (Custom)

- (void)drawRect:(CGRect)rect {
    UIImage *image = [UIImage imageNamed: @"bg_toolbar.png"];
    [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}

@end

Because of the Navigation-based App, most of the views have a height of 436px (= ScreenSize - NavigationBar height, as you probably know ;).

I got one view similar to the photo app overview showing all the thumbnails, from there I push a viewcontroller containing the scroll view (like in photos app) on the stack, like so

- (void)buttonPressed:(id)sender 
{
    UIButton *btn = (UIButton *)sender;
    PhotoSetScrollViewController *psc = [[PhotoSetScrollViewController alloc] initWithPhotoArray:photos andID:btn.tag];
    [self.navigationController pushViewController:psc animated:YES]; 
}

Problem 1: The view holding the fullscreen scrollview has a height of 480px which seems to be a problem because when poping the viewcontroller by hitting the back button, the view containing the thumbnails (height 436px) moves upward below the navigation bar. And also the Toolbar keeps showing. What could be the problem?

EDIT: The fullscreen scrollview is also moving when the navigation and toolbar are shown (hidden initially). And even without the custom navigationbar i get the views floating around. That is weird.

Problem 2: How could I switch between my custom navigation bar and the standard black translucent style?


回答1:


jd,

Problem 1: Please clarify your question.... Are you trying to make it the same as the Photos app, where you click on a single photo and then you can hide the nav bar and the toolbar? Unless you explicitly hide the toolbar, it will continue to show when you pop your view by hitting the back button. You can delay the pop view and hide it or hide it within the viewDidAppear method of the prior view controller.

If your view is moving around, you may want to check your frame settings in IB (2nd to the last tab in the inspector window after you click on the view in question). Also, make sure you put the faked in nav bar in your XIB files so you can lay everything out correctly.

Problem 2:

First, check this post: using image or tint color on uinavigationbar in iphone?

Then use this as well:

self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;


来源:https://stackoverflow.com/questions/2867827/how-to-move-from-custom-to-transluscent-navigationbar-and-back-display-problems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!