您可以定义按钮和setImage
正常和选定状态。像这样。
buttonJobs = [UIButton buttonWithType:UIButtonTypeCustom ];
buttonJobs.tag = 1;
[buttonJobs setTitle:@"Jobs" forState:UIControlStateNormal];
buttonJobs.frame = CGRectMake(2, 56, 109, 33);
[buttonJobs setImage:[UIImage imageNamed:@"tabButtonImage_Off.png"] forState:UIControlStateNormal];//buttonJobs.png
[buttonJobs setImage:[UIImage imageNamed:@"tabButtonImage_On.png"] forState:UIControlStateDisabled];
[buttonJobs addTarget:self action:@selector(btnNextTab:) forControlEvents:UIControlEventTouchUpInside];
在按钮选择器方法中,您可以设置您选择的按钮sender's tag
。
-(void)btnNextTab:(UIButton*)sender
{
if(sender.tag == 1)
{
sender.selected = YES;
}
}
对于标题,您可以更改文本的颜色。
希望这会帮助你。