2012-06-12 4 views
5

나는 내 tableview의 오른쪽 상단 및 왼쪽 모서리 만 둥글게하려고합니다. 아래 코드를 사용하고 있는데, 왼쪽 상단 모서리를 반올림하는 것 같습니다.UITableView에서 모서리를 둥글게 만드는 방법은 무엇입니까?

CAShapeLayer *topLayer = [CAShapeLayer layer]; 
UIBezierPath *roundedPath = 
[UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerTopLeft cornerRadii:CGSizeMake(9.f, 9.0f)];  
topLayer.path = [roundedPath CGPath]; 
+0

HTTP를 UIBezierPath maskPath

CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame =self.testView.bounds; maskLayer.path = PathToMask.CGPath; 

을 설정하여 모양 레이어 마스크 만들기를 만들기 위해 상단의 경로를 찾기 : // 유래 .com/a/5826698/855738 나는이 답변을 거의 똑같은 일을하기 위해 사용했다. – BBog

+1

옛날 글을 알고 있지만 youve가 있는지 확인한다. [tableView.layer setMasksToBound : YES] 괜찮 으면 좋겠어요 –

+0

[여기] [1] 수락 된 답변을 참조하십시오. 같은 문제 일 수 있습니다. [1] : http://stackoverflow.com/questions/26934231/uiview-in-cell-cant-round-right-hand-corners –

답변

2

희망이 작동합니다. 마스크 층

UIBezierPath *PathToMask; 
PathToMask = [UIBezierPath bezierPathWithRoundedRect:self.testView.bounds 
           byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight) 
             cornerRadii:CGSizeMake(8.0, 8.0)]; 

마스크 층 maskLayer

self.testView.layer.mask = maskLayer; 
관련 문제