2011-02-19 132 views

回答

0

ü可能得到帮助,这

@implementation UINavigationBar (UINavigationBarCategory) 
    -(void)setBackgroundImage:(UIImage*)image{ 
if(!image) return; 
UIImageView *aTabBarBackground = [[UIImageView alloc]initWithImage:image]; 
// aTabBarBackground.frame = CGRectMake(0,0,self.frame.size.width,self.frame.size.height); 
aTabBarBackground.frame = CGRectMake(0,0,self.frame.size.width * .6,self.frame.size.height); 

// [self addSubview:aTabBarBackground]; 
// [self sendSubviewToBack:aTabBarBackground]; 
[self insertSubview: aTabBarBackground atIndex: 0]; 
[aTabBarBackground release]; 
    } 
    @end 

也是我们甲肝另一种思路,它工作正常。

@implementation UINavigationBar (UINavigationBarCategory) 

- (void)drawRect:(CGRect)rect { 
// Drawing code 
UIImage *img = [UIImage imageNamed: @"navbar_background.png"]; 
CGContextRef context = UIGraphicsGetCurrentContext(); 
CGContextDrawImage(context, CGRectMake(0, 0, 320, self.frame.size.height), img.CGImage); 

} @end

+0

我想我也不是很清楚瓦特/我的问题。我想弄清楚如何制作使用系统图标或图像图标的自定义导航栏按钮。 – kbecker 2011-02-20 20:48:17

相关问题