0
我不明白简单的代码发生了什么。我想调整UITextField
的宽度,但是当我这样做时,它也会更改它的origin.x
。我尝试了很多配置,但找不到解决方案。UITextfiels界限,奇怪的行为
的文本字段处于UIView
:
containerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
containerView.backgroundColor = [UIColor whiteColor];
textfield = [[UITextField alloc] initWithFrame:CGRectMake(5,20,200,30)];
textfield.leftViewMode = UITextFieldViewModeAlways;
这里是改变其宽度代码:
[UIView beginAnimations:nil context:nil];
textfield.bounds = CGRectMake(textfield.bounds.origin.x,
textfield.bounds.origin.y,
textfield.bounds.size.width + 110,
textfield.bounds.size.height);
[UIView commitAnimations];
每一次,origin.x
改变为类似-55(但NSLog
打印0 )。你有什么主意吗?我想保持总是相同的origin.x
。
感谢您的帮助。
完美!它的解决方案,谢谢你的帮助。 – user269568 2012-01-19 10:05:46