How to center shortcut text in Xcode

I have a cell with two shortcuts. How can I programmatically center the alignment of the top mark and hide the second mark?

+3
source share
3 answers

UITextAlignmentCenteroutdated. You should use the following:

labelOne.textAlignment = NSTextAlignmentCenter;
+8
source

[labelOne setTextAlignment: UITextAlignmentCenter]; // for the center of the text in UILabel [labelTwo setHidden: YES] // there, but not visible.

+4
source

, : - ..

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    firstLabel.frame = cell.frame; // or reconfigure your frame or some reason(i dont know)
    firstLabel.textAlignment = NSTextAlignmentCenter;
    secondLabel.hidden = YES;
}

, ?

0

Source: https://habr.com/ru/post/1749960/


All Articles