Yevgeni Yevgeni - 5 months ago 9
Objective-C Question

Title shows 3 dots "..." instead of the string in a toggle button

Strange behaviour. Im trying to make toggle button that changes the title of the button.
But instead of "Done" it shows me "..." :

enter image description here

The method:

-(IBAction)toggleEditingMode:(id)sender
{
if(self.isEditing){
[sender setTitle:@"Edit" forState:UIControlStateNormal];

[self setEditing:NO animated:YES];
}
else if(!self.isEditing){
[sender setTitle: @"Done" forState:UIControlStateNormal];

[self setEditing:YES animated:YES];
}
}

Answer

It's truncating, either button needs to be bigger, or text needs to be smaller.

To adjust text dynamically,

yourButton.titleLabel.adjustsFontSizeToFitWidth = YES;
yourButton.titleLabel.minimumScaleFactor = 0.5;
Comments