1

我使用这个代码,这个工作,真正的图像大小为 160x148,但图像按钮在所有屏幕上都非常大!

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];

如何解决?

4

2 回答 2

2

图像很大,因为您调用initWithFrame:并通过了视图的边界。将其更改为不同大小的矩形,例如:

CGRectMake(0, 0, 160, 148)

...然后按照您认为合适的方式重新定位它。

于 2013-01-22T19:18:06.023 回答
0

试试这个代码。它将帮助您找到正确的解决方案。

 UIImage *myimage=UIImage imageNamed:@"button1.png";
Button.imageview.image=myimage;
于 2013-01-24T06:49:55.223 回答