Custom Shaped progress View

2019-09-03 09:06发布

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.

enter image description here

Any ideas how to achieve it??

2条回答
一夜七次
2楼-- · 2019-09-03 09:20

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).

查看更多
forever°为你锁心
3楼-- · 2019-09-03 09:37

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.

查看更多
登录 后发表回答