菜鸟教程小白 发表于 2022-12-12 09:07:59

ios - 在 iOS 中的 UIView 上绘图


                                            <p><p>我正在开发 iPhone 应用程序,我已经使用 UIView,我想在用户 touchMove 事件的 View 上绘制特定区域。所以请任何人向我建议如何做这意味着如何实现 touchMove 事件,以便它可以与用户 touchMove 同时绘制区域。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>你需要做的是:</p>

<ol>
<li>创建 <code>UIView</code> 的子类。 </li>
<li>实现所有的触摸方法,如
<code>touchesBegan:</code>、<code>touchesMoved:</code> 等。</li>
<li>使用<code>drawRect:</code>,
<code>UIGraphicsBeginImageContextWithOptions</code> 和 <code>UIBezierPath</code> 绘制
基于触摸位置的图像。</li>
</ol>

<p>互联网上有很多教程。我觉得这个很好:<a href="http://code.tutsplus.com/tutorials/ios-sdk-advanced-freehand-drawing-techniques--mobile-15602" rel="noreferrer noopener nofollow">Advanced Freehand Drawing Techniques</a> </p>

<p> <img src="/image/fO7JM.png" alt="enter image description here"/> </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 在 iOS 中的 UIView 上绘图,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/22868643/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/22868643/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 在 iOS 中的 UIView 上绘图