问题
I'm trying to add a UIButton in a cell which already has a UIImageView in the background.
I put this code in configureCell
UIButton *mail = [[UIButton alloc] initWithFrame:CGRectMake(10, 270, 40, 40)];
[mail setImage:[UIImage imageNamed:@"mail.png"] forState:UIControlStateNormal];
mail.backgroundColor = [UIColor whiteColor];
[mail addTarget:self action:@selector(sendMail) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:mail];
It works but the image in the UIButton is seems darker

I tried these but it didn't changed anything
mail.alpha = 1;
[cell.contentView bringSubviewToFront:mail];
Does anyone have an explanation for this, and a solution as well.
回答1:
I had the same problem once and I solved it by setting the button's image for the UIControlStateHighlighted
[mail setImage:[UIImage imageNamed:@"mail.png"] forState:UIControlStateHighlighted];
Hope it works for you
回答2:
Try this
UIButton *mail=[UIButton buttonWithType:UIButtonTypeCustom];
mail.frame= CGRectMake(10, 270, 40, 40);
[mail setImage:[UIImage imageNamed:@"mail.png"] forState:UIControlStateNormal];
mail.backgroundColor = [UIColor clearColor];
[mail addTarget:self action:@selector(sendMail) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:mail];
来源:https://stackoverflow.com/questions/10474536/image-in-uibutton-is-darker-tharn-original