2010-12-21 8 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

이를 사용합니다. 로 :

당신의 XIB에서 같은 이미지의 플래시 효과를 원하는 경우에
[tempButton setImage:[UIImage imageNamed:@"NormalImage.png"] 
      forState:UIControlStateNormal]; 
[tempButton setImage:[UIImage imageNamed:@"HighlightImage.png"] 
      forState:UIControlStateHighlighted]; 

, 버튼이 클릭, , 고토 검사기 창> 컨트롤>을 강조 속성을 확인합니다. 있는 UIButton의 속성이 을 showsTouchWhenHighlighted라는 이름이

[tempButton setShowsTouchWhenHighlighted:YES]; 

//or 
tempButton.highlighted = YES;