您的位置:首页 > 移动开发 > IOS开发

ios改变导航条title的字体大小和颜色

2014-04-03 15:03 435 查看
- (void)viewDidLoad
{
    [superviewDidLoad];
// Do any additional setup after loading the view.
    
   /**第一种方法
*/

//自定义标题

    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0 , 100, 44)];

    titleLabel.backgroundColor = [UIColor clearColor];

    titleLabel.font = [UIFont systemFontOfSize:15];

    titleLabel.textColor = [UIColor darkGrayColor];//设置文本颜色

    titleLabel.textAlignment = UITextAlignmentCenter;

    titleLabel.text = @"Settings";

    self.navigationItem.titleView = titleLabel;

 /**第二种方法
    self.title = @"首页";
    -(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    */
   
   NSDictionary *dict = [NSDictionary
dictionaryWithObject:[UIColor
yellowColor] forKey:UITextAttributeTextColor];
   self.navigationController.navigationBar.titleTextAttributes = dict;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  uilabel 导航