[英]animate and resize UIImageView
如何動畫和調整UIImageView的大小? 我試過這樣做,但對我來說沒有用:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
imgView.frame = CGRectMake(0, 0, 320, 480);
[UIView commitAnimations];
嘗試使用塊動畫:
[UIView animateWithDuration:1.0f // This can be changed.
animations:^{
CGRect frame = imageView.frame;
frame.size.width += 100.0f; // This is just for the width, but you can change the origin and the height as well.
imageView.frame = frame;
}
completion:^(BOOL finished){
}];
希望有幫助!
試試這個代碼。 這對我很好,
CGPoint newLogoutCenter = CGPointMake(160, 364);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0f];
twitterBarVIew.center = newLogoutCenter;
[UIView commitAnimations];
如果我們假設您對imgView有正確的引用,那么似乎imgView的起始幀在動畫之前和之后是相同的。
嘗試將imgView.frame設置為:
imgView.frame = CGRectMake(100,100,100,100);
//設置UIImageView。 框架確定圖像的位置和大小。 UIImageView * i = [[UIImageView alloc] initWithFrame:[CGRectMake(50.0,50.0,50.0,50.0)]];
//將圖像添加到UIImageView i.images = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@“1.png”],
[UIImage imageNamed:@“2.png”],nil];
//設置動畫運行的時間i.animationDuration = 1.0f;
//啟動動畫[i startAnimating];
您可以通過更改圖像的幀來調整圖像大小
i.frame = CGRectMake(x,y,width,height);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.