I created UINavigationController application. I added UILabel to UINavigationBar, but there is a problem. My label is not moving when UINavigationBar is moving to left or to right. How do I solve the problem?
UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(70, 0, 200, 44)] autorelease];
label.text = @"There are too car on the ...";
label.backgroundColor = [UIColor clearColor];
[self.navigationController.navigationBar addSubview:label];
The problem here is that you set the label directly on the UINavigationBar. If you don’t need a customized label and the default behavior is enough for you, you should set the UIViewController title property instead. However, if you need a customized label, you should set your UIViewController’s navigationItem titleView property. Check out the example below. I assume self is an active view controller: