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];
這是怎麼解決的?
那麼它的大,因爲你稱爲initWithFrame:並傳入你的視圖的邊界。將其更改爲不同大小的矩形。 – Luke
如何做到這一點? – user1996717
至少將self.view.bounds更改爲CGRectMake(0,0,160,148),然後將其重新定位到您需要的位置。 – Luke