본문 바로가기

iOS Programming

UINavigationBar에 이미지를 배경으로 지정하기

#import <Foundation/Foundation.h>


@interface LWNavigationBar : UINavigationBar {
UIImage *background;
}

@end



@implementation LWNavigationBar


- (void)drawRect:(CGRect)rect
{
if(background == nil)
background = [UIImage imageNamed:@"cs1_header.png"];
[background drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}

- (void)dealloc {
[background release];

    [super dealloc];
}

@end


Interface Builder 에서  Navigation Controller 안의 Navigation Bar의 클래스를 위에 것으로 변경하고
소스애서 background property에 이미지 지정.