views:

112

answers:

0

I have created a UILabel that displays a single large character. Even with clipsToBounds = NO; I still get clipping.

See link: http://img341.imageshack.us/img341/5310/screenshot20100814at243.png

I used the following code:

 CGSize fBounds = [myLabel.text sizeWithFont:cFont];

To get what should be the bounding rectangle of the font. And the label is drawn with:

myLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 280, 300)];
 myLabel.clipsToBounds = NO;
 myLabel.numberOfLines = 1;
 myLabel.textAlignment = UITextAlignmentCenter;
 myLabel.adjustsFontSizeToFitWidth = YES;
 myLabel.minimumFontSize = 10;
 myLabel.text = @"A";
 myLabel.font = [UIFont fontWithName:@"CourierNewPSMT" size:300];
 myLabel.textColor = [UIColor blackColor];
 myLabel.backgroundColor = [UIColor colorWithRed:1 green:.5 blue:0 alpha:.5];

In the image below, the size returned from sizeWithFont is rendered by the semi-transparent blue rectangle overlay. As you can see, with an italic font (in this case Verdana-BoldItalic), the character extends past what sizeWithFont returns. Further, the UILabel's frame (the orange color) also clips the character. Thoughts? Maybe I could override some text drawing routine. Also, not sure if this is the same problem as here:

http://stackoverflow.com/questions/3479815/uibutton-titlelabel-clipping-text-problem