Colours appearing different on iPhone 6 plus using UIImageRenderingModeAlwaysTemplate - ios

I have a PNG image that I am re-colouring at runtime:
logo.image = [[UIImage imageNamed:#"logo.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
logo.tintColor = [UIColor whiteColor];
This appears white on my iPhone 6, all the simulators etc; but it is a slightly darker grey colour on an iPhone 6+. Could there be a reason I've missed?
Here's a screenshot of the iPhone 6+ (all the navigation items should be white - like every other device)

barTintColor is made translucent by default unless you set the
translucent property to NO.
Try this
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
self.navigationController.navigationBar.translucent = NO;

Related

ios 11 color of the app (uinavigation)

Am using this color for the UINavigationController and some of other views
[UIColor colorWithRed:0.137 green:0.137 blue:0.145 alpha:1.00]
but there is a strange behaviour with iOS 11 when I run the application sometimes the color is correct (dark) and sometimes the color be in light mode a lighter than the original color
Replace
[UIColor colorWithRed:0.137 green:0.137 blue:0.145 alpha:1.00]
with
[UIColor colorWithRed:137.0/255.0 green:137.0/255.0 blue:145.0/255.0 alpha:1.00]

Change Notification Content Extension background color

While developing Notification Content Extension I noticed, it's impossible to change background color to clear color.
I want it looks like background of weather standard app widget.
So, if I change background color of View to clear in IB or by code, it's become white without alpha.
You see that buttons with blurred background and white notification background looks awful. If you have some ideas, please tell me.
Tested on iPhone 6 Plus and iPhone 6s iOS 10 beta 3 and Xcode 8 beta 3.
you can try adding a UIBlurEffect like this:
self.view.backgroundColor = [UIColor clearColor];
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
blurEffectView.frame = self.view.bounds;
blurEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
blurEffectView.alpha = 0.5;
[self.view insertSubview:blurEffectView atIndex:0];
you can play with background color or with UIBlurEffectStyle to achieve exact thing that you like.

Change color of navigation bar ios6 and ios7

I'm in the process of upgrading my app to iOS7. However I want to preserve the iOS6 interface as well. It works well except for the navigation bar(s). In iOS7 they look great (just the default color with the translucent property to YES. In iOS6 the navigation bars are showing as the default blue bars and I want them to be black translucent.
What I do is check the version of the iOS and then perform some code. In the debugger I see they right version in the vComp variable but the color is not changing. Don't mind the redColor property, that's just for the test. In both ways I am presented with the default color.
Here is my code:
- (void) fixNavBarColor:(UINavigationBar*)bar {
NSArray *vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:#"."];
if ([[vComp objectAtIndex:0] intValue] >= 7) {
bar.barTintColor = [UIColor redColor];
bar.translucent = NO;
}
else {
bar.tintColor = [UIColor redColor];
bar.opaque = YES;
}
}
There is no error or warning.
Any ideas?
You shouldn't set the tintColor straight to navigationBar as it wouldn't be applied to other parts of your app, you should instead use UINavigationBar's appearance to set tintColor which is available on iOS 5.0 onwards.
[[UINavigationBar appearance] setTintColor:"Your Color"];
Use this code for iOS6
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithWhite:0 alpha:.8]]
forBarMetrics:UIBarMetricsDefault];

Different positioning on iOS7 iPad Mini and iOS6 iPad 3

I have a simple placement of a UILabel in my app's code:
headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 5, 884, 68)];
headerLabel.font = [UIFont fontWithName:#"HoboStd" size:64];
headerLabel.textAlignment = UITextAlignmentCenter;
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.textColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:1.0f];
headerLabel.adjustsFontSizeToFitWidth = YES;
[self.view addSubview:gameSpeaks];
On an iOS6 iPad 3 the text is showing a little higher up on the screen than it is on the iOS 7 iPad Mini with the same code, same .xib and everything. Does anybody know if this is a result of iOS6 vs iOS7 or if it is a result of the different devices or some other issue I am not aware of?
I WANT to say that the iPad Mini was showing the text in the same position as the iPad 3 when I was testing with it on iOS6, and then I upgraded it to iOS7 and noticed this difference. If it is the OS version that is causing this issue - what is the preferred way for testing for OS version in code so that I can reposition the label as needed when running on an OS7 device vs OS6?
Thanks so much!
It's a result of iOS6 vs iOS7 given that the status bar is now part of the view.
In iOS7, everything will appear about 20 pixels farther up than it did in iOS6 and previous if you do not adjust them.
In iOS6 and previous, setting a UI element's y origin to 0 would put it at the very bottom edge of the status bar. In iOS7, a y origin of 0 will now put it at the very top edge of the screen, behind the (now transparent) status bar.
You can get the current version of a device using:
[[UIDevice currentDevice] systemVersion]

How to consolidating the translucency of the navigation bar between iPhone 5S and 5?

I have difficulty consolidating the UINavigationBar's barTintColor between iPhone 5 and 5S. Both of my phones are on iOS 7. In the following screenshot, the top is 5S and the bottom is 5. iPhone 5S shows an extremely translucent effect while iPhone 5 shows a much more subtle effect. Only very dark objects are visible behind the navigation bar for iPhone 5.
[[UINavigationBar appearanceWhenContainedIn:[UINavigationController class], nil]
setBarTintColor:[UIColor
colorWithRed:46.0 / 255.0
green:160.0 / 255.0
blue:152.0 / 255.0
alpha:0.8
]
];
I would prefer that both phones look like the iPhone 5. If I were to increase the alpha of the barTintColor to 1.0, iPhone 5's navigation bar would become completely opaque. This is the expected result. Although iPhone 5S's bar would become less translucent, the effect is still too strong. How would I decrease the translucency even more, without making it completely opaque?
As discussed in the comments, you are seeing different behaviors because one of the devices is using an outdate iOS 7 version. Apple made changes in version 7.0.3 to the way bar tint color is processed, and now the alpha value is taken into account. You should focus on the newer version of iOS.
if you still want to set the alpha for your navigation bar in IOS 7.1 I found a workaround to do it. Create an image from a colour with alpha set for it, then assign this image as a background to the navigation bar:
1- here is the method to create an image from colour:
-(UIImage *)imageWithColor:(UIColor *)color {
CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
i found it at: Creating a UIImage from a UIColor to use as a background image for UIButton
//create a colour and set its alpha:
UIColor *colorWithAlpha = [UIColor colorWithRed:(80/255.f) green:(146/255.f) blue:(84/255.f) alpha:0.2]; // light red colour
// create your background image:
UIImage *backgroundImage = [self imageWithColor: colorWithAlpha];
//set this image as a background image:
[self.navigationController.navigationBar setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init]; // to remove shadow

Resources