Ipad导航栏横向问题
有没有办法在ipad横向/纵向模式下使用不同的图像?我的导航栏中有一个标志,虽然它在iPhone上使用不同的图像效果很好,但是我不能为iPad使用不同的图像,所以当你打开设备时,徽标不居中。 或者,我可以使用一个普通的背景图像,或者用一个图像替换导航栏标题,或者用一个按钮居中,但我也无法做到这一点。(我没有UINavigationController子类) 以下是我在应用程序委托中实现此技巧的代码:Ipad导航栏横向问题,ipad,uinavigationcontroller,landscape,Ipad,Uinavigationcontroller,Landscape,有没有办法在ipad横向/纵向模式下使用不同的图像?我的导航栏中有一个标志,虽然它在iPhone上使用不同的图像效果很好,但是我不能为iPad使用不同的图像,所以当你打开设备时,徽标不居中。 或者,我可以使用一个普通的背景图像,或者用一个图像替换导航栏标题,或者用一个按钮居中,但我也无法做到这一点。(我没有UINavigationController子类) 以下是我在应用程序委托中实现此技巧的代码: if ([UINavigationBar respondsToSelector:@selecto
if ([UINavigationBar respondsToSelector:@selector(appearance)]) {
// Create resizable images for iphone
UIImage *navbarImage44 = [[UIImage imageNamed:@"nav_bar"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
UIImage *navbarImage32 = [[UIImage imageNamed:@"nav_bar_landscape"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
// Overide for iPad
// In theory navbar_bg_landscape~iPad should work
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
//use iPad specific image extending last pixel for landscape mode
[[UINavigationBar appearance] setBackgroundImage:[[UIImage imageNamed:@"nav_bar_ipad" ]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]
forBarMetrics:UIBarMetricsDefault];
}else {
// Set the background image for *all* UINavigationBars
[[UINavigationBar appearance] setBackgroundImage:navbarImage44
forBarMetrics:UIBarMetricsDefault];
// Never called on iPad, used for landscape on iPhone
[[UINavigationBar appearance] setBackgroundImage:navbarImage32
forBarMetrics:UIBarMetricsLandscapePhone];
}
}
我没有得到任何回应,所以我找到了一个解决办法,就是调整风景图片的大小。我现在还可以。我正在调整我的肖像背景图片的大小——这是我的iPad代码
我没有得到任何回应,所以我找到了一个解决办法,就是调整风景图片的大小。我现在还可以。我正在调整我的肖像背景图片的大小——这是我的iPad代码
// Create resizable images
UIImage *ipadTabBarBG = [[UIImage imageNamed:@"nav_bar_ipad.png"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, -260, 0, 0)];
// Set the background image for *all* UINavigationBars
[[UINavigationBar appearance] setBackgroundImage:ipadTabBarBG
forBarMetrics:UIBarMetricsDefault];