• IOS-tableView 设置圆角


       
    // 设置 tableView整体的圆角设置
        
    //    /// 设置圆角
    //    v_tableview.layer.cornerRadius = 7;
    //    v_tableview.layer.masksToBounds = YES;
    //    /// 设置边框
    //    v_tableview.layer.borderWidth = 1;
    //    v_tableview.layer.borderColor = [COLOR(189, 189, 189, 1) CGColor];
        
       

    //IOS7  分组后每组圆角的设置

    //#pragma mark - Table view data source
    //- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    //    
    //    if ([cell respondsToSelector:@selector(tintColor)]) {
    //        if (tableView == v_tableview) {
    //            
    //            CGFloat cornerRadius = 10.f;
    //            cell.backgroundColor = UIColor.clearColor;
    //            CAShapeLayer *layer = [[CAShapeLayer alloc] init];
    //            CGMutablePathRef pathRef = CGPathCreateMutable();
    //            CGRect bounds = CGRectInset(cell.bounds, 0, 0);
    //            
    //            BOOL addLine = NO;
    //              //绘制圆角
    //            if (indexPath.row == 0 && indexPath.row == [tableView numberOfRowsInSection: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 = [UIColor colorWithWhite:1.f alpha:0.8f].CGColor;
    //            
    //            
    //            
    //            if (addLine == YES) {
    //                
    //                CALayer *lineLayer = [[CALayer alloc] init];
    //                
    //                CGFloat lineHeight = (1.f / [UIScreen mainScreen].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 = [[UIView alloc] initWithFrame:bounds];
    //            [testView.layer insertSublayer:layer atIndex:0];
    //            testView.backgroundColor = UIColor.clearColor;
    //            cell.backgroundView = testView;
    //            
    //        }
    //        
    //    }
    //    
    //}

    //tableView 选中的颜色设置

    1. //无色  
    2. cell.selectionStyle = UITableViewCellSelectionStyleNone;  
    3.   
    4. //蓝色  
    5. cell.selectionStyle = UITableViewCellSelectionStyleBlue;  
    6.   
    7. //灰色  
    8. cell.selectionStyle = UITableViewCellSelectionStyleGray; 


       

    //tableView 选中后颜色即可消失

    [self.tableview deselectRowAtIndexPath:[self.tableview indexPathForSelectedRow] animated:YES];

  • 相关阅读:
    Locust学习笔记3——模拟登录案例(非加密)
    Locust学习笔记2——环境搭建与基本用法
    Locust学习笔记1——性能测试工具选择
    Pytest学习笔记7——接口自动化测试框架实战附源码(开荒篇)
    Pytest学习笔记6——自定义用例顺序
    Pytest学习笔记5——Allure测试报告用例详细描述
    Pytest学习笔记4——测试步骤
    Python 批量插入100万级数据到Excel文件(简洁版)
    [Java] SpringBoot
    [bug] Springboot JPA使用Sort排序时的问题
  • 原文地址:https://www.cnblogs.com/jhonyzhang/p/3700901.html
Copyright © 2020-2023  润新知