Nazish Ali Nazish Ali - 1 month ago 14
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

Answer

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.

https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/UIKitUICatalog/index.html#//apple_ref/doc/uid/TP40012857-UIView-SW7

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 ];
Comments