有时候右上角的按钮会中后会变蓝 如图


这个时候的解决方法很简单,就是吧button的类型设置为custom。
代码如下:
//自定义一个导航条右上角的一个button
self.collectBut = [UIButton buttonWithType:UIButtonTypeCustom];
self.collectBut.frame = CGRectMake(0, 0, 15, 15);
[self.collectBut setImage:[[UIImage imageNamed:@"Thumb"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
[self.collectBut setImage:[[UIImage imageNamed:@"Thumb_selected"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ]forState:UIControlStateSelected];
self.collectBut.titleLabel.font = [UIFont systemFontOfSize:13];
[self.collectBut addTarget:self action:@selector(collectButclick:) forControlEvents:UIControlEventTouchUpInside];
//添加到导航条
UIBarButtonItem *rightBarButtomItem = [[UIBarButtonItem alloc]initWithCustomView:self.collectBut];
self.navigationItem.rightBarButtonItem = rightBarButtomItem;
有什么建议可以给我留言
网友评论