NavigationItem的点击范围很大,有时候会影响到附近区域点击事件,所以需要缩小点击范围,可采用如下方式定义点击范围
UIButton*button = [UIButtonbuttonWithType:UIButtonTypeCustom]; [buttonsetTitleEdgeInsets:insets]; [buttonsetFrame:CGRectMake(0,0,44,30)]; [buttonaddTarget:selfaction:actionforControlEvents:UIControlEventTouchUpInside]; [buttonsetTitle:textforState:UIControlStateNormal]; button.titleLabel.font= [UIFontsystemFontOfSize:14.0f]; [buttonsetTitleColor:[UIColorgrayColor]forState:UIControlStateNormal]; [buttonsetTitleColor:[UIColorhexStringToColor:@"808080"]forState:UIControlStateHighlighted]; [buttonsizeToFit]; [buttonsetFrame:CGRectMake(0,0, button.width+5,24)]; UIView*backBtnView = [[UIViewalloc]initWithFrame:button.bounds]; backBtnView.bounds=CGRectOffset(backBtnView.bounds,0,0); [backBtnViewaddSubview:button];