我想知道如何从 UIBarButtonItem 中的两行标签中去掉左右空格,它的视图由 setCustomView 设置,如下所示:
UIButton* forwardButton = [UIButton buttonWithType:101];
[forwardButton setTransform:CGAffineTransformMakeScale(-1.0, 1.0)];
[forwardButton.titleLabel setTransform:CGAffineTransformMakeScale(-1.0, 1.0)];
[forwardButton setTitle:@"Now\nPlaying" forState:UIControlStateNormal];
[forwardButton addTarget:self action:@selector(openPlayer) forControlEvents:UIControlEventTouchUpInside];
[forwardButton.titleLabel setNumberOfLines:2];
[forwardButton.titleLabel setLineBreakMode:NSLineBreakByWordWrapping];
[forwardButton.titleLabel setTextAlignment:NSTextAlignmentCenter];
[forwardButton.titleLabel setFont:[UIFont boldSystemFontOfSize:10]];
[navButton setCustomView:forwardButton];
这是我得到的结果。
按钮的宽度就好像标签有这样的一行文字。