2012-06-12 15 views
5

मैं अपने टेबलव्यू के केवल ऊपरी दाएं और बाएं कोने को गोल करने की कोशिश कर रहा हूं। मैं नीचे दिए गए कोड का उपयोग कर रहा हूं और यह केवल ऊपरी बाएं कोने को घेर रहा है ...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 का उपयोग कर सेट एक आकार लेयर मास्क बनाने बनाने के लिए खोजें: // stackoverflow .com/a/5826698/855738 मैंने इस उत्तर का उपयोग बहुत कुछ करने के लिए किया था – BBog

+1

इसे पुरानी पोस्ट पता है लेकिन बस सुनिश्चित करें कि आपको मिल गया है। [tableView.layer setMasksToBound: हाँ] और यह ठीक और बेवकूफ होना चाहिए –

+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)]; 

UIBezierPath maskPath

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

मुखौटा परत maskLayer

self.testView.layer.mask = maskLayer;