具有标题的UIButtonTypeCustom的UIButton未显示为已单击

tom*_*tom 1 iphone uibutton

我正在设置以下UIButton(在tableview单元格中),以使其看起来像一个可点击的URL链接

UIButton *buttonUserName = [UIButton buttonWithType:UIButtonTypeCustom];
buttonUserName.frame = CGRectMake(10, 10, 280, 20);
[buttonUserName setTitle:@"test" forState:UIControlStateNormal];
[buttonUserName setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[buttonUserName setEnabled:YES];
buttonUserName.userInteractionEnabled = YES;
[buttonUserName addTarget:self action:@selector(user:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:buttonUserName];
Run Code Online (Sandbox Code Playgroud)

按钮和标题确实显示,但点击它时没有点击效果(视觉上).我错过了什么吗?

Wub*_* Li 7

将所需的视觉反馈设置为按钮状态 UIControlStateHighlighted

例如:标题颜色

[buttonUserName setTitleColor:[UIColor redColor] forState: UIControlStateHighlighted];
Run Code Online (Sandbox Code Playgroud)

和其他一些标题,背景图像,图像等.