iOS7导航栏半透明=否 [英] iOS7 nav bar translucent = NO

查看:162
本文介绍了iOS7导航栏半透明=否的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个背景图像,在所有视图中都是相同的图像,但是导航栏透明度默认设置为YES,并且背景不是均匀的.我尝试了各种解决方案,但没有任何改变:(

I have a background image, the same image in all views, but the nav bar traslucent is set by default to YES and the background is not homogeneous. I tried various solutions but nothing change :(

我的AppDelegate.h

my AppDelegate.h

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end

我的AppDelegate.m

my AppDelegate.m

#import "AppDelegate.h"

#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >>16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.

[[UINavigationBar appearance] setBarTintColor: UIColorFromRGB(0x45312a)];
[[UINavigationBar appearance] setTintColor: [UIColor whiteColor]];

NSArray *ver = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
if ([[ver objectAtIndex:0] intValue] >= 7) {
    self.navigationController.navigationBar.translucent = NO;
}

return YES;
}

但在该行中:

self.navigationController.navigationBar.translucent = NO;

给我这些错误:在类型为'AppDelegate *'的对象上找不到属性'navigationController'

give me these error: Property 'navigationController' not found on object of type 'AppDelegate *'

有人可以帮助我吗?谢谢!

Anyone can help me? Thanks!

推荐答案

您可以在根视图控制器中做到这一点

You can do that in your root view controller

//inside the root view controller
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.navigationController.navigationBar setTranslucent:NO];
}

还可以在界面构建器中切换半透明.选择导航控制器,然后在文档大纲中选择导航栏,然后在 Attributes Inspector

Also you can toggle translucent in the interface builder. Select your Navigation Controller then in the Document Outline select the Navigation Bar and just change it in the Attributes Inspector

这篇关于iOS7导航栏半透明=否的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆