天天看點

如何給每一個navigationcontroller設定傳回按鈕

//導航控制器的子控制器個數

      int   count =   self . navigationController . viewControllers . count ;

      if   (count > 1) {

          ThemeButton   *button = [[ ThemeButton   alloc ]   initWithFrame : CGRectMake (0, 0, 60, 44)];

        button. imgName   =   @"titlebar_button_back_9.png" ;

        button. titleLabel . font   = [ UIFont   systemFontOfSize :14];

        [button   setTitle : @"傳回"   forState : UIControlStateNormal ];

        [button   addTarget : self   action : @selector (backAction)   forControlEvents : UIControlEventTouchUpInside ];

          UIBarButtonItem   *backItem = [[ UIBarButtonItem   alloc ]   initWithCustomView :button];

          self . navigationItem . leftBarButtonItem   = backItem;

    }