文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>自定义UINavgationBar 方法二

自定义UINavgationBar 方法二

时间:2010-10-18  来源:苏瑞强

 

//  Created by suruiqiang on 8/3/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//
#pragma once
#import <UIKit/UIKit.h>
@interface UINavigationBar (UINavigationBarCategory) 
UIImageView *bg;
-(UINavigationBar*)setBackgroundImage:(UIImage*)image;
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;
@end


CustomNavController.m

 

 

 

#import "CustomerNavBarController.h"


@implementation UINavigationBar (UINavigationBarCategory)
-(UINavigationBar*)setBackgroundImage:(UIImage*)image
{
        UINavigationBar *NavBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
    if(image == nil) return NavBar;
    bg = [[UIImageView alloc]initWithImage:image];
    bg.frame = CGRectMake(0.f, 0.f, self.frame.size.width, self.frame.size.height);
    [NavBar addSubview:bg];
    [NavBar sendSubviewToBack:bg];
    [bg release];
        return NavBar;
}

- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index
{
    [super insertSubview:view atIndex:index];
    [self sendSubviewToBack:bg];
}
@end

 

 

 

 

 在需要调用的地方添加如下代码:

- (void)viewDidLoad {
    [super viewDidLoad];
   [[self.navigationController navigationBar] setBackgroundImage:[UIImage imageNamed:@"NavigationBarBackground.png"]];

//在下面添加你自己的功能代码
***********
}
相关阅读 更多 +
排行榜 更多 +
雷电觉醒安卓版

雷电觉醒安卓版

飞行射击 下载
3D幻影飞车最新版

3D幻影飞车最新版

飞行射击 下载
星河一号战队

星河一号战队

飞行射击 下载