自定义形状的进度视图

发布于 2025-01-02 14:07:26 字数 160 浏览 2 评论 0原文

我正在寻找有关自定义进度视图的一些解决方案。

基本上,我想填充下面的图像来表示加载进度,就像我们在游戏中一样。

在此处输入图像描述

有什么想法如何实现它吗?

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??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小糖芽 2025-01-09 14:07:26

使用 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 一样填充的非透明图像 - 黑色表示可见部分,白色表示透明。

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.

想你的星星会说话 2025-01-09 14:07:26

创建自定义视图类并在该类中添加动画序列以无限地按顺序显示图像。

像这样将该视图添加到主窗口
(UIWindow*)[[UIApplication共享应用].windows objectAtIndex:0];

调用 BringSubviewToFront 在您想要此加载屏幕(视图)的任何视图上显示该视图。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文