I am trying to set the title of my navigation item by setting a UILabel to it. The code essentially works, but my is problem that when the View loads, for a second or so the UILabel starts at the position defined by the CGRectMake
rather that at the top and middle of the navigation bar where it belongs. Is there a way to default having the UILabel start in the correct position?
The obvious work around is to set the initial position off the screen so it is hidden and then after a split second the UILabel moves to the correct place. but this seems to be the 'wrong' way to accomplish what I need. below is the code.
@property (nonatomic, strong) UILabel *titleView;
...
self.titleView = [[UILabel alloc] initWithFrame:CGRectMake(20.0f, 0.0f, 150.0f, 128.0f)];
self.titleView.font = [UIFont systemFontOfSize:10.0f];
self.titleView.text = @"My title";
self.navigationItem.titleView = self.titleView;