IOS-tableView 設定圓角

來源:互聯網
上載者:User

標籤:style   tar   width   color   get   int   art   set   cti   rgb   line   

 

 

   
// 設定 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; 
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.