我正在尝试在后台已有 UIImageView 的单元格中添加一个 UIButton。
我将此代码放入 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];
它可以工作,但是 UIButton 中的图像似乎更暗
我尝试了这些,但没有改变任何东西
mail.alpha = 1;
[cell.contentView bringSubviewToFront:mail];
有没有人对此有解释,以及解决方案。
最佳答案
我曾经遇到过同样的问题,我通过为 UIControlStateHighlighted 设置按钮的图像解决了它
[mail setImage:[UIImage imageNamed:@"mail.png"] forState:UIControlStateHighlighted];
希望它对你有用
关于objective-c - UIButton 中的图像比原始图像更暗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10474536/