开发者

editingRectForBounds: moves my background image of UITextField to left

开发者 https://www.devze.com 2023-03-26 15:41 出处:网络
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 backg

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, b开发者_如何学运维ounds.size.height);
    return inset;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消