#pragma mark - =========给cell添加边框 =========
//TODO:方法一
// UIBezierPath *maskPath;
// CGRect boardRect;
//
// float h = cell.bounds.size.height;
// float w = cell.bounds.size.width;
// if (indexPath.row == 0) {
// boardRect = CGRectMake(1, 0, w-1, h);
// maskPath = [[UIBezierPath bezierPathWithRoundedRect:cell.bounds byRoundingCorners:UIRectCornerTopLeft cornerRadii:CGSizeMake(10, 10)] bezierPathByReversingPath];
// }
// else if (indexPath.row == 6) {
// boardRect = CGRectMake(-1, 0, w+1, h);
// maskPath = [[UIBezierPath bezierPathWithRoundedRect:cell.bounds byRoundingCorners:UIRectCornerTopRight cornerRadii:CGSizeMake(10, 10)] bezierPathByReversingPath];
// } else if (indexPath.row == 35) {
// boardRect = CGRectMake(0, -1, w, h+1);
// maskPath = [[UIBezierPath bezierPathWithRoundedRect:cell.bounds byRoundingCorners:UIRectCornerBottomLeft cornerRadii:CGSizeMake(10, 10)] bezierPathByReversingPath];
// }
// else {
// boardRect = CGRectMake(-1, 0, w+2, h);
// maskPath = [UIBezierPath bezierPathWithRect:boardRect];
// }
//
// for (CALayer *layer in cell.contentView.layer.sublayers) {
// if ([layer.name isEqualToString:@"maskLayer"]) {
// [layer removeFromSuperlayer];
// }
// }
//
// CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
//
// maskLayer.name = @"maskLayer";
// maskLayer.frame = boardRect;
// maskLayer.path = maskPath.CGPath;
// maskLayer.strokeColor = [UIColor redColor].CGColor;
// maskLayer.lineDashPattern = @[@4, @2];
// maskLayer.lineWidth = 1.0f;
// maskLayer.fillColor = [UIColor clearColor].CGColor;
// maskLayer.masksToBounds = YES;
// [cell.contentView.layer insertSublayer:maskLayer atIndex:0];
//TODO:方法二
// CALayer *bottomBorder = [CALayer layer];
// float height=cell.frame.size.height-1.0f;
// float width=cell.frame.size.width;
// bottomBorder.frame = CGRectMake(0.0f, height, width, 1.0f);
// bottomBorder.backgroundColor = [UIColor lightGrayColor].CGColor;
// [cell.layer addSublayer:bottomBorder];
//
//
// CALayer *rightBorder = [CALayer layer];
// float rightHeight=cell.frame.size.height;
// float rightWidth=cell.frame.size.width-.0f;
// rightBorder.frame = CGRectMake(rightWidth, 0, 1.0f, rightHeight);
// rightBorder.backgroundColor = [UIColor lightGrayColor].CGColor;
// [cell.layer addSublayer:rightBorder];
// TODO:方法三 kUIColorFromRGB(0xeeeeee).CGColor 这个颜色可以省去上边CALayer
cell.layer.borderColor = kUIColorFromRGB(0xeeeeee).CGColor;
cell.layer.borderWidth = 0.5;
cell.layer.masksToBounds = YES;
[cell setBackgroundColor:[UIColor clearColor]];
增加边框 用颜色事半功倍(方法三)
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
相关阅读更多精彩内容
- 【蝴蝶效应】 蝴蝶效应:上个世纪70年代,美国一个名叫洛伦兹的气象学家在解释空气系统理论时说,亚马逊雨林一只蝴蝶...