我有一个文本字段,当我在其中触摸时,我想更改其宽度和图像。图像更改没有任何问题,但宽度保持不变。问题在于触摸文本字段时触发的动作,因为当我创建一个简单的按钮时,动画会起作用。所以我的问题是如何在触摸文本字段时让动画工作。
动画在这里不起作用:
- (void)textFieldDidBeginEditing:(UITextField *)textField{
[UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationCurveEaseOut
animations:^{
self.textFieldSearchStore.background = [UIImage imageNamed:@"text-field-small.png"];
self.textFieldSearchStore.frame = CGRectMake(textFieldSearchStore.frame.origin.x, textFieldSearchStore.frame.origin.y, 248.0f, textFieldSearchStore.frame.size.height);
}
completion:^(BOOL finished){}
];
}
动画在这里工作:
- (IBAction)test:(id)sender {
[UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationCurveEaseOut
animations:^{
self.textFieldSearchStore.background = [UIImage imageNamed:@"text-field-small.png"];
self.textFieldSearchStore.frame = CGRectMake(textFieldSearchStore.frame.origin.x, textFieldSearchStore.frame.origin.y, 248.0f, textFieldSearchStore.frame.size.height);
}
completion:^(BOOL finished){}
];
}