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 2023-09-21 15:57  懂事长qingzZ  阅读(694)  评论(0编辑  收藏  举报