0

メイン ビューで、不透明度 0 から完全な不透明度にプログラムでアニメーション化するボタンを追加する必要があります。これのコーディングは何ですか?私はこのコーディングを与えられましたが、それを機能させることができないようです。

[UIElement setAlpha: 0.0f]; 

[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:0.5];

[UIElement setAlpha: 1.0f]; 

[UIView commitAnimations]; 
4

1 に答える 1

1

このコードをviewDidLoadメソッドに配置します。

UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn.frame = CGRectMake(0,0,100,50);
btn.alpha = 0;
[self.view addSubview:btn];

[UIView animateWithDuration: 0.3
                 animations: ^(void) { btn.alpha = 1; } ];
于 2012-11-09T16:22:03.893 に答える