How to set the title of UIToolBar?

后端 未结 8 1276
独厮守ぢ
独厮守ぢ 2021-02-01 07:09

How can I set the title of UIToolBar such that it looks the same as the title in UINavigationBar?

I tried to use a button with plain style, it looks ok, but it will be

8条回答
  •  爱一瞬间的悲伤
    2021-02-01 07:28

    UILabel* title = [[[UILabel alloc] init] autorelease];
    [title setBackgroundColor:[UIColor clearColor]];
    [title setFont:[UIFont boldSystemFontOfSize:20]];
    [title setTextAlignment:UITextAlignmentCenter];
    [title setTextColor:[UIColor grayColor]];
    [title.layer setShadowColor:[[UIColor colorWithWhite:1.0 alpha:0.5] CGColor]];
    [title.layer setShadowOffset:CGSizeMake(0, 1)];
    [title.layer setShadowRadius:0.0];
    [title.layer setShadowOpacity:1.0];
    [title.layer setMasksToBounds:NO];
    [title setText:@"Sample Title"];
    [title sizeToFit];
    
    // [[[UIBarButtonItem alloc] initWithCustomView:title] autorelease]
    

提交回复
热议问题