我的问题是这个,
我有一个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;
}