随笔 - 399,  文章 - 0,  评论 - 7,  阅读 - 21万

 

1.同分区第一行cell 和最后一行cell 会切圆角,10, 改不了半径

UITableViewStyleInsetGrouped


        if (@available(iOS 13.0, *)) {
            _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStyleInsetGrouped];
        } else {
            _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStyleGrouped];
        }

 

 2.cell 指定切圆角

复制代码
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface UIView (PersonCategory)

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

@end

NS_ASSUME_NONNULL_END
复制代码

 

 

复制代码
#import "UIView+PersonCategory.h"

@implementation UIView (PersonCategory)
/// 部分圆角
- (void)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.dataArray.count > 0 &&  (indexPath.row == self.dataArray.count - 1)) {
        [cell addRoundedCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
                                 frame:cell.bounds
                          cornerRadius:10];
    }
}

 

参考:

「iOS」UITableView.Style.insetGrouped样式 及 代码实现圆角cell 方案

https://zhuanlan.zhihu.com/p/354622408

 

ios swift tableView insetGrouped 圆角 组间距

https://blog.csdn.net/baidu_40537062/article/details/129702088

 

iOS 多个分区的tableView设置每个分区第一行和最后一行圆角效果

https://www.jianshu.com/p/650831d6ce6d

 

iOS 设置tableView每个分区cell圆角

https://www.jianshu.com/p/abd7738e146b

posted on   懂事长qingzZ  阅读(778)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
历史上的今天:
2018-09-21 swift和OC - 拆分数组 和 拆分字符串

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示