导航栏常用代码

来源:互联网 发布:linux top 参数 编辑:程序博客网 时间:2024/04/27 22:57

//iOS7 修改导航条背景色

    [[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0x067AB5)];

    

    //iOS7 修改导航条上面返回按钮标题颜色,如果不修改返回的indicator <也是这样颜色

    [[UINavigationBar appearance] setTintColor:[UIColor redColor]];


    //自定义导航条背景图片

    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"nav_bg_ios7.png"] forBarMetrics:UIBarMetricsDefault];

    

    //iOS7 自定义返回文字左边的indicator图标 即<

    [[UINavigationBar appearance] setBackIndicatorImage:[UIImage imageNamed:@"back_btn.png"]];

    [[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:[UIImage imageNamed:@"back_btn.png"]];

    

    

    //自定义导航条的标题样式

    NSShadow *shadow = [[NSShadow alloc] init];

    shadow.shadowColor = [UIColor colorWithRed:0.0 green:1.0 blue:0.0 alpha:0.8];

    shadow.shadowOffset = CGSizeMake(1, 1);//x:左右偏移量,左﹣右+;y:上下偏移量,上-下+

    shadow.shadowBlurRadius = 200;

    [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:

                                                           [UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName,

                                                           shadow, NSShadowAttributeName,

                                                           [UIFont fontWithName:@"HelveticaNeue-CondensedBlack" size:21.0], NSFontAttributeName, nil]];


//设置导航上面的提示信息:

self.navigationItem.prompt =@"This is a prompt";

导航栏常用代码 - 〇①世界 - 云端的小牛牛
0 0
原创粉丝点击