Eu tenho o seguinte código:
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];
O problema é que, quando a sequência no texto não é longa, ela mostra boa (1-2 dígitos). No entanto, quando é bastante longo (3 dígitos), tudo o que vejo é um botão vermelho, sem texto dentro. Como ajusto isso?
Eu não acho isso:
[button.titleLabel setAdjustsFontSizeToFitWidth:YES];
faz o trabalho, certo?
titleButton.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
