开发者

UILabel center align issue

I have a strange issue with UILabel.

I have a countdown module in my app that displays the days/hours/minutes/secs to a particular date.

All o开发者_如何学JAVAf the values are displayed in UILabels with center alignment.

The issue is when we go from 2 digits to 1 digit, the text is no longer center aligned.

I put the following code in the method that is called each second to try and resolve this, but no luck:

 secondLabel.textAlignment = UITextAlignmentCenter;
 secondLabel.baselineAdjustment =  UIBaselineAdjustmentAlignCenters;
 secondLabel.text = [NSString stringWithFormat:@"%2d", components.second];

Do I have redraw the label each time I put the number in there?

Thanks for your time.


You can use @"%02i" instead @"%2d" in the stringWithFormat: NSString selector...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜