2012-10-19 5 views
1

나는를 가지고 있습니다. 인 UITableViewCell 안에 UIImageView이 있습니다. 둥근 테이블 셀의 (0,0) 위치에 이미지를 배치했습니다. 응용 프로그램을 실행할 때 UIImageView 여전히 왼쪽 된 모서리가 표시됩니다. 셀 안의 Imageview는 클리핑되지 않습니다. UIImageView의 모서리 반경을 설정하지 않고도 누구나 해결책을 찾을 수 있습니까?UITableViewCell에서 UIImageView의 모퉁이를 숨기기

답변

2

이 방법은 레이어 마스크와 모서리 반경을 사용하는 것입니다.

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:frame 
                  byRoundingCorners:UIRectCornerAllCorners 
                   cornerRadii:CGSizeMake(5.0, 5.0)]; 
      // Create the shape layer and set its path 
      CAShapeLayer *maskLayer = [CAShapeLayer layer]; 
      maskLayer.frame = frame; 
      maskLayer.path = maskPath.CGPath; 
      // Set the newly created shape layer as the mask for the image view's layer 
      imageView.layer.mask = maskLayer; 
imageView.layer.cornerRadius = 5.0; 

frame 귀하의 이미지 뷰의 프레임이라고 가정 : 어떻게 여기입니다. 그리고 #import <QuartzCore/QuartzCore.h>을 잊지 마세요. 행운을 빕니다!

+0

Fahri Azimov thaks 좋은 ...하지만 왼쪽 모서리 마스크 ineed이 ... – krishh

+0

그런 다음 경로에 지정하는 것이 -'UIBezierPath * maskPath = [UIBezierPath bezierPathWithRoundedRect : 프레임 byRoundingCorners : UIRectCornerBottomLeft | UIRectCornerTopLeft cornerRadii : CGSizeMake (5.0, 5.0)]' –

+0

Fahri Azimov 예 ... 다시 감사드립니다 ... – krishh

0

셀의 clipsToBounds 속성을 YES으로 설정하고 원하는 결과가 표시되는지 확인해보십시오.

관련 문제