自定义形状进度视图 [英] Custom Shaped progress View
本文介绍了自定义形状进度视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找有关自定义进度视图的解决方案。
I'm looking out for some solution regarding the custom progress view.
基本上,我想填充下面的图像来表示加载进度,就像
Basically, i would like to fill the image below to represent the loading progress,just like the one's we have in games.
任何想法如何实现?
推荐答案
使用CoreGraphics进行屏蔽:
Masking using CoreGraphics:
UIImage *img = [UIImage imageNamed:@"imagetomask.png"];
CGImageRef maskRef = [UIImage imageNamed:@"mask.png"].CGImage;
CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef),
CGImageGetHeight(maskRef),
CGImageGetBitsPerComponent(maskRef),
CGImageGetBitsPerPixel(maskRef),
CGImageGetBytesPerRow(maskRef),
CGImageGetDataProvider(maskRef), NULL, false);
CGImageRef maskedImage = CGImageCreateWithMask([img CGImage], mask);
[imageView setImage:maskedImage];
您的 mask.png
应该不是透明的图像像倒置的alpha一样填充-黑色代表可见部分,白色代表透明。
Your mask.png
should be non-transparent image filled like inverted alpha - black for visible parts, white for transparent.
这篇关于自定义形状进度视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文