2013-01-22 3 views
1

이 코드를 사용하면 이미지 160x148의 실제 크기가 작동하지만 이미지 버튼이 모든 화면에서 매우 크게 볼 수 있습니다!uibutton의 애니메이션 GIF

UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:self.view.bounds]; 
animatedImageView.animationImages = [NSArray arrayWithObjects:  
           [UIImage imageNamed:@"button1.png"], 
           [UIImage imageNamed:@"button2.png"], 
           [UIImage imageNamed:@"button3.png"], 
           [UIImage imageNamed:@"button4.png"], nil]; 
animatedImageView.animationDuration = 1.0f; 
animatedImageView.animationRepeatCount = 0; 
[animatedImageView startAnimating]; 
[yourButton addSubview: animatedImageView]; 

수정 방법은 무엇입니까?

+0

initWithFrame :을 (를) 호출하여보기의 경계를 넘어서서 매우 좋습니다. 다른 크기의 rect로 변경하십시오. – Luke

+0

어떻게 그럴 수 있습니까? – user1996717

+0

적어도 self.view.bounds를 CGRectMake (0, 0, 160, 148)로 변경 한 다음 필요에 따라 위치를 변경합니다. – Luke

답변

2

initWithFrame:을 호출하여보기의 경계에 전달되어 이미지가 큽니다. 다음과 같은 다른 크기의 사각형으로 변경하십시오.

CGRectMake(0, 0, 160, 148) 

... 등으로 변경 한 다음 적절하게 위치를 변경하십시오.

0

이 코드를 사용해보십시오. 올바른 해결책을 찾는데 도움이됩니다.

UIImage *myimage=UIImage imageNamed:@"button1.png"; 
Button.imageview.image=myimage;