editingRectForBounds:将我的UITextField背景图像移动到左侧

时间:2011-08-09 03:08:08

标签: iphone objective-c ios xcode

我的问题是这个,

我有一个UITextField,它通过IB应用了背景图像,我试图在10px中移动左侧的边距。但是,当我执行以下操作时,背景图像随文本移动。有什么想法吗?

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;
}

0 个答案:

没有答案