当我点击位于UIButton
顶部的UINavigationBar
时,我有这种光泽效果:
如何将此效果添加到位于UINavigatonBar
但不作为左或右按钮项目的另一个按钮?像这样:
UIButton * emptyButton = [UIButton buttonWithType:UIButtonTypeCustom];
[emptyButton setFrame:CGRectMake(119, 5, 82, 35)];
[emptyButton addTarget:self action:@selector(centerNavigationBarTitleClicked:) forControlEvents:UIControlEventTouchUpInside];
[emptyButton setBackgroundColor:[UIColor clearColor]];
[self.navigationController.navigationBar addSubview:emptyButton];
谢谢!
答案 0 :(得分:4)
您只需将showsTouchWhenHighlighted
属性设置为YES
即可获得发光效果,即
emptyButton.showsTouchWhenHighlighted = YES;