2010-12-21 15 views
-1

私はiPhoneの新しい開発者です。UIButtonアニメーションビュー

uibuttonを作成したいと思います。

ボタンをクリックすると、ボタンが次のように点滅します。私は私のボタンをクリックすると、フラッシュを作成する方法

alt text

答えて

2

:として あなたはコードでこれを試すことができます。プロパティをYESに設定すると、ボタンをタッチすると光りが表示されます。デフォルト値はNOです。

[yourButton setShowsTouchWhenHighlighted:YES];

0

ハイライトされた画像を設定します。たとえば、ユーザがそれをタップすると

[someButton setImage:[UIImage imageNamed:@"MyHighlight.png"] 
      forState:UIControlStateHighlighted]; 

はその後、あなたのMyHighlight.pngが表示されます。

0
toolbar = [UIToolbar new]; 
toolbar.barStyle = UIBarStyleDefault; 
[toolbar sizeToFit]; 
toolbar.frame = CGRectMake(0, 410, 320, 50); 

//Add buttons 
UIBarButtonItem *systemItem1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd 
        target:self 
        action:@selector(pressButton1:)]; 

UIBarButtonItem *systemItem2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction 
        target:self 
        action:@selector(pressButton2:)]; 

UIBarButtonItem *systemItem3 = [[UIBarButtonItem alloc] 
     initWithBarButtonSystemItem:UIBarButtonSystemItemCamera 
     target:self action:@selector(pressButton3:)]; 

//Use this to put space in between your toolbox buttons 
UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace 
        target:nil 
        action:nil]; 

//Add buttons to the array 
NSArray *items = [NSArray arrayWithObjects: systemItem1, flexItem, systemItem2, flexItem, systemItem3, nil]; 

//release buttons 
[systemItem1 release]; 
[systemItem2 release]; 
[systemItem3 release]; 
[flexItem release]; 

//add array of buttons to toolbar 
[toolbar setItems:items animated:NO]; 

[self.view addSubview:toolbar]; 

これを使用してツールバーを作成します。

、あなたがボタン画像を変更したい場合は、ボタンをクリックしたときに、今の両方のデフォルトのために異なる画像を設定し、統計を強調し、検索ボタン

UIBarButtonSystemItemSearch 
0

のためにこれを使用しています。よう:

[tempButton setImage:[UIImage imageNamed:@"NormalImage.png"] 
      forState:UIControlStateNormal]; 
[tempButton setImage:[UIImage imageNamed:@"HighlightImage.png"] 
      forState:UIControlStateHighlighted]; 

あなたは同じボタンがクリックされた画像、あなたのXIBで 、後藤インスペクタウインドウ>制御のためのフラッシュ効果をしたい場合>強調表示されたプロパティを確認してください。 UIButtonのプロパティがをshowsTouchWhenHighlightedという名前があり

[tempButton setShowsTouchWhenHighlighted:YES]; 

//or 
tempButton.highlighted = YES;