I have an interesting issue with an existing project and iOS7.1, I think. I've had code working and performing normally; since updating XCode and my iOS on my devices I have a problem, a transparent background image used in the Navigation Bar for that project is now rendered twice, once at the correct size and again blown up and blurry. The code only adds the image via the [UINavigationBar appearance] api in the app delegate. To check that this wasn't a specific bug with my code I create a default xcode project using the master detail default, set it to be iPhone only, added some newly created images and set them using the same calls in the app delegate. This project had the same issue and is on github here:
UINavigationBarBug github source
This is the relevant chunk of code imo:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"TLS.png"]
forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBarTintColor:RGB(233, 155, 20)];
[[UINavigationBar appearance] setTintColor:RGB(245, 245, 245)];
return YES;
}
A screenshot of the problem:
Looking at the transition documentation what i am doing here should be fine, the navigation bars at 44 points high should be scaled horizontally and not vertically. I'm also pretty sure this problem never occurred prior to the update (it would have been spotted by internal QA prior to uploading the code to apple for review).
Two things fix it:
1) Using non transparent images, if it still has the problem it is loading the 'correct' image second and due to the lack of transparency overriding the incorrectly rendered one.
2) Using a navigation bar that is 66 points high instead (available in the project with a top transparent section as TLS-ios7), changing the code in the app delegate to use that fixes the problem.
Can anyone enlighten me as to what is going on here? Is this a bug, is it my fault, is there some section of documentation that informs me why this is so?
Thanks!
** Update: I recently found an iPad lying around still running iOS 7.0, this problem does not occur. **
I had a similar issue on my app. I solved it by setting the "translucent" of my UINavigationBar to NO.
[self.navigationController.navigationBar setTranslucent:NO];
You can disable image stretching by defining left and top caps.
Here's a Swift 3 solution:
let navbarImage = image.stretchableImage(withLeftCapWidth: 1, topCapHeight: 1)
UINavigationBar.appearance().setBackgroundImage(navbarImage, for: .default)
Example before:
and after the fix:
I just received this following my bug report... tl;dr It's me providing an image with an incorrect height:
Workaround for iOS 7.1 is to specify a resizable image with a non-zero inset. Internally UINavigationBar will tile your image if it isn't quite the right size and that is basically what was happening here – since the image wasn't tall enough (the navigation bar is top attached, so the image needed to be 64pt tall not 44pt) it would get tiled. If you set it to stretch and configure the cap insets such that it only stretches pixels that are uniform you should be able to avoid this issue.
I had a similar looking issue and it turns out I didn't have the correct image assets in the assets catalog. I only had retina assets but when I imported, they went into the 1x box in the asset catalog - moving them to the 2x box fixed my nav bar for me.
I had a similar problem, I had a logo with transparent background. Height was fine. Added in coloured background and the problem stopped.
Related
Since iOS 11, when the UIWebView is full screen, a fake background appears on the status bar with the same color of the UIWebView background.
Anyone knows how to get rid of it?
Even adding the IUWebView to a storyboard and make it full screen will make the status bar background to appear
I've been trying to edit the size and some other properties of the UIWebView and none of them worked, but it's definitely something from the UIWebView.
Also tried to see all the subviews and it's sizes and didn't see anything strange.
Attached a screenshot, see the grey "statusbar", it disappears when scrolling, and doesn't appear if the UIWebView is not over that part of the screen.
I want it as on the second screenshot, only remove the fake background, not the status bar.
This happens because of UIScrollView new behavior to adjust the content inset to include safe area insets like the status bar.
To fix it, just set it to UIScrollViewContentInsetAdjustmentNever
[self.webView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
Since iOS 11 Beta 4 you can add this to your viewport and will also remove the fake statusbar
viewport-fit=cover
To do this entirely in HTML/CSS, viewport-fit=cover in the Viewport meta tag is the correct way to handle this.
But you'll also want to adjust your padding dynamically to handle the differently sized status bar on iPhone X with its notched camera/speaker.
Luckily, Apple exposed some CSS constants for the safe area insets, so you can take advantage of those in your CSS:
i.e., padding-top: constant(safe-area-inset-top);
I wrote a bit more about this scenario and the new features for iOS 11 and iPhone X: https://ayogo.com/blog/ios11-viewport/
Swift version:
webView.scrollView.contentInsetAdjustmentBehavior = .never
It seems odd, so i am likely just missing it in preferences, but how does one change the actual background color of IB in Xcode? Not any of the elements, but the actual blinding white of the standard IB? Too much contrast and when you zoom out, the view controllers almost disappear..
Thanks for any tips..
I've gone ahead and created an Xcode plugin that changes the background color of the storyboard editor. You can find the source at rpendleton/xcode-canvas-color. I've hardcoded it to a light gray color, as shown in the screenshot below, but this can be changed easily.
(Also, I don't think you're missing a setting for it. When I decompiled Xcode, the drawRect method for the background view explicitly called [[NSColor whiteColor] set].)
One doesn’t. Submitting a feature request to Apple is your only hope.
Unfortunately, with recent changes to Xcode, Ryan Pendleton's plugin is no longer a viable option. (unless you are willing to break Xcode's code signing, which can be quite problematic.) However, the good news is that there is now an official solution -- so long as you are willing to upgrade to OS X 10.14 Mojave: Upgrade to OS X 10.14 Mojave and turn on Dark mode. When Dark Mode is enabled, the background in Interface Builder darkens to a nice, eye-pleasing dark gray color. Navigating around a large storyboard is now MUCH easier (and less eye-scorching :) )
Before:
After:
I have an app that uses stroryboards, a navigation controller and autolayout that runs fine under io6 and I would like to enable to run under both ios6 and ios7.
I have converted the app using xcode5 and it now runs fine under ios7, but when I run it under ios 6 the navigation bar and bottom bar are now transparent (they were not originally) and the view flows under them - hiding some of the controls. This persists even if I convert the ios7 app not to flow under these bars (by setting Extend Edges / Under Top Bars and Under Bottom Bars OFF).
I have worked around it by allowing ios7 to flow the view under the bars (what Apple wants us to do anyway) and then adding the following code to the viewDidLoad method of the fist view controller to force ios6 not to use transparent bars.
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
self.navigationController.toolbar.barStyle = UIBarStyleBlackOpaque;
}
This seems to be working, but I don't understand why I need to do this and I am concerned that I am missing something fundamental.
Edit: The other concern I have with this 'solution' is that the Preview in xcode5 under ios6 doesn't accurately reflect the layout as it runs under a simulator under ios 6 (I don;t have a real ios6 device handy to test it at the moment). The new preview feature in xcode5 appears to assume that the ios 6 will not flow the view under the top and bottom bars and thus squashes the controls together to fit into the available space.
Ali
Try this regardless of the OS version (it solved me a similar issue recently):
self.navigationController.navigationBar.translucent = NO;
self.navigationController.toolbar.translucent = NO;
I am not sure if this will help you, but there is another option to your situation: try using the __IPHONE_6_1 macro. I have an example:
if(__IPHONE_7_0) {
NSLog(#"Hello");
}
so you could just do
if(__IPHONE_OS_VERSION_MAX_ALLOWED <= __IPHONE_6_1) {
self.navigationController.navigationBar.translucent = NO;
self.navigationController.toolbar.translucent = NO;
}
hope this helps you
I've seen the Apple video where it explains that if you provide a 44p image for the UINavigationBar it will just set the background for that.
I've also search around and found this very useful post and What I am experiencing is his point number #5. Where even tho I've supplied the 44p image I sill see the status bar with a black background.
I was just wondering... if anyone has been able to find a work around so that the status bar is transparent showing the UIView Background?, I've tried everything I could think of and came across by but nothing seems to work.
I set the background view in my appDelegate
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:#"BlackBackground"] forBarMetrics:UIBarMetricsDefault];
This is how it looks
This is how i want it to look
I'm trying to set the background to an image.
code:
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:#"myPic"]]];
My original plan was to set the self.window to the background image and then have the other views be clear. (Using self.window in the app delegate) But after that turned our to give me a plain black screen (??) , I moved and adjusted the code to my RootViewController. I'm still getting a plain black screen. I tried using a few different images, yet I'm getting the same result on all of them. Any Ideas? Thanks!
The image name "myPic" should contain the file extension i.e. myPic.jpg