首页 > 其他分享 >OC 设置cell 圆角

OC 设置cell 圆角

时间:2023-09-22 15:11:23浏览次数:38  
标签:indexPath 圆角 shmaas frame OC addRoundedCorners cell cornerRadius

 

 

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface UIView (PersonCategory)

- (void)shmaas_addRoundedCorners:(UIRectCorner)corners
                       frame:(CGRect)frame
                    cornerRadius:(CGFloat)cornerRadius;

@end

NS_ASSUME_NONNULL_END

 

 

#import "UIView+PersonCategory.h"

@implementation UIView (PersonCategory)
/// 部分圆角
- (void)shmaas_addRoundedCorners:(UIRectCorner)corners
                       frame:(CGRect)frame
                   cornerRadius:(CGFloat)cornerRadius {    
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:frame byRoundingCorners:corners cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];
    CAShapeLayer *maskLayer = [CAShapeLayer layer];
    maskLayer.frame = frame;
    maskLayer.path = maskPath.CGPath;
    self.layer.mask = maskLayer;
}
@end

 

 

/// 设置cell圆角
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    if (self.inputSearchText.length > 0) {
        
        if (indexPath.section == 0){
            if (self.viewModel.poi2SitesResModel == nil ||
                self.viewModel.poi2SitesResModel.pois.count == 0) {
                // 无poi匹配结果
                [cell shmaas_addRoundedCorners:UIRectCornerAllCorners
                                         frame:cell.bounds
                                  cornerRadius:10];
            } else {
                // 搜索结果
                if (indexPath.row == 0) {
                    [cell shmaas_addRoundedCorners:UIRectCornerTopLeft | UIRectCornerTopRight
                                             frame:cell.bounds
                                      cornerRadius:10];
                } else if (indexPath.row == self.viewModel.poi2SitesResModel.pois.count-1) {
                    [cell shmaas_addRoundedCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
                                             frame:cell.bounds
                                      cornerRadius:10];
                }
            }
            
        } else if (indexPath.section == 1) {
            
            if (indexPath.row == 0) {
                [cell shmaas_addRoundedCorners:UIRectCornerTopLeft | UIRectCornerTopRight
                                         frame:cell.bounds
                                  cornerRadius:10];
            } else{
                if (_stationData.recommands.count > 0) {
                    if (indexPath.row == _stationData.recommands.count) {
                        [cell shmaas_addRoundedCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
                                                 frame:cell.bounds
                                          cornerRadius:10];
                    }
                } else {
                    if (indexPath.row == _stationData.sites.count) {
                        [cell shmaas_addRoundedCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
                                                 frame:cell.bounds
                                          cornerRadius:10];
                    }
                }
            }
        }
        
    } else {
        if (indexPath.section == 0){
            if (indexPath.row == 0) {
                [cell shmaas_addRoundedCorners:UIRectCornerTopLeft | UIRectCornerTopRight
                                         frame:cell.bounds
                                  cornerRadius:10];
            } else if (indexPath.row == _stationData.histories.count-1) {
                [cell shmaas_addRoundedCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
                                         frame:cell.bounds
                                  cornerRadius:10];
            }
        } else if (indexPath.section == 1) {
            if (indexPath.row == 0) {
                [cell shmaas_addRoundedCorners:UIRectCornerTopLeft | UIRectCornerTopRight
                                         frame:cell.bounds
                                  cornerRadius:10];
            } else {
                if (_stationData.recommands.count > 0) {
                    if (indexPath.row == _stationData.recommands.count) {
                        [cell shmaas_addRoundedCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
                                                 frame:cell.bounds
                                          cornerRadius:10];
                    }
                } else {
                    if (indexPath.row == _stationData.sites.count) {
                        [cell shmaas_addRoundedCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
                                                 frame:cell.bounds
                                          cornerRadius:10];
                    }
                }
            }
        }
    }
}

 

标签:indexPath,圆角,shmaas,frame,OC,addRoundedCorners,cell,cornerRadius
From: https://www.cnblogs.com/qingzZ/p/17722415.html

相关文章

  • ABP + Vue Docker 部署
    #!/bin/bashecho"Welcometodockerbuild"echo""echo""ABP_HOST="abp/host"ABP_NG="abp/ng"cd..echo"Buildingdockerimage$ABP_HOST..."#cd到aspnet-core目录,eg:cd/data/apb/#将aspnet-......
  • Docker
    Ubuntu22.04全程root用户安装aptupdateaptinstall-yapt-transport-httpsca-certificatescurlgnupg-agentsoftware-properties-commoncurl-fsSLhttps://download.docker.com/linux/ubuntu/gpg|sudoapt-keyadd-add-apt-repository"deb[arch=amd64]https:......
  • Docker - Docker Desktopo
    ThereisareasonfortheneedforWindowsandMacuserstodownloadandworkwith DockerDesktopinsteadofworkingwithDockerbinarydirectly.Containerizationis moreofaLinuxtechnology,soitisnotavailableoutoftheboxforwindowsand macuse......
  • [885] How to generate automated tables in Word document with Python
    ref:HowtoGenerateAutomatedWordDocumentswithPythonref:docxtpl快速上手使用,数据填入以及循环写入表格CreatingaTemplateBeforeyoucanproceed,youmustfirstcreateyourveryowntemplatedocumentthatisbasicallyanormalMicrosoftWordDocument......
  • P7200 [COCI2019-2020#1] Lutrija
    发现相邻的奇数只能恰好差\(2\)(偶质数只有\(2\))。而大于\(3\)的三个连续奇数至多有两个是质数,因为有一个能被\(3\)整除。对于357这三个数,我们可以构造成3527以归入下面的构造方法。所以相邻的奇数最多只有两个。但我们可以放偶质数\(2\)。显然,放多个\(2\)肯......
  • [884] How to generate automated Word documents by Python
    ref:python-docxref:HowtoGenerateAutomatedWordDocumentswithPythonref:AutomatingWordDocumentsfromExcelUsingPython|‘docxtpl’Tutorialref:docxtpl快速上手使用,数据填入以及循环写入表格ref:探究Python中的文档自动化工具——docxtplref:Python......
  • docker 部署mysql8.3.0
    以下内容全部来源于https://blog.csdn.net/Weirdo_zhu/article/details/126358872?spm=1001.2014.3001.5501一、拉取镜像dockerpullmysql:8.0.30二、创建挂载路径 //根目录选择自身实际最大磁盘路径一般为/home或者定义/datamkdir-p/data/mysql/datamkdir-p/data/m......
  • jenkins+测试平台+jacoco实现代码覆盖
    Jenkins配置 构架后执行shellif[${jacoco}=='true'];then cd/home/apps/xxxxx/xxxx sh./test_run.shelse echo"不生成jacoco报告"fi jenkins添加html插件 jacoco报告 shell脚本内容#!/bin/sh#定义要检查的主机和端口host="localhost"port=18098s......
  • Nextcloud使用OCC命令重置密码
    Nextcloud使用OCC命令重置密码  一般来说,可以使用管理员账户来修改密码如果出现了忘记了管理员密码这种糟糕的情况,就只能通过OCC命令或修改数据库的方式来解决了。本文介绍较为方便的使用OCC命令重置密码方式。OCC命令的用法occ命令是ownCloud/Nextcloud的命令行界面......
  • docker-compose 部署 jenkins Blue Ocean插件
    DockerfileFROMjenkins/jenkins:2.414.2-lts-jdk17USERrootRUNapt-getupdate&&apt-getinstall-ylsb-releaseRUNcurl-fsSLo/usr/share/keyrings/docker-archive-keyring.asc\https://download.docker.com/linux/debian/gpgRUNecho"deb[a......