/添加一个view 用来存放btn UIView *iconBgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 25, 25)]; leftButton = [[CDLeftBtn alloc]init]; leftButton.layer.masksToBounds = YES; leftButton.frame = CGRectMake(0, 0, 25, 25); leftButton.layer.cornerRadius = 12.5; [CDUtils displayLeftBtnImageWithUrlUnderMyIcon:icon.length>0?icon:[CDUser currentUser].avatarUrl button:leftButton]; [iconBgView addSubview:leftButton]; [leftButton addTarget:self action:@selector(leftBtnCilck) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:iconBgView]; self.navigationItem.leftBarButtonItem = leftItem;
///就是加一层,
UIView *iconBgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 25, 25)];
UIButton * backbtn =[UIButton addBtnImage:@"backimg" AndFrame:CGRectMake(0, 0, 25, 25) WithTarget:self action:@selector(leftBtnClick)];
backbtn.layer.masksToBounds = YES;
backbtn.layer.cornerRadius = 12.5;
[iconBgView addSubview:backbtn];
self.navigationItem.leftBarButtonItem =[[UIBarButtonItem alloc]initWithCustomView:iconBgView];