对cell的最上边和最下边左圆角处理
来源:互联网 发布:ipadpro手写笔软件 编辑:程序博客网 时间:2024/04/27 21:22
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(tintColor)]) {
if (tableView == self.tableView) {
CGFloat cornerRadius = 15.f;
cell.backgroundColor = UIColor.clearColor;
CAShapeLayer *layer = [[CAShapeLayeralloc] init];
CGMutablePathRef pathRef = CGPathCreateMutable();
CGRect bounds = CGRectInset(cell.bounds, 10, 0);
BOOL addLine = NO;
if (indexPath.row ==0 && indexPath.row == [tableViewnumberOfRowsInSection:indexPath.section]-1) {
CGPathAddRoundedRect(pathRef, nil, bounds, cornerRadius, cornerRadius);
} else if (indexPath.row == 0) {
CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds));
CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds), CGRectGetMidX(bounds),CGRectGetMinY(bounds), cornerRadius);
CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds), CGRectGetMaxX(bounds),CGRectGetMidY(bounds), cornerRadius);
CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds));
addLine = YES;
} else if (indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1) {
CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds));
CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds), CGRectGetMidX(bounds),CGRectGetMaxY(bounds), cornerRadius);
CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds), CGRectGetMaxX(bounds),CGRectGetMidY(bounds), cornerRadius);
CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds));
} else {
CGPathAddRect(pathRef, nil, bounds);
addLine = YES;
}
layer.path = pathRef;
CFRelease(pathRef);
layer.fillColor = [UIColorcolorWithWhite:1.falpha:0.8f].CGColor;
if (addLine == YES) {
CALayer *lineLayer = [[CALayeralloc] init];
CGFloat lineHeight = (1.f / [UIScreenmainScreen].scale);
lineLayer.frame = CGRectMake(CGRectGetMinX(bounds)+10, bounds.size.height-lineHeight, bounds.size.width-10, lineHeight);
lineLayer.backgroundColor = tableView.separatorColor.CGColor;
[layer addSublayer:lineLayer];
}
UIView *testView = [[UIViewalloc] initWithFrame:bounds];
[testView.layer insertSublayer:layer atIndex:0];
testView.backgroundColor = UIColor.clearColor;
cell.backgroundView = testView;
}
}
}
- 对cell的最上边和最下边左圆角处理
- 猫猫学iOS之tableview隐藏最下边多余的cell
- iOS之tableview隐藏最下边多余的cell
- Cell上边或者下边出现不规则长度的黑色细线
- 去掉listview的上边和下边有黑色的阴影
- listview的上边和下边有黑色的阴影
- android 上边标题下边图片的button
- Iphone 把UIView 放在所以view的最上边
- 关于tabBar 隐藏最上边那条烦人的线
- asp 表格定位 去掉上边距和下边距
- div左边固定、右边自适应 和 上边固定、下边自适应
- 上边的UITableViewCell覆盖下边的UITableViewCell的问题
- 自定义图片在上边,文字在下边的按钮
- java 滚动条显示在最下边
- 线段树空间容纳且最上边的数(单点更新)
- android listview去掉分割线 和 颜色值 以及上边和下边黑色阴影
- android listview去掉分割线 和 颜色值 以及上边和下边黑色阴影
- 上边一个颜色下边一个颜色
- UI学习 第五章 UIScrollView UIPageControl
- 编程珠玑第一章之产生数据1000000-9999999(二)C/C++高效实现
- VC使用CRT调试功能来检测内存泄漏
- nginx转发配置shipyard遇到的问题
- codeforce #328D Super M (LCA)
- 对cell的最上边和最下边左圆角处理
- 递归方式求数组中最大元素
- C++11常用特性学习-易学易用新特性(>>/auto/decltype/范围的for)
- HDU2041超级楼梯
- UI学习 第六章 UITableView
- bochs使用手册
- 关于生成utf-8格式的文件
- Android沉浸式通知栏
- 华为oj DNA序列