2
UITextField
が編集モードになっているときに、非表示と非表示になるUIButton
があります。問題は、(隠されたものから隠されていないものまで)完全に細かく変化するが、アニメーション化されないことである。私が代わりにsetAlpha:
試してみたが、ここで、これまでに私のコードではありません100 0に、0から100までのアルファを設定しているときにのみ動作します。アニメーションのUIButtonが非表示になり、非表示になる
-(BOOL) textFieldShouldBeginEditing:(UITextField *)textField
{
negButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
negButton.frame = CGRectMake(textField.frame.origin.x, textField.frame.origin.y, 37, textField.frame.size.height);
[negButton setHidden:YES];
return YES;
}
-(void) textFieldDidBeginEditing:(UITextField *)textField
{
if ([textField isEditing])
{
[UIView animateWithDuration:0.3 animations:^
{
CGRect frame = textField.frame;
frame.size.width -= 40;
frame.origin.x += 40;
[negButton setHidden:NO];
[textField setFrame:frame];
[self.view addSubview:negButton];
}];
}
}
-(void) textFieldDidEndEditing:(UITextField *)textField
{
[UIView animateWithDuration:0.3 animations:^
{
CGRect frame = textField.frame;
frame.size.width += 40;
frame.origin.x -= 40;
[negButton setHidden:YES];
[negButton removeFromSuperview];
[textField setFrame:frame];
}
];
}
編集:私はこの問題を解決しました。私はちょうどremoveFromSuperview
関数を呼び出す必要はなかった、私はアルファからアルファに切り替える必要があった。 (下記の@ Davidの答えをご覧ください)
こんにちはデビッド、助けてくれてありがとう、私はこの方法を試して、ボタンが表示されません。 –
ヒッデンズをすべてアルファに変更しましたか? – David
はい。私の編集は上に掲載されている、私は解決策を見つけた。 –