【问题标题】:Navigation controller affecting app overall background image影响应用整体背景图像的导航控制器
【发布时间】:2012-08-08 09:22:57
【问题描述】:

我有一个应用程序,当它开始时,它会加载一个 viewController,它会加载 Default.png 启动图像并将其保持 1.5 秒,然后该图像淡出,然后淡入另一个图像,该图像将作为背景图像我的整个申请。它从这里加载第一个 viewController,然后按钮和导航栏淡入。

所以它去了 SplashScreeVC - Default.png 呈现 Default.png 淡出 新图像淡入(这是应用程序的整体背景图像) 加载 MainVC,按钮和导航栏 alpha 设置为 0.1。 调用方法淡入导航栏和 mainVC 中的按钮

所以在我的应用 Delegate 中有这个

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.

    SplashVC *splash = [[SplashVC alloc] initWithNibName:@"SplashView" bundle:nil];
    self.window.rootViewController = splash;

    [self.window makeKeyAndVisible];
    return YES;
}

所以应用程序加载 Default.png,然后加载具有 Default.png 作为其背景图像的 splashVC,这将显示 1.5 秒。然后我有一些方法可以淡出这个图像,然后淡入将用作整个应用程序的背景图像的图像。然后它调用加载导航控制器的 appDelegates MainNav 方法。应用 Delegates MainNav 方法如下

-(void) MainNav
{
    UIViewController *main = [[MainVC alloc] initWithNibName:@"MainView" bundle:nil];

    self.navController = [[UINavigationController alloc] initWithRootViewController:main];

    UIImage *navImage = [UIImage imageNamed:@"NavBarGrey.png"];
    //Add the custom image


    [[self.navController navigationBar] setBackgroundImage:navImage forBarMetrics:UIBarMetricsDefault];

    //[[UINavigationBar appearance] setTintColor:UIColorFromRGB(0xee2e24)];


    [[UINavigationBar appearance] setTintColor:UIColorFromRGB(0xe7e7e7)];

    self.navController.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"backgroundImage.png"]];

    self.window.rootViewController = self.navController;

}

问题是,当它从 SplashScreen VC 移动到 MainVC 时,图像会突然跳动,尽管事实上它与在 SplashVC 中淡入的图像相同。

有人知道这是为什么吗?我猜它与影响图像大小的导航控制器有关,但不确定如何修复它?我是否需要为不同尺寸的导航栏背景创建新图像?还是有其他方法可以解决这个问题?

任何建议将不胜感激。谢谢!!

编辑:修正图像向右抖动,图像宽度在错误高度,但图像仍在跳跃设定的量

【问题讨论】:

    标签: objective-c ios uinavigationcontroller


    【解决方案1】:

    设法弄明白了。似乎必须复制图像并将其高度增加 20 像素并将其设置为导航栏背景图像。这抵消了导航栏的问题。

    【讨论】:

      【解决方案2】:

      您可以设置背景图像代码,如

      yourView.setBacroundColur=[UIColour colourWithImagePttern:[UIImage ImageNamed:@""]];
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-07-05
        • 2015-09-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多