我有一個文本字段,我想要改變它的寬度和圖像。圖像變化沒有任何問題,但寬度保持不變。這個問題在某種程度上取決於觸摸文本字段時觸發的動作,因爲當我創建一個簡單的按鈕時,動畫就起作用。所以我的問題是如何在觸摸文本字段時使動畫工作。按動UITextField時的動畫大小
動畫並不在這裏工作:
- (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){}
];
}
下面的答案是否有幫助? – clearwater82
恐怕不是。動畫無處不在,但在textFieldDidBeginEditing。 –