ios 设置button 的高亮状态

来源:互联网 发布:中国金融战略2020知乎 编辑:程序博客网 时间:2024/04/29 08:53
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];[button setFrame:CGRectMake(0, 0, 200, 80)];[button setTitle:@"button" forState:UIControlStateNormal];[button addTarget:self action:@selector(buttonAction:forEvent:) forControlEvents:UIControlEventAllTouchEvents];[self.view addSubview:button];    - (void)buttonAction:(id)sender forEvent:(UIEvent *)event{    UITouchPhase phase = event.allTouches.anyObject.phase;    if (phase == UITouchPhaseBegan) {        NSLog(@"press");    }    else if(phase == UITouchPhaseEnded){        NSLog(@"release");    }}
2.可以重新写系统的setHigh方法