用于在 iOS 中创建可着色图标的 Gimp 设置
Gimp Settings to Create a Tintable Icon in iOS
我有一个 PNG 文件,它是一个箭头,我想在 iOS 应用程序中用作图标。我已将其他 PNG 文件放入 Xcode 中,它们作为可着色 UIButton
图像使用此行作为示例可以正常工作:
[self.backButton setTintColor:[UIColor redColor]];
对于我放入的 PNG 文件,我放入的文件是透明的,除了箭头是黑色的。上面的代码对我要着色的图像没有任何作用。
我找到了 other posts covering this topic,但与其为 UIButton
上的每个图标键入 10-20 行代码,我宁愿使用正确的设置来保存它在 Gimp 中并仅引用 Xcode.
中的文件
在Gimp中保存为PNG格式需要注意哪些设置?
更新
我最初认为添加色调会导致我的应用程序崩溃,但是缓存清理解决了该问题。无论如何,我的 UIButton
具有 PNG 背景不会改变色调。它始终是黑色的,但如果按钮被禁用它会变成木炭色(深灰色?)。
更新 2
我已经试过了,但没有成功:
self.backButton = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *backButtonImage = [[UIImage imageNamed:@"back"]imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.backButton setImage:backButtonImage forState:UIControlStateNormal];
self.backButton.tintColor = [UIColor myCustomColor];
我放弃了,选择了 UISwipeGestureRecognizer
--界面效果更好,所以没有妥协。显然,您可以为某些按钮着色,但不能为其他按钮着色。
我有一个 PNG 文件,它是一个箭头,我想在 iOS 应用程序中用作图标。我已将其他 PNG 文件放入 Xcode 中,它们作为可着色 UIButton
图像使用此行作为示例可以正常工作:
[self.backButton setTintColor:[UIColor redColor]];
对于我放入的 PNG 文件,我放入的文件是透明的,除了箭头是黑色的。上面的代码对我要着色的图像没有任何作用。
我找到了 other posts covering this topic,但与其为 UIButton
上的每个图标键入 10-20 行代码,我宁愿使用正确的设置来保存它在 Gimp 中并仅引用 Xcode.
在Gimp中保存为PNG格式需要注意哪些设置?
更新
我最初认为添加色调会导致我的应用程序崩溃,但是缓存清理解决了该问题。无论如何,我的 UIButton
具有 PNG 背景不会改变色调。它始终是黑色的,但如果按钮被禁用它会变成木炭色(深灰色?)。
更新 2 我已经试过了,但没有成功:
self.backButton = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *backButtonImage = [[UIImage imageNamed:@"back"]imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.backButton setImage:backButtonImage forState:UIControlStateNormal];
self.backButton.tintColor = [UIColor myCustomColor];
我放弃了,选择了 UISwipeGestureRecognizer
--界面效果更好,所以没有妥协。显然,您可以为某些按钮着色,但不能为其他按钮着色。