【发布时间】:2011-11-29 08:32:04
【问题描述】:
这是一个非常基本的问题 - 但我无法在任何地方找到答案。 我想要一个后退按钮,就像在导航栏中显示的默认按钮一样,但在背景中有图像。 即使进行了自定义,如何根据标题计算按钮的大小/长度? 非常感谢您的帮助,提前!
更新:
谢谢各位!但我最终实现的答案是:
@implementation UINavigationBar (UINavigationBarCategory)
-(void)drawRect:(CGRect)rect
{
UIColor *color = [UIColor colorWithRed:(13.0/255.0) green:(183.0/255.0) blue:(255.0/255.0) alpha:1.0];
// 使用我使用导航栏图像上的数字色度计获得的后退按钮使用自定义颜色:P
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColor(context, CGColorGetComponents( [color CGColor]));
CGContextFillRect(context, rect);
self.tintColor = color;
// use a custom background image for my navigation bar
UIImage *img = [UIImage imageNamed: Navigation_img];
[img drawInRect:CGRectMake(0,0,img.size.width,img.size.height)];
}//对我来说很满意
@结束
【问题讨论】:
-
上面的答案只是在导航项的默认后退按钮中加入了颜色以及导航栏的背景图像。
标签: iphone ios xcode uinavigationcontroller