我尝试使用UIColor clearColor而不是UIColor redColor,但图像只是消失了。
如何“按原样”显示图像,而根本没有颜色叠加?
非常感谢你的帮助!
UIButton *temp = [UIButton buttonWithType:UIButtonTypeCustom];
temp.tag = 0;
[self collectionClose:temp];
CGFloat width, height;
CGFloat centerX = _canvas.frame .size.height/2.0, centerY = _canvas.frame.size.width/2.0;
UIImage *image = [self imageNamed:[NSString stringWithFormat:@"Pack%ld%@_%zd.png", (long)packID, currentCollection, indexPath.row+1]
withColor:[UIColor redColor]];
答案 0 :(得分:0)
我看到了你的代码,你已经清楚地写出了按钮颜色为红色。你写的方法是错误的。 [UIButton setImage:[UIImage imageNamed:@“image.png”]]。
这将在按钮中显示图像。
答案 1 :(得分:0)
UIButton *temp = [UIButton buttonWithType:UIButtonTypeCustom];
temp.tag = 0;
[self collectionClose:temp];
CGFloat width, height;
CGFloat centerX = _canvas.frame .size.height/2.0, centerY = _canvas.frame.size.width/2.0;
NSString *imageName = [NSString stringWithFormat:@"Pack%ld%@_%zd.png", (long)packID, currentCollection, indexPath.row+1];
[temp setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];