Navigation with only Back Button and transparent background
That seems pretty easy, by the following code used in my app too:-
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.translucent = true
self.navigationController?.view.backgroundColor = UIColor.clearColor()
Edit:-
To remove back button text:-
navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .Plain, target: nil, action: nil)
Swift 3.0
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.isTranslucent = true
self.navigationController?.view.backgroundColor = UIColor.clear
Transparent background for header using createStackNavigator, React Native
To achieve this effect you need to follow those steps:
- Change the style of the navigation header with absolute position, transparent background and no border.
- Use ImageBackground component as parent component for your screen with the image that you want to use as background.
- Add padding top to this ImageBackground to fix the overlapping.
So your code should looks something similar to this:
import React, {Component} from 'react';
import {
StyleSheet,
Button,
ImageBackground,
Platform,
} from 'react-native';
import {
createStackNavigator,
} from 'react-navigation';
class HomeScreen extends Component {
render() {
return (
<ImageBackground
style={styles.container}
source={require('./images/bg.png')}
>
<Button
onPress={() => {}}
title="Just a button"
/>
</ImageBackground>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: Platform.OS === 'ios' ? 60 : 80,
}
});
const App = createStackNavigator({
Home: {
screen: HomeScreen,
navigationOptions: {
title: 'Home',
headerStyle: {
position: 'absolute',
backgroundColor: 'transparent',
zIndex: 100,
top: 0,
left: 0,
right: 0,
elevation: 0,
shadowOpacity: 0,
borderBottomWidth: 0,
}
},
}
})
export default App;
How to make navigation bar transparent with a back button and the webView will display until the edge of the status bar
You can get navbar height by, This will work for all screens
let height = self.navigationController.navigationBar.frame.size.height
and you need to set the top constraint of your webview to -ve to this value. first, take the reference of the top constraint say
@IBoutlet weak var topRefWebView:NSLayoutConstraint!
set its value at view will appear
let height = self.navigationController.navigationBar.frame.size.height
topRefWebView = -1 * height
Navigation bar only have background when scroll
You need opaque appearance, because default
one means system-selected-by-design
which is changed from version to version.
let navBarAppearance = UINavigationBarAppearance()
navBarAppearance.configureWithOpaqueBackground()
UINavigationBar.appearance().scrollEdgeAppearance = navBarAppearance
Tested with Xcode 13.3 / iOS 15.4 (in ContentView.init)
Note: onAppear is too late to inject above code, the appearance settings are applied on objects created after it, and onAppear is called after NavigationView created. So use it either in init, or anywhere else, but before view created.
ios 5 change the background of back button in navigation controller to transparent
You can't change the appearance of the default back button, but you can create your own button to replace it.
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
if ([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)] ) {
UIImage *image = [UIImage imageNamed:@"greenbar.png"];
[self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
// [[UIBarButtonItem appearance] setBackButtonBackgroundImage:image forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
}
//change back button image
if(self.navigationController.viewControllers.count > 1) {
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
[backButton setTitle:@"Back" forState:UIControlStateNormal];
[backButton addTarget:self action:@selector(didTapBackButton:) forControlEvents:UIControlEventTouchUpInside];
backButton.frame = CGRectMake(0.0f, 0.0f, 64.0f, 41.0f);
UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
self.navigationItem.leftBarButtonItem = backButtonItem;
}
}
- (void) didTapBackButton:(id)sender {
if(self.navigationController.viewControllers.count > 1) {
[self.navigationController popViewControllerAnimated:YES];
}
}
Flutter Android transparent navigation bar and buttons
I found this Flutter Package and it's working
How to add Back Button without using AppBar in Flutter?
Simran, this is a little tricky but it is possible with the combination of Stack
, SingleChildScrollView
and AppBar
. Here is quick example demonstrating this,
return Scaffold(
body: Stack(children: <Widget>[
Container(
color: Colors.white,// Your screen background color
),
SingleChildScrollView(
child: Column(children: <Widget>[
Container(height: 70.0),
buildRow('This is test row.'),
buildRow('This is test row.'),
buildRow('This is test row.'),
buildRow('This is test row.'),
buildRow('This is test row.'),
buildRow('This is test row.'),
buildRow('This is test row.'),
buildRow('This is test row.'),
buildRow('This is test row.'),
buildRow('This is test row.'),
buildRow('This is test row.'),
buildRow('This is test row.'),
buildRow('This is test row.'),
buildRow('This is test row.'),
buildRow('This is test row.'),
buildRow('This is test row.'),
buildRow('This is test row.'),
])
),
new Positioned(
top: 0.0,
left: 0.0,
right: 0.0,
child: AppBar(
title: Text(''),// You can add title here
leading: new IconButton(
icon: new Icon(Icons.arrow_back_ios, color: Colors.grey),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: Colors.blue.withOpacity(0.3), //You can make this transparent
elevation: 0.0, //No shadow
),),
]),
);
Note: You can make the AppBar
completely transparent. However, you'll need to design your widgets accordingly to make sure back button is visible. In the example above, i just set the opacity.
Hope this helps. Good luck!
Related Topics
Swift Add Line Above to Control
Swift Get Specific Value from Firebase Database
iOS - Send Image to Instagram - Documentinteraction
Openurl in Appdelegate Conversion Error Nsstring -> String (Swift & iOS8)
App Crash on Device But Works on Simulator iOS
Cmpedometer Querypedometerdatafromdate Returns Error 103
Manage a Uipickerview from an External Class - Using Swift
How to Keep the Header Cell Moving with the Tableview Cells in Swift 2.0
Wkwebview Blank After 'Successful' Https Nsurlrequest
How to Monitor More Than 20 Regions
Memory Usage Keeps Rising on Older Devices Using Metal
Save Image with the Correct Orientation - Swift & Core Image
How to Convert This Opengl Pointer Math to Swift
-[Uithreadsafenode Canperformaction:Withsender:]: Unrecognized Selector Sent to Instance
How to Access My Swift Classes from My UI Tests
Alamofireimage Disk Cache Not Working