Ho il codice seguente:
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0.0, 0.0, 25, 25);
[[button layer] setCornerRadius:5.0f];
[[button layer] setMasksToBounds:YES];
[[button layer] setBackgroundColor:[[UIColor redColor] CGColor]];
[button.titleLabel setFrame:CGRectMake(0,0, 25, 25)];
[button setTitle:[NSString stringWithFormat:@"%@", [[topics objectAtIndex:indexPath.row] unread]] forState:UIControlStateNormal];
Il problema è che quando la stringa nel testo non è lunga, mostra bene (1-2 cifre). Tuttavia, quando è piuttosto lungo (3 ++ cifre), tutto ciò che posso vedere è un pulsante rosso, senza testo all'interno. Come lo aggiusto?
Non credo che:
[button.titleLabel setAdjustsFontSizeToFitWidth:YES];
fa il lavoro, giusto?
titleButton.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
