Yogesh's Blog

Sharing me with blog…
Archive for October, 2014

If we have added a push segue in a view controller, that segue actually performs navigation, destination view gets a back button in navigation bar even if we do not add any back button. If we like to have customised look of this back button, we can’t do that in storyboard (because we are not specifying anything in storyboard for back button or if we are specifying back text, then there is no look customisation option in storyboard.) In order to customise this back button (Suppose change colour or font or font size), we can achieve it by following way: 1. Specify desired back button (in navigation bar of destination controller) text in storyboard as back text for push segue (This is must, otherwise our customisation in code does not appear) 2. Open controller code from where that segue will perform to open view where we want to see customised behaviour (For ex. if ControllerA is pushing segue to ControllerB, and ControllerB is showing “Back” button which we want to customise, then we need to add customisation code in ControllerA) 3. in viewDidLoad (of source controller of segue as explained in step2), specify desired customisation [self.navigationItem.backBarButtonItem setTitleTextAttributes:[[NSDictionary alloc] initWithObjectsAndKeys:[UIFont fontWithName:@”Champagne&Limousines” size:20.0] , NSFontAttributeName, nil] forState:UIControlStateNormal]; Note: Here first step if must, and it is indication changes in destination controller in storyboard. While second and third steps are indication source controller code.