私はnav barコントローラを備えた単純なアプリケーションを持っています。drawRect関数をオーバーライドしながらナビゲーションバーを変更したいと思います。ここでは、appDelegateの上にコードを貼り付けるだけでよいことをここではたくさん読んでいます。悲しいことに、それは私のために何かをするように見えません。私はそれに画像を追加しようとする前に、ナビゲーションバーの色が変更されているだけのスタートとして試しましたが、何も起こりません。UINavigationBarをオーバーライドするdrawRect関数が動作しません
@implementation UINavigationBar (UINavigationBarCategory)
- (void)drawRect:(CGRect)rect {
UIColor *color = [UIColor redColor];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColor(context, CGColorGetComponents([color CGColor]));
CGContextFillRect(context, rect);
}
@end
と背景画像と::助けを
@implementation UINavigationBar (UINavigationBarCategory)
- (void)drawRect:(CGRect)rect {
// Drawing code
UIImage *img = [UIImage imageNamed: @"13.png"];
[img drawInRect:CGRectMake(0, 0, 320, self.frame.size.height)];
}
@end
おかげで私は何AppDelegate上記のコードを挿入して、私は疲れてここに
をしないのです!
この回答を見る:http://stackoverflow.com/questions/7657465/uinavigationbars-drawrect-is-not-called-in-ios-5-0 –