菜鸟教程小白 发表于 2022-12-13 10:05:52

ios - 圆角仅适用于 UITableView 的底部边缘


                                            <p><p>我正在使用下面的代码为 tableView 的底部边缘制作圆角</p>

<pre><code>CALayer *capa = self.patientTableView.layer;

//Round
CGRect bounds = capa.bounds;

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:bounds
                                             byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight)
                                                   cornerRadii:CGSizeMake(10.0, 10.0)];

CAShapeLayer *maskLayer = ;
maskLayer.frame = bounds;
maskLayer.path = maskPath.CGPath;

;
capa.mask = maskLayer;
</code></pre>

<p>此代码工作正常,但 tableview 没有显示低于其框架高度的内容(但它滚动到它的 offset.y)。 </p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您可以通过将表格 View 放在 <code>UIView</code> 中来解决此问题,然后将掩码应用于该容器 View 。这样掩码就不会随着表格 View 的 <code>contentOffset</code> 移动。</p>

<p> <a href="/image/E1V6X.png" rel="noreferrer noopener nofollow"><img src="/image/E1V6X.png" alt="view hierarchy"/></a> </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 圆角仅适用于 UITableView 的底部边缘,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/32205579/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/32205579/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 圆角仅适用于 UITableView 的底部边缘