UINavigationItem titleView position

前端 未结 7 750
长发绾君心
长发绾君心 2021-02-13 03:45

I\'m using UINavigationItem\'s titleView property to set a custom UILabel with my desired font size/color. Here\'s my code:

self.headerLabel = [[UILabel alloc] i         


        
7条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-13 04:04

    UIView *vw = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];
    UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];
    lbl.text = @"Home";
    lbl.textAlignment = UITextAlignmentCenter;
    lbl.backgroundColor = [UIColor clearColor];
    lbl.textColor = [UIColor whiteColor];
    lbl.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:20];
    lbl.shadowColor = [UIColor blackColor];
    lbl.shadowOffset = CGSizeMake(0,1);
    self.navigationItem.titleView = vw;
    [self.navigationItem.titleView addSubview:lbl];
    

提交回复
热议问题