SHARE
TWEET

navigationItem.rightBarButtonItems

a guest May 8th, 2013 43 Never
  1. UIBarButtonItem* gamecenterButtonItem, *gamecenterButtonItem2 ;
  2.     {
  3.         UIImage* image1 = [UIImage imageNamed:TEX_GAMECENTER_BTN_1];
  4.         UIImage* image2 = [UIImage imageNamed:TEX_GAMECENTER_BTN_2];
  5.  
  6.         CGRect frame = CGRectMake(0, 0, image1.size.width, image1.size.height);
  7.  
  8.         UIButton *gcButton = [[UIButton alloc] initWithFrame:frame];
  9.         [gcButton setBackgroundImage:image1 forState:UIControlStateNormal];
  10.         [gcButton setBackgroundImage:image2 forState:UIControlStateHighlighted];
  11.    
  12.         gamecenterButtonItem = [[UIBarButtonItem alloc] initWithCustomView:gcButton];
  13.     }
  14.    
  15.     {
  16.         UIImage* image1 = [UIImage imageNamed:TEX_GAMECENTER_BTN_1];
  17.         UIImage* image2 = [UIImage imageNamed:TEX_GAMECENTER_BTN_2];
  18.  
  19.         CGRect frame = CGRectMake(30, 0, image1.size.width, image1.size.height);
  20.  
  21.         UIButton *gcButton = [[UIButton alloc] initWithFrame:frame];
  22.         [gcButton setBackgroundImage:image1 forState:UIControlStateNormal];
  23.         [gcButton setBackgroundImage:image2 forState:UIControlStateHighlighted];
  24.        
  25.         gamecenterButtonItem2 = [[UIBarButtonItem alloc] initWithCustomView:gcButton];
  26.     }
  27.  
  28.     self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:gamecenterButtonItem, gamecenterButtonItem2, nil];
RAW Paste Data
Top