navigationBar添加背景圖片

http://blog.csdn.net/iorchid/article/details/


  1. @interface UINavigationBar (MyCustomNavBar)   
  2. @end   
  3.   
  4. @implementation UINavigationBar (MyCustomNavBar)  
  5. - (void) drawRect:(CGRect)rect   
  6. {  
  7.     UIImage *barImage = [UIImage imageNamed:@"title.png"];  
  8.     [barImage drawInRect:rect];  
  9. }  
  10. @end  


方法二:

  1. - (void)viewWillAppear:(BOOL)animated  
  2. {  
  3.   
  4.     UIImageView *imageView = [[UIImageView alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 44.0f)];  
  5.     imageView.image = [UIImage imageNamed: @"title.png"];  
  6.     [self.navigationController.navigationBar addSubview: imageView];  
  7. }  

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章