首页 > 其他分享 >tableViewCell 自定义圆角

tableViewCell 自定义圆角

时间:2023-04-21 14:00:29浏览次数:24  
标签:indexPath tableViewCell 自定义 圆角 bounds cell backView maskLayer UIView

 

在一个多cell的Tab了View 中设置第一个和最后一个cell的圆角

其实还是贝塞尔去画 给cell 加一个view 

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {

    if (indexPath.row == 0 && indexPath.section == 0) {

        UIView *backView = [[UIView alloc] initWithFrame:cell.bounds];

        backView.backgroundColor = [UIColor whiteColor];

        backView.layer.cornerRadius = 15;

        cell.backgroundView = backView;

    } else if ((indexPath.section == 1 && indexPath.row == 0) || (indexPath.section == 2 && indexPath.row == 0)) {

        UIView *backView = [[UIView alloc] initWithFrame:cell.bounds];

        backView.backgroundColor = [UIColor whiteColor];

        UIRectCorner corner = UIRectCornerTopLeft | UIRectCornerTopRight;

        UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:backView.bounds byRoundingCorners:corner cornerRadii:CGSizeMake(15, 15)];

        CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];

        maskLayer.frame = backView.bounds;

        maskLayer.path = path.CGPath;

        backView.layer.masksToBounds = YES;

        backView.layer.mask = maskLayer;

        cell.backgroundView = backView;

    } else if ((indexPath.section == 1 && indexPath.row == 2) || (indexPath.section == 2 && indexPath.row == 4)) {

        UIView *backView = [[UIView alloc] initWithFrame:cell.bounds];

        backView.backgroundColor = [UIColor whiteColor];

        UIRectCorner corner = UIRectCornerBottomLeft | UIRectCornerBottomRight;

        UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:backView.bounds byRoundingCorners:corner cornerRadii:CGSizeMake(15, 15)];

        CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];

        maskLayer.frame = backView.bounds;

        maskLayer.path = path.CGPath;

        backView.layer.masksToBounds = YES;

        backView.layer.mask = maskLayer;

        cell.backgroundView = backView;

    }

 

}

 

标签:indexPath,tableViewCell,自定义,圆角,bounds,cell,backView,maskLayer,UIView
From: https://www.cnblogs.com/xiaodeng90/p/17340123.html

相关文章

  • Spring 自定义属性编辑器
    装Spring自定义属性编辑器 SpringDI注入的时候可以把普通属性注入进来,但是像Date类型的就无法被识别。这时可以通过Spring的属性编辑器把配置文件中的字符串转化成相应的对象进行注入。Spring有自带的属性编辑器,我们也可以写自定义的属性编辑器 自定义属性编辑器:继承java.bean......
  • Android-自定义控件
    原文地址zhuanlan.zhihu.com残枫cps​目录收起framelayout触发覆盖页面的点击事件SurfaceView自定义控件1.构造函数2.测量View大小(onMeasure)注意:3.确定View大小(onSizeChanged)4.确定子View布局位置(onLayout)5.绘制内容(onDraw)Android自定义控件之自定义组合控件前言:使......
  • 微信小程序开发笔记 基础篇③——自定义数据dataset,事件触发携带额外信息
    文章目录一、前言二、视频演示三、原理和流程四、注意事项五、全部源码六、参考一、前言微信小程序开发笔记——导读想要实现一个电费充值界面。多个不同金额的充值按钮,每个按钮都携带自定义数据(金额)点击不同金额的充值按钮,就会上传对应的数据(金额)。所以,本文主要使用到了微信小程......
  • CentOS7使用systemctl添加自定义服务
    一、简介Centos7开机第一个程序从init完全换成了systemd这种启动方式,同centos56已经是实质差别。systemd是靠管理unit的方式来控制开机服务,开机级别等功能。在/usr/lib/systemd/system目录下包含了各种unit文件,有service后缀的服务unit,有target后缀的开机级别unit等,这里介绍关......
  • 直播软件源码,自定义RecyclerView支持快速滚动
    直播软件源码,自定义RecyclerView支持快速滚动问题描述: RecyclerView自带快速滚动无法控制滚动条的长度唯一,也就是说随着item的增多,滚动条的长度会越变越小。 解决问题: 通过自定义RecyclerView来实现滚动条的长度不会因为item的增多而发生长度变化。 packagecom.emsm......
  • JSP自定义标签开发入门
    评:简单深入赞一般情况下开发jsp自定义标签需要引用以下两个包 importjavax.servlet.jsp.*;importjavax.servlet.jsp.tagext.*; 首先我们需要大致了解开发自定义标签所涉及到的接口与类的层次结构(其中SimpleTag接口与SimpleTagSupport类是JSP2.0中新引入的)。 目标1:自......
  • 收藏 JSP自定义标签EL表达式取值问题
    给你个标签的例子自己看看吧!标签:<framework:VoucherCodeToNamecode=""/>tld.xml<tag><name>VoucherCodeToName</name><tagclass>com.itown.crm.fee.vouchermanager.util.VoucherCodeToNameTag</tagclass>&......
  • 记录一次使用 表达式引擎 自定义注解 还有 sql union all 实现对数据库数据提取、重组
    这样编写减少了前后端很多没必要的遍历,以及if判断并最大限度提高了代码的可变通性额外需要学习的是ORM框架下,如何接收多表(各表结构不同)操作后,sql返回的新结构的临时表问题表达式引擎用到的依赖<dependency><groupId>org.apache.commons</groupId>......
  • Vue3 自定义hook
    视频9.自定义hook函数什么是hook?——本质是一个函数,把setup函数中使用的CompositionAPI进行了封装。类似于vue2.x中的mixin。自定义hook的优势:复用代码,让setup中的逻辑更清楚易懂。componentsDemo.vue<template> <h2>当前求和为:{{sum}}</h2> <button@clic......
  • 自定义注解+AOP实现参数校验
          转: https://www.cnblogs.com/mcj123/p/16842043.htmlhttps://www.cnblogs.com/fps2tao/p/13921207.html https://www.cnblogs.com/fps2tao/p/13921106.htmlhttps://www.cnblogs.com/fps2tao/p/13306246.html ......