Use UINavigationBar appearance back icon for custom button?
UINavigationBar.appearance().backIndicatorImage
is an optional value, therefore you won't be able to get the system default chevron from this. Rather, the system will use the image provided here if not null, otherwise revert to the system default.
If targeting iOS 13+, you can make use of Apple's SF Symbols, in particular the back button icon is referred to as chevron.left
. To use this, call UIImage(systemName: "chevron.left")
. For earlier versions of iOS, you'll have to use an image set asset. You could target all versions of iOS using if #available(iOS 13.0, *) { ... } else { ... }
, where you display the system image if on iOS 13+ for improved UI appearance.
func addBackButton() {
let backButton = UIButton(type: .custom)
if #available(iOS 13.0, *) {
backButton.setImage(UIImage(systemName: "chevron.left"), for: .normal)
}
else {
backButton.setImage(UIImage(named: "backChevon"), for: .normal)
}
backButton.imageView?.contentMode = .scaleAspectFit
backButton.setTitle("Back", for: .normal)
backButton.setTitleColor(backButton.tintColor, for: .normal)
self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: backButton)
}
How to change toolbar back button icon in android material components
If you are using a Toolbar
to change the icon just use:
Toolbar toolbar = findViewById(R.id.xxx);
toolbar.setNavigationIcon(R.drawable.xxxx4);
setSupportActionBar(toolbar);
If you are using the ActionBar
you can use:
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.xxx);
You can also change it overriding in your app theme the homeAsUpIndicator
attribute:
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
<item name="homeAsUpIndicator">@drawable/...</item>
</style>
If you are using the Navigation Components, currently there isn't a way to customize the HomeAsUpIndicator icon, and it is an expected behavior with the Up button displayed when you are on a non-root destination.
There is a workaround adding an addOnDestinationChangedListener
after your setup method and checking the destination.
Something like:
navController.addOnDestinationChangedListener(
new NavController.OnDestinationChangedListener() {
@Override
public void onDestinationChanged(@NonNull NavController controller, @NonNull NavDestination destination, @Nullable Bundle arguments) {
if (destination.getId() == R.id.nav_xxx) {
//With ActionBar
//getSupportActionBar().setHomeAsUpIndicator(R.drawable.xxxx);
//With a Toolbar
toolbar.setNavigationIcon(R.drawable.xxxx);
}
}
});
How to use an icon instead of the original back button in React Navigation?
Try this
const screenOptions = {
headerBackImage: () => (
<FontAwesomeIcon icon={faArrowAltCircleLeft} color="#fff" size={24} />
),
};
here is slack demo
Navigation bar back button custom icon?
What I ended up doing was creating a popup window over the soft input and making the soft input "arrow down" button do what I wanted on that pop up window.
To control what the soft input "arrow down" button does I had to create a class that extends EditText
and override:
public boolean onKeyPreIme(int keyCode, KeyEvent event)
Related Topics
Filter: Progid:Dximagetransform.Microsoft.Gradient Is Not Working in Ie7
How to Make Custom Scrollbars Show in All Browsers
Creating Custom Blocks in Rstudio's Bookdown
PHP/HTML/CSS - If Firefox, If Chrome, If Safari
Full Viewport Height Scaling Div Just CSS No Js... Possible
Wordpress Will Only Fully Load on Localhost
Is Browser Prefix Still Required for Linear-Gradient
Considerations for CSS3 Transition Performance
CSS Gradients in Ie7 & Ie8 Is Causing Text to Become Aliased
Gulp-Sass Fails to Compile SCSS File
Bootstrap 4 Vertical Align Text Won't Center on Card
Pace.Js "Hide Everything But Pace Until The Page Has Fully Loaded" Local Copy
Why Clear: Right Doesn't Work as Intended
How to Configure Sourcemaps for Less Using Grunt
Selected Text Background Color
Slide Out Panel with Bootstrap
Color "Transparent" Not Working
How to Hide One Column from Grid in Bootstrap Mobile Version