Custom back indicator image and iOS 11 Custom back indicator image and iOS 11 ios ios

Custom back indicator image and iOS 11


1) remove PositionAdjustment if have any. such as

  bap.setBackButtonTitlePositionAdjustment(UIOffset(horizontal: 0, vertical: -64), for: .default)

2) check if the previous ViewController in nav stack has a title


I think this method is ok! It's useful for me.

if(@available(iOS 11, *)) {    [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor clearColor]} forState:UIControlStateNormal];    [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor clearColor]} forState:UIControlStateHighlighted];} else {    [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-60, -60) forBarMetrics:UIBarMetricsDefault];}


For anyone who couldn't resolve it:

1) Search in your project (cmd+shift+f) for "setBackButtonTitle", you will find a code like below:

[[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[xController class]]] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];

2) Change code above with this one:

[[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[xController class]]] setBackButtonTitlePositionAdjustment:UIOffsetMake(-200, 0) forBarMetrics:UIBarMetricsDefault];

Since iOS 11, above code we used to hide back button titles, moves back button along with the title itself. However if you just move the back button title horizontally, everything works fine and there's no backdraws.


matomo