0

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

        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 覆盖在图像顶部。如何消除这种影响?

谢谢

4

1 回答 1

1

而不是 setImage:forState 使用setBackgroundImage:forState

[self.learnMoreButton setBackgroundImage:[UIImage imageNamed:@"btn_learn_pad"] forState:UIControlStateNormal];
[self.learnMoreButton setBackgroundImage:[UIImage imageNamed:@"btn_learn_focus_pad"] forState:UIControlStateHighlighted];
于 2012-06-08T15:41:01.390 回答