我有一個UIImageView
命名bigBottle
:從全面的UIImage填充的UIImageView%的動畫
bigBottle.image = [UIImage imageNamed:@"fullBootle.png"];
fullBootle.png
填充到100%的瓶子。
我需要兩個步驟:
- 首先要以百分比圖像的作物(突然想到說50%的填充) - 也就是說,一瓶裝滿了一半,從底部)。
Animate
bigBottle
從瓶子的下方向50%填充物發出填充效果。 我的代碼是波紋管:CGRect captureRect = CGRectMake(0,22,18,72); UIImage *captureImg; UIGraphicsBeginImageContext(captureRect.size); CGContextRef context = UIGraphicsGetCurrentContext(); [self.bigBottle.layer renderInContext:context]; captureImg = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); self.bigBottle.image = [UIImage imageWithCGImage:CGImageCreateWithImageInRect(captureImg.CGImage, captureRect)]; CGRect captureRect1 = CGRectMake(0,37,18,72); self.bigBottle.frame=CGRectMake(45, 174,18,1); CGRect newFrameOfMyView1 = CGRectMake(45,129, 18, 45); [UIView animateWithDuration:3.0f animations:^{ self.bigBottle.frame = newFrameOfMyView1; } completion:^(BOOL finished){ NSLog(@"done bottle: 1"); }];
這是另一種方式,使灌裝瓶更簡單的這部動畫,和更多的內存效率?我有幾十瓶隨機填充百分比(讓我們說瓶子80填滿了20%)並且沒有模糊的結果圖像?
Thenk你。我還沒有足夠的積分投票,但我很快就會做。 – user3344236
那麼,你的例子填充矩形,我用animation.fillMode = kCAFillModeForwards;保持結果可見。請看看這個屏幕截圖。這確實是我需要的那種動畫的最後階段。因此,瓶子從底部到頂部填充,從1高度開始,填充滿足瓶子的整個輪廓。 http://tinypic.com/view.php?pic=2h7lzs4&s=8 – user3344236