对于UIButton在视图之一,我创建了一个图像用于正常状态,但我想继续使用默认的蓝色/图像的突出显示/选择状态, 有没有办法做到这一点?或者我是否真的必须为突出显示/选择准备定制图像?UIButton定制使用标准的图像/颜色为突出显示的状态
下面是我每@mashios要求和意见有如下的代码 -
UIButton *shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
[shareButton setFrame:CGRectMake(1.0, 0.0, 99.0, 43.0)];
[shareButton setBackgroundImage:[[UIImage imageNamed:@"share_normal"]
stretchableImageWithLeftCapWidth:0.0
topCapHeight:0.0] forState:UIControlStateNormal];
[shareButton setBackgroundImage:[[UIImage imageNamed:@"share_normal"] // bottom_up_left_3_selected
stretchableImageWithLeftCapWidth:0.0
topCapHeight:0.0] forState:UIControlStateHighlighted];
[shareButton addTarget:self action:@selector(share:) forControlEvents:UIControlEventTouchUpInside];
我刚刚试验过,通过将相同的图像(用于正常状态)设置为突出显示的状态。结果不是我想要的,而是点击按钮时根本没有颜色变化。 – tom 2012-01-09 18:24:49
你可以只提供一些代码。 – mashios 2012-01-10 04:48:16
请查看我的帖子,上面有我使用的代码 – tom 2012-01-10 09:29:06