change font of back button on uinavigationcontroller

前端 未结 5 1161
滥情空心
滥情空心 2020-12-25 12:14

I\'m trying to change the font color of the text on my back button in my UINavigationControllerBar

    [[UIBarButtonItem appearance] setTitleColor:[UIColor r         


        
5条回答
  •  长发绾君心
    2020-12-25 12:25

    And the beautiful solution, iOS7+ (because of attribute names):

    NSShadow *shadow = [NSShadow new];
    [shadow setShadowColor: [UIColor colorWithWhite:0.0f alpha:0.750f]];
    [shadow setShadowOffset: CGSizeMake(0.0f, 1.0f)];
    
    [[UIBarButtonItem appearance] setTitleTextAttributes:@{
            NSFontAttributeName: [UIFont systemFontOfSize:24],
            NSForegroundColorAttributeName: [UIColor colorWithWhite:0.2 alpha:1.0],
            NSShadowAttributeName: shadow,
    } forState:UIControlStateNormal];
    

提交回复
热议问题