मेरे पास निम्नलिखित कोड हैं:
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];
मुद्दा यह है कि जब पाठ में स्ट्रिंग लंबी नहीं होती है, तो यह ठीक दिखाता है (1-2 अंक)। हालांकि, जब यह काफी लंबा (3 ++ अंक) है, तो मैं देख सकता हूं कि एक लाल बटन है, जिसमें कोई पाठ नहीं है। मैं इसे कैसे समायोजित करूं?
मुझे नहीं लगता कि:
[button.titleLabel setAdjustsFontSizeToFitWidth:YES];
काम करता है, है ना?
titleButton.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
