2012-10-16 3 views
1

사용자 정의 UITableViewCell이 있습니다. XIB 파일은 다음과 같다 :사용자 정의 셀/사용자 정의 배경 이미지가있는 그룹화 된 UITableView

enter image description here

세포는 선택하여 열고 닫을 수 있습니다. 셀이 닫히면 제목 레이블과 상단 배경 이미지 만 표시됩니다. 여기에서 열려, 테이블 뷰는 시뮬레이터에 모습입니다 및 폐쇄 : 나는 둥근 모서리 처리하는 방법을 알아 내려고 노력하고 있어요

enter image description here enter image description here

. 현재, 나는 셀이 먼저 마지막 또는 중간 세포 있는지 확인하고, 마스크를 적용하고 있습니다 :

if (row == 0) 
{ 
    // Create the path (with only the top corners rounded) 
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:cell.titleBackgroundImageView.bounds 
                byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight) 
                 cornerRadii:CGSizeMake(10.0, 10.0)]; 

    // Create the shape layer and set its path 
    CAShapeLayer *maskLayer = [CAShapeLayer layer]; 
    maskLayer.frame = cell.titleBackgroundImageView.bounds; 
    maskLayer.path = maskPath.CGPath; 

    // Set the newly created shape layer as the mask for the image view's layer 
    cell.titleBackgroundImageView.layer.mask = maskLayer; 
    cell.bodyBackgroundImageView.layer.mask = nil; 
} 
else if ((row + 1) == [itemsForSection count]) 
{ 
    // Create the path (with only the bottom corners rounded) 
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:cell.titleBackgroundImageView.bounds 
                byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight) 
                 cornerRadii:CGSizeMake(10.0, 10.0)]; 
    CAShapeLayer *maskLayer = [CAShapeLayer layer]; 

    // Create the shape layer and set its path 
    BOOL isOpened = [[[self.cellOpenedStatusMutableDictionary objectForKey:sectionTitle] objectAtIndex:row] boolValue]; 
    if (isOpened) 
    { 
     cell.titleBackgroundImageView.layer.mask = nil; 
    } 
    else 
    { 
     maskLayer.frame = cell.titleBackgroundImageView.bounds; 
     maskLayer.path = maskPath.CGPath;   
     cell.titleBackgroundImageView.layer.mask = maskLayer; 
    } 
     // Create the path (with only the bottom corners rounded) 
    maskPath = [UIBezierPath bezierPathWithRoundedRect:cell.bodyBackgroundImageView.bounds 
            byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight) 
              cornerRadii:CGSizeMake(10.0, 10.0)]; 

    // Create the shape layer and set its path 
    maskLayer = [CAShapeLayer layer]; 
    maskLayer.frame = cell.titleBackgroundImageView.bounds; 
    maskLayer.path = maskPath.CGPath; 

    cell.bodyBackgroundImageView.layer.mask = maskLayer; 
} 
else 
{ 
    cell.titleBackgroundImageView.layer.mask = nil; 
    cell.bodyBackgroundImageView.layer.mask = nil; 
} 

을하지만 당신이 볼 수 있듯이, 그것은 아래 셀에 대해 잘 작동을하지 않습니다 - 테이블 뷰의 테두리가 가려집니다.

이 문제를 어떻게 해결할 수 있습니까?

답변

1

테이블 뷰의 구분 스타일을 "단일 라인 에칭"대신 "단일 라인"(UITableViewCellSeparatorStyleSingleLine)으로 설정하는 것이 필요합니다.

관련 문제