1

My question is this,

I have a UITextField that has a background image applied to it through IB, I am attempting to move the margin of the left side in 10px. However when i do the following, the background image moves with the text. Any thoughts?

textField.bounds = [self editingRectForBounds:textField.bounds];
textField.bounds = [self textRectForBounds:textField.bounds];


- (CGRect)textRectForBounds:(CGRect)bounds {
    CGRect inset = CGRectMake(bounds.origin.x + 10, bounds.origin.y, bounds.size.width - 10, bounds.size.height);
    return inset;
}

- (CGRect)editingRectForBounds:(CGRect)bounds {
    CGRect inset = CGRectMake(bounds.origin.x + 10, bounds.origin.y, bounds.size.width - 10, bounds.size.height);
    return inset;
}
James Dunay
  • 2,714
  • 8
  • 41
  • 66
  • Have a look at http://stackoverflow.com/questions/3727068/set-padding-for-uitextfield-with-uitextborderstylenone. Very similar problem. – Akshay Aug 09 '11 at 03:31
  • That works most of the time, however when i have a UILabel that is in the rightView allowing me to put a more custom text in, it doesnt allow me to, or doesnt show up, to have a leftView – James Dunay Aug 09 '11 at 15:58

0 Answers0