Clipped UITextField with UITextFieldAlignmentRight

Posted by Typeoneerror on Stack Overflow See other posts from Stack Overflow or by Typeoneerror
Published on 2010-04-04T01:44:38Z Indexed on 2010/04/04 1:53 UTC
Read the original article Hit count: 524

Filed under:
|
|

Got a small problem with UITextField. I have a simple UITextField and when I set the textAlignment property to "right", it gets clipped by 1-2 pixels. It looks shite so I'm hoping someone has an idea of how to remedy this. I've tried setting the frame to integers to prevent them from being on .5 pixels.

- (UITextField *)textControlForSetting:(NSDictionary *)settings
{
    CGRect frame = CGRectIntegral(CGRectMake(100.0f, 0.0f, 170.0f, 44.0f));
    UITextField *textField = [[[UITextField alloc] initWithFrame:frame] autorelease];
    NSString *defaultValue = [settings objectForKey:kDefaultValueKey];
    NSString *currentValue = [prefs objectForKey:[settings objectForKey:kSettingKey]];

    textField.tag = settingsCounter;
    textField.delegate = self;
    textField.textAlignment = UITextAlignmentRight;
    textField.font = [UIFont fontWithName:@"HelveticaNeue" size:14.0f];
    textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    textField.placeholder = (currentValue != nil) ? currentValue : defaultValue;

    settingsCounter++;
    return textField;
} 

alt text

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about iphone