0

I have a PNG file that's an arrow that I'd like to use as an icon in an iOS app. I've dropped other PNG files into Xcode and they work fine as tintable UIButton images using this line as an example:

[self.backButton setTintColor:[UIColor redColor]];

With the PNG file I dropped in, the file I'm dropping in is transparent except for the arrow, which is black. The code above does nothing to the image I'm trying to tint.

I've found other posts covering this topic, but rather than type 10-20 lines of code for each icon I've got on a UIButton, I'd rather save it with the correct settings in Gimp and just reference the file in Xcode.

What settings should I pay attention to when saving the file as a PNG in Gimp?

Update I initially thought adding the tint was causing my app to crash, however a cache clean resolved that issue. Regardless, my UIButton with a PNG background won't change tints. It's always black, though it turns charcoal (darkGray?) colored if the button is disabled.

Update 2 I've tried this without any luck:

self.backButton = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *backButtonImage = [[UIImage imageNamed:@"back"]imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.backButton setImage:backButtonImage forState:UIControlStateNormal];
self.backButton.tintColor = [UIColor myCustomColor];
Community
  • 1
  • 1
Adrian
  • 16,233
  • 18
  • 112
  • 180
  • Provide relevant code and details about the crash. – rmaddy Aug 01 '15 at 17:38
  • @rmaddy I updated my query. I cleaned the cache and the crash went away, but the issue w/ my PNG image on a button persists. It looks like every other PNG button image I open in Gimp, so I can only conclude I'm fouling up a setting when saving the PNG file – Adrian Aug 01 '15 at 19:16
  • Under what method did you tint it? – ThatGuy Aug 01 '15 at 22:13
  • 'viewDidLoad' is the method that code is contained in – Adrian Aug 01 '15 at 22:29

1 Answers1

0

I gave up and opted for a UISwipeGestureRecognizer--works out better for the interface, so no compromise. Apparently, you can tint some buttons, but not others.

https://stackoverflow.com/a/11066046/4475605

Community
  • 1
  • 1
Adrian
  • 16,233
  • 18
  • 112
  • 180