UIButton转UIBarButtonItem

UIButton转UIBarButtonItem_第1张图片

Swift

        let leftButton = UIButton(type: .Custom);

        let leftItem = UIBarButtonItem(customView: leftButton)

        navigationItem.leftBarButtonItem = leftItem;

OC

      UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
    
      UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:leftButton];
    
      self.navigationItem.leftBarButtonItem = leftItem;



你可能感兴趣的:(UIButton转UIBarButtonItem)