jansma jansma - 1 year ago 100
Swift Question

How to remove all navigationbar back button title

When I push a

, it has some title in back button at new
, if the title has a lot of text, It does not look good in iPhone 4s So I want to remove it.

If I add some code in
function, it is going to be a trouble.

Any better way to achieve this´╝č

Answer Source

If you want back arrow so following code put into AppDelegate file into didFinishLaunchingWithOptions method.

For Objective-C

 [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];

Another option give below.

In Objective C

self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];

In Swift

self.navigationItem.backBarButtonItem = UIBarButtonItem(title:"", style:.Plain, target:nil, action:nil)

So may be your problem has been solve.

Happy coding.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download