Guest User

Untitled

a guest
Dec 11th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1.  
  2. ///========CUSTOM NAVIGATION BAR=============///
  3.  
  4. @implementation UINavigationBar (UINavigationBarCustomDraw)
  5.  
  6. - (void) drawRect:(CGRect)rect {
  7. [self setTintColor:[UIColor colorWithRed:0.5f
  8. green: 0.5f
  9. blue:0
  10. alpha:1]];
  11. if ([self.topItem.title length] > 0 && ![self.topItem.title isEqualToString:@"Back to ..."]) {
  12. [[UIImage imageNamed:@"CustomNavigationBar.png"] drawInRect:rect];
  13.  
  14. CGRect frame = CGRectMake(0, 0, 320, 44);
  15. UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease];
  16. [label setBackgroundColor:[UIColor clearColor]];
  17. label.font = [UIFont boldSystemFontOfSize: 20.0];
  18. label.shadowColor = [UIColor colorWithWhite:0.0 alpha:1];
  19. label.textAlignment = UITextAlignmentCenter;
  20. label.textColor = [UIColor whiteColor];
  21. label.text = self.topItem.title;
  22.  
  23.  
  24. } else {
  25.  
  26. [[UIImage imageNamed:@"CustomNavigationBar.png"] drawInRect:rect];
  27. self.topItem.titleView = [[[UIView alloc] init] autorelease];
  28.  
  29. }
  30.  
  31. }
  32.  
  33.  
  34. ///========CUSTOM SEARCH BAR=============///
  35.  
  36. @implementation UISearchBar (CustomBG)
  37.  
  38. - (void)drawRect:(CGRect)rect {
  39. UIImage *image = [UIImage imageNamed: @"CustomNavigationBar.png"];
  40. [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
  41. }
Add Comment
Please, Sign In to add comment