我的建議:
繪製第二圖像編程應用作爲對你的「旋風」形象口罩,然後重複這個循環。
例如,填補圖像由左(右面膜吧)
{
//existing variables
IBOutlet UIImageView *swooshView;
}
-(UIImage *)maskImageOfSize:(CGSize)size filledTo:(CGFloat)percentage{
UIGraphicsBeginImageContextWithOptions (size, NO, 0.0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColourWithColour (context, [UIColor blackColor].CGColor);
CGRect fillRect = CGRectZero;
fillRect.size.height = size.height;
fillRect.size.width = size.width * percentage/100.0;
fillRect.origin.x = (size.width - fillRect.size.width);
CGContextFillRect(context, fillRect);
UIImage *result = UIGraphicsGetImageFromImageContext();
UIGraphicsEndImageContext();
return result;
}
-(void)fillSwooshToPercentage:(CGFloat)percentage{
percentage = ((CGFloat) fmaxf (0.0 , (fminf (100.0, (float) percentage)));
// just policing a 'floor' and 'ceiling'...
swooshView.layer.mask = [self maskImageOfSize:self.swoosh.bounds.size filledTo:percentage];
}
來源
2014-11-01 23:37:19
Jef
創建自己的控件,繪製旋風,並根據需要填寫入。 – rmaddy 2014-11-01 23:28:04