What's UIBarButtonItem's possibleTitles for?

前端 未结 2 1061
刺人心
刺人心 2021-02-15 16:57

In UIKit, UIBarButtonItem has a property called possibleTitles. How is that being used?

2条回答
  •  孤街浪徒
    2021-02-15 17:28

    I wrote a little code to test this out and it's like Ed says, the button will be as wide as it needs to be to fit the longest string in the NSSet given to possibleTitles

    UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithTitle:@"Bye"
                style:UIBarButtonItemStyleBordered
                target:self
                action:@selector(sayGoodnight)];
    myButton.possibleTitles = [NSSet setWithObjects:@"So Long", @"Farewell", @"Auf Wiedersen, Good Night", nil];
    [self setToolbarItems:[NSArray arrayWithObjects:myButton, nil] animated:NO];
    [myButton release];
    

    The button is set wide enough to fit "Auf Wiedersen, Good Night".

提交回复
热议问题