2012-10-25 5 views
2

Apple에서 iOS6의 코너 반경을 약 7 (이전의 10)으로 변경 한 것으로 보입니다.그룹화 된 TableView에서 UITableViewCell의 액세스 코너 반경

내 UITableView 뒤에서 UITableViewCell과 동일한 코너 반경을 가져야하는보기가 있습니다. 내 응용 프로그램도 이전 iOS 버전을 지원하므로 현재 뷰의 코너 반경을 현재 UITableview에 적용해야합니다. 셀의 코너 반경에 액세스하는 방법이 있습니까?

답변

0

@bllubbor - 당신은

@interface BackgroundView : UIView 
    @end 

    @implementation BackgroundView 

    + (Class)layerClass 
    { 
     return [CAShapeLayer class]; 
    } 
    @end 

나중에 cellForRowAtIndexPath에서이 같은 일을 할 .. 나를 위해 작동하기 때문에 그것은 당신의 대답을 해결 희망,이 방법으로 갈 수 : -

static NSString *CellIdentifier = @"CustomCell"; 
    CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

    CGRect frame = cell.backgroundView.frame; 
    cell.backgroundView = [[BackgroundView alloc] initWithFrame:frame]; 

    CGFloat corner = 20.0f; 
    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:cell.backgroundView.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(corner, corner)]; 
    CAShapeLayer *shapeLayer = (CAShapeLayer *)cell.backgroundView.layer; 
    shapeLayer.path = path.CGPath; 
    shapeLayer.fillColor = cell.textLabel.backgroundColor.CGColor; 
    shapeLayer.strokeColor = [UIColor lightGrayColor].CGColor; 
    shapeLayer.lineWidth = 1.0f; 

    return cell;