Custom Shaped progress View

最后都变了- 提交于 2019-12-13 07:04:31

问题


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.

Any ideas how to achieve it??


回答1:


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];

Your mask.png should be non-transparent image filled like inverted alpha - black for visible parts, white for transparent.




回答2:


Create custom view class and add animation sequence in that class to show your images in sequence infinitly.

Add that view to mainwindow like this (UIWindow*)[[UIApplication sharedApplication].windows objectAtIndex:0];

call bringSubviewToFront to show that view on any view where u want this loading screen(view).



来源:https://stackoverflow.com/questions/9140030/custom-shaped-progress-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!