The following is basically my entire project to illustrate the problem:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UILabel *integralLabel = [[UILabel alloc]initWithFrame: CGRectMake(30, 60, 200, 150)];
integralLabel.font = [UIFont systemFontOfSize:100];
[window addSubview:integralLabel];
integralLabel.text = @"∫∫∫";
integralLabel.textAlignment = UITextAlignmentLeft;
integralLabel.backgroundColor = [UIColor yellowColor];
[window makeKeyAndVisible];
return YES;
}
The leftmost integral sign in the label is clipped.
Is there a clean way to fix this? The contents of my labels will change frequently in response to all sorts of things, so I don’t want to do something hackish.
You can add a space at the beginning if the text begins with the integral sign:
EDIT
To distinguish between this space and other spaces in the label, you can use different Unicode values for spaces (full list here: http://www.cs.tut.fi/~jkorpela/chars/spaces.html)
etc…
EDIT 2
You can also subclass UILabel by overriding
drawTextInRect:.Hope this helps.