UIButton如果包含圖片,會(huì)有默認(rèn)點(diǎn)擊效果他爸。
但是如果只設(shè)置title缩功,那么點(diǎn)擊是沒有任何效果的。
UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(20, 50, 100, 44)];
[self.view addSubview:btn];
[btn setTitle:@"哈哈" forState:UIControlStateNormal];
[btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
這時(shí)可以如下設(shè)置:
[btn setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
如果設(shè)置btn.showsTouchWhenHighlighted = YES;
則點(diǎn)擊時(shí)button中心會(huì)有白色光圈箫章。