in project development, we will encounter the need to define the title text style, the system's API self.title It 's hard to customize it, and the previous API has a very complex dictionary property that can be modified and not explained here, so let's look at a simple way to modify its style.
We look at our own viewcontroller.m file.
- (void) viewdidload{[SuperViewdidload];UILabel*label = [[UILabelAlloc] Initwithframe:cgrectmake (0,0, $, +)]; Self. Navigationitem. Titleview= label; Label. Text= @"Home"; Label. TextAlignment=1; Label. Font= [UifontSystemfontofsize: A]; Label. TextColor= [UicolorWhitecolor]; }
In fact, to Navigationitem assigned a titleview, note, here is self.navigationItem.titleView = label; used
Instead of
[self.navigationItem.titleView addSubview label]
If you want all of the Viewcontroller title to have the same style, create a basicviewcontroller inheritance Viewcontroller then write the above code to him, and then leave an interface to pass the title content.
With the above method, you can also successfully avoid the TabItem title above and the first one added to Tabbarviewcontroller viewcontroller title conflict.
iOS Project development Tips (i)--How to customize Uiviewcontroller's Titile