iosobjective-ctweak

How to get the original color of the image


I try to get the original color of the image on the rebootButton button I can change color .. but I want to get the original color of the image I create in Photoshop

The problem is that I can not get the original color and I only get a blue color on the whole picture Can i get help please?

 UIColor* tintColor;

UIButton *rebootButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
rebootButton.frame = CGRectMake(self.view.frame.size.width - 250, self.view.frame.size.height / 2 - 80, 60, 60);
[rebootButton setImage:[UIImage imageWithContentsOfFile: reboot3] forState:UIControlStateNormal];
[rebootButton setTitle:@"Reboot" forState:UIControlStateNormal];
[rebootButton addTarget:self action:@selector(reboot) forControlEvents:UIControlEventTouchUpInside];

if(style != 1) {
rebootButton.tintColor = tintColor;
} else {
if(defaultTheme1 == 0) {
[rebootButton setImage:[UIImage imageWithContentsOfFile: reboot1] forState:UIControlStateNormal];
} else if (defaultTheme1 == 1) {
[rebootButton setImage:[UIImage imageWithContentsOfFile: reboot2] forState:UIControlStateNormal];
} else if (defaultTheme1 == 2) {
[rebootButton setImage:[UIImage imageWithContentsOfFile: reboot3] forState:UIControlStateNormal];
}
}
[powerButton centerVertically];
[myView addSubview:powerButton];

// Load preferences using HBPreferences, I could use NSUserDefaults but HBPreferences is fine for now.
static void loadPrefs() {
NSString *kBackgroundColor = @"";
NSString *kTintColor = @"";

[colorPrefs registerDefaults:@{
@"kBackgroundColor": @"#FFFFFF",
@"kTintColor": @"#007AFF"
}];


kTintColor = [colorPrefs objectForKey:@"kTintColor"];
// Set the tint and background colour to a UIColor
tintColor = LCPParseColorString(kTintColor, kTintColor);
backgroundColor = LCPParseColorString(kBackgroundColor, kBackgroundColor);
}

Solution

  • Change

    [rebootButton setImage:[UIImage imageWithContentsOfFile: reboot3] forState:UIControlStateNormal];
    

    To

    [rebootButton setImage:[[UIImage imageWithContentsOfFile: reboot3] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];