NavigationItem.titleView custom自定义

NSMutableAttributedString *titleString = [[NSMutableAttributedString alloc]initWithString:@"Cloud 2 Door"];

    [titleString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:185/255.0 green:225/255.0 blue:238/255.0 alpha:1.0] range:NSMakeRange(0, 5)];

    [titleString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(6, 6)];


UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 30)];

    [customLab setTextColor:[UIColor blueColor]];

    [customLab setAttributedText:titleString];

    customLab.font = [UIFont boldSystemFontOfSize:24];

    customLab.textAlignment = NSTextAlignmentCenter;

    self.navigationController.navigationItem.titleView = customLab;


你可能感兴趣的:(NavigationItem.titleView custom自定义)