我有一个应用程序,当它开始时,它加载一个viewController,它加载Default.png启动图像并在那里保持1.5秒,然后该图像淡出,然后淡入另一个图像,这将是背景图像我的整个申请。从这里开始加载第一个viewController,然后按钮和导航栏淡入。
所以它出现了SplashScreeVC - Default.png Default.png淡出 新图像淡入(这是应用程序整体背景图像) 加载MainVC,按钮和导航栏alpha设置为0.1。 调用淡入导航栏的方法和mainVC中的按钮
所以在我的app appate中我有这个
- (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,然后加载splashVC,其中Default.png作为其背景图像,显示1.5秒。然后我有一些方法淡出这个图像,然后淡入将用作整个应用程序的背景图像的图像。然后它调用appDelegates MainNav方法,该方法加载Navigation控制器。 app 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中的图像相同,但图像突然猛然抬起。
有谁知道为什么会这样?我猜这与影响图像大小的导航控制器有关,但不知道该怎么做才能修复它?我是否需要为具有不同尺寸的导航栏背景创建新图像?或者还有其他方法可以解决这个问题吗?
非常感谢任何建议。谢谢!
编辑:修正图像向右抖动,图像宽度错误,但图像仍然跳起一定量
答案 0 :(得分:0)
管理解决问题。似乎必须复制图像并将其高度增加20像素并将其设置为导航栏背景图像。这会抵消导航栏问题。
答案 1 :(得分:0)
您可以设置背景图片代码,如
yourView.setBacroundColur=[UIColour colourWithImagePttern:[UIImage ImageNamed:@""]];