1

I am trying to place a label in navigation item title view. In case of long titles,on pushing/popping to other screen, the label moves from its original position and a transition takes place.
The code to set the label:

- (void)setNavBarTitle:(NSString *)title {

        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0.0, 0.0, 320.0, 60.0)];
        label.font=[UIFont boldSystemFontOfSize:20.0];
        [label setBackgroundColor:[UIColor clearColor]];
        [label setNumberOfLines:0];
        [label setTextColor:[UIColor whiteColor]];
        [label setTextAlignment:NSTextAlignmentCenter];
        [label setText:title];
        [label sizeToFit];

        self.navigationItem.titleView = label;
        self.parentViewController.navigationItem.titleView = label;
    }

0 Answers0