Nazish Ali Nazish Ali - 3 months ago 34
iOS Question

Add alert on back button without title of UINavigationBar iOS

I have a screen having navigation bar, back button default is placed using navigationItem storyboard. I want to popup view controller on back button based on condition. Back button is default before Add Event. Please suggest a solution for this problem.enter image description here


If you set the tintColor Of NavigationBar,add a custom back button image without title that tint color will reflect the image color. Please follow this apple documentaion link.

UINavigationItem *navItem = [[UINavigationItem alloc] init]; navBar.tintColor = self.tintColor;

UIImage *myImage = [UIImage imageNamed:@"left_arrow.png"]; myImage = [myImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithImage:myImage style:UIBarButtonItemStylePlain target:self action:@selector(cancelButtonFunction:)];
 navItem.leftBarButtonItem = leftButton;
navBar.items = @[ navItem ];