系统图标和图像的自定义导航栏按钮
问题描述:
我想弄清楚如何将自定义背景图像添加到使用系统图标或图像图标的NavigationBar按钮。系统图标和图像的自定义导航栏按钮
我已经想出了如何将背景图像添加到NavigationBar按钮与文本,但我很努力弄清楚如何使用图标按钮来完成此操作。
对于文本按钮,我跟着这个教程: http://idevrecipes.com/2010/12/13/wooduinavigation/
如何创建自定义按钮W /图标?
谢谢!
答
ü可能得到帮助,这
@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
我想我也不是很清楚瓦特/我的问题。我想弄清楚如何制作使用系统图标或图像图标的自定义导航栏按钮。 – kbecker 2011-02-20 20:48:17