菜鸟教程小白 发表于 2022-12-12 20:01:43

ios - 圆形 View 和颜色以及带有动画的 cifilter


                                            <p><p>我正在开发一个应用程序,我需要在用户单击 UIButton 时制作效果。 </p>

<p> <a href="http://imageshack.com/a/img802/3337/on55.png" rel="noreferrer noopener nofollow">http://imageshack.com/a/img802/3337/on55.png</a> </p>

<p>当用户单击屏幕截图中心的按钮时,图片上会出现一个带有颜色的光环,该光环正在通过网络请求加载。图片加载了颜色,实际上我在其上应用了一个去除颜色的 cifilter。 </p>

<p>如果可能,请向我解释如何使用背景图像重现圆形 View 。</p>

<p>谢谢。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>所以,我试图解释我的解决方案,我是法国人,我的英语很差:D</p>

<p>为了实现这一点,我使用自定义 drawrect 制作了一个 uiview,PaintCode 确实帮助我做到了这一点,因为我的设计师制作了一些 svg 示例文件,我将它加载到 PaintCode 中以制作 UIBezierPath。像这样。</p>

<pre><code>UIBezierPath* bezier2Path = ;
    ;
    ;
    ;
    ;
    ;
    ;
    ;
    ;
    ;
    ;
    ;
    ;
    bezier2Path.miterLimit = 4;
</code></pre>

<p>当 uiview 初始化时,我在使用 AFNetworking 从 Internet 下载我的图像时初始化她。我在drawrect中的 View 背景中设置图像,如下所示:</p>

<pre><code>//// General Declarations
CGContextRef context = UIGraphicsGetCurrentContext();


//// Image Declarations
UIImage* bGTest = ;

//// Calque_2_-_copie
{
    //// Bezier 2 Drawing
    UIBezierPath* bezier2Path = ;
    ;
    ;
    ;
    ;
    ;
    ;
    ;
    ;
    ;
    ;
    ;
    ;
    bezier2Path.miterLimit = 4;

    CGContextSaveGState(context);
    ;
    ;
    CGContextRestoreGState(context);
}
</code></pre>

<p>这真的很简单,之后我可以只使用 alpha 组件为我的 View 设置动画来制作我的波纹动画。</p>

<p>现在看截图:</p>

<p> <a href="http://imageshack.com/a/img839/4613/v2wm.png" rel="noreferrer noopener nofollow">http://imageshack.com/a/img839/4613/v2wm.png</a> </p>

<p>感谢您的回复。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 圆形 View 和颜色以及带有动画的 cifilter,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/22354324/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/22354324/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 圆形 View 和颜色以及带有动画的 cifilter