覆盖Apple的UIButton亮点

时间:2012-06-08 15:29:33

标签: iphone objective-c xcode ipad uibutton

我有一个按钮,我在其中设置了图像和选中的图像。突出显示状态图像如下:

        UIImage *buttonImage = [UIImage imageNamed:@"btn_learn_pad"];
        self.learnMoreButton = [[UIButton alloc] initWithFrame:CGRectMake(50, 0, buttonImage.size.width, buttonImage.size.height)];
        [self.learnMoreButton setImage:buttonImage forState:UIControlStateNormal];
        [self.learnMoreButton setImage:[UIImage imageNamed:@"btn_learn_focus_pad"] forState:UIControlEventTouchUpInside | UIControlStateHighlighted | UIControlStateSelected];
        [self.learnMoreButton addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];

在选择时,这仍然会覆盖Apple图像上的深色alpha。如何删除此效果?

由于

1 个答案:

答案 0 :(得分:1)

而不是设置Image:for State use setBackgroundImage:forState

[self.learnMoreButton setBackgroundImage:[UIImage imageNamed:@"btn_learn_pad"] forState:UIControlStateNormal];
[self.learnMoreButton setBackgroundImage:[UIImage imageNamed:@"btn_learn_focus_pad"] forState:UIControlStateHighlighted];