How to achieve the real time blurring effect for the navigation bar in iOS 7.
If i scroll the contents should get blurred behind the navigation bar. Please help me with some code for iOS 7.
Thanks!
I want to achieve like this--
https://drive.google.com/file/d/0B0qSYN2gw-4-MGhneFF2VnlBVk0/view?usp=sharing
In iOS 7 this effect in navigationBar is achieved easily by setting translucent property to YES:
self.navigationController.navigationBar.translucent = YES;
Related
I have a ViewController which has a hidden navigationBar (supported by a NavigationController). The problem is that the navigation bar is rendering a black image on the bottom of the nav bar.
What am i doing wrong?
This is a bug in iOS 11. If you try on a lower target you´ll see that it will work. The problem is that the navigation bar goes up like 10 pixels on iOS 11. Not much to do at the moment for this.
I have a custom navigation bar that worked well until iOS 11. It appears smaller than it should and seems to ignore the status bar height or something.
I set the whole thing programmatically and the height is set to 64.
have you tried to disable (untick) safe area?
I'm trying to get this blur-translucent navigation bar effect (The first navigation bar in the image) in my Swift iOS application:
But I can't get this done. I've tried several methods, some of them are below:
setBackgroundImage, shadowImage and translucent attrs in AppDelegate (Getting the NavController from the RootViewController attr)
Those lines in AppDelegate main method:
UINavigationBar.appearance().translucent = true;
UINavigationBar.appearance().barTintColor = UIColor(white: 1, alpha: 0.4)
Changing attributes from UIBuilder
Setting self.automaticallyAdjustsScrollViewInsets = true and self.edgesForExtendedLayout = UIRectEdge.None in viewControllers
But still can't get this to work. I'm running the app on XCode simulators, using iOS 8.1 and 9.0
What I am doing wrong?
The second navigation bar is already translucent and blurred—it just isn't quite as translucent as the first navigation bar. If you open Digital Color Meter and mouse over your screenshot, you can see that the background of the second navigation bar is darker in the area covering the image.
The reason why the first navigation bar is more translucent than the second navigation bar was explained in this question: the screenshot of the first bar was taken from a device running iOS 7.0.2, whereas the screenshot of the second bar was taken from a device running iOS 7.0.4. Apple changed the behaviour of UINavigationBar between those versions of iOS, and again with iOS 7.1.
Apple explains the current translucency mechanism as follows:
A translucent bar mixes its barTintColor with gray before combining it with a system-defined alpha value to produce the final background color that is used to composite the bar with the content it overlies.
The only description of the blur effect appears to be the following:
Navigation bars are translucent by default in iOS 7. Additionally, there is a system blur applied to all navigation bars.
You can change the transparency of the bar by using UIImage.imageWithColor: to make a background image for the bar from a UIColor with an appropriate alpha value, but doing so will remove the blur effect. There is no documented way to alter the "system-defined alpha value" to increase the translucency of the bar without removing the "system blur".
If you want to imitate the old translucency and blurring effects on iOS 8.1 and 9.0, you'll need to make your own subclass of UINavigationBar and insert one or more subviews such as a UIView with a background color that uses an appropriate alpha value (for transparency) and/or a UIVisualEffectView (for the blur effect).
You might be able to find a combined view in one of the answers to this question.
Related: Blurring effect disappeared on iOS 7.1
Add bellow code in didFinishLaunchingWithOptions:
For Objective C
[[UINavigationBar appearance] setTranslucent:NO];
For Swift 3+/iOS 10+
UINavigationBar.appearance().isTranslucent = false
Maybe plist changes can fix your problem.
I want add 20 points margin to my navigation bar. I need it because I want another background color under status bar as youtube did:
I found
iOS Developer library says: Status bar background appearance provided by the window background, if using UIBarPositionTop.
I found solution for toolbar, but I can't move my navigation bar inside navigation view controller. I just set UIBarPositionTop for my navigation bar, but it changes nothing.
-(UIBarPosition)positionForBar:(id<UIBarPositioning>)bar {
NSLog(#"position method called");
return UIBarPositionTop;
}
I still see the gray background of status bar instead of white.
Is it possible to do it with a navigation bar or should I use a view with a toolbar?
(XCode 6, development target 7.0+, sdk 8.0, autolayout)
UPDATE: ANOTHER WAY TO RESOLVE PROBLEM
I read this question
and understood, that there is no need to add margin. I added view with background color I need over my navigation bar controller and it resolved my problem.
When you are adding your UIView to the UIWindow, you should change the UIViews size to not underlap the title bar. How to do this is well documented in this post:
Offset on UIWindow addSubview
I hope i understood correctly, look in size inspector, ios 6/7 deltas.
Check this link for an explanation:
Interface Builder: What are the UIView's Layout iOS 6/7 Deltas for?
In iOS7 the navigation barTintColor is very 'bland'. In iOS6 (and below) the color of the navigation bar would fade from lighter to darker from top to bottom.
In iOS7, I can make the navbar a custom color, but it is the same from top to bottom. Is there any way to get the same fading effect?
Thank You!
You can use the open-source CRGradientNavigationBar subclass to support gradients. This is preferable because it is more robust than having to deal with images.
You set up your navigation controller like so:
UINavigationController *navigationController = [[UINavigationController alloc] initWithNavigationBarClass:[CRGradientNavigationBar class] toolbarClass:nil];
or set the class of the navigation bar in storyboard, and then pass an array of colors using setBarTintGradientColors:.
[[CRGradientNavigationBar appearance] setBarTintGradientColors:colors];
Use the various UINavigationBar setBackgroundImage... methods. Pass in an image with the desired gradient.
Keep in mind however, that people expect to see the new iOS 7 look in their iOS 7 app. This means moving away from the old iOS 6 look.