2
我想添加圆角只有我的UITableView的顶部角落,但问题是,与下面的代码,它只是在我的整个UITableView黑色层。我将如何解决这个问题?将圆角添加到UITableView的顶部?
//Rounded Corners for top corners of UITableView
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:thetableView.bounds
byRoundingCorners:UIRectCornerTopLeft
cornerRadii:CGSizeMake(10.0, 10.0)];
UIBezierPath *maskPath2 = [UIBezierPath bezierPathWithRoundedRect:thetableView.bounds
byRoundingCorners:UIRectCornerTopRight
cornerRadii:CGSizeMake(10.0, 10.0)];
// Create the shape layer and set its path
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = thetableView.bounds;
maskLayer.path = maskPath.CGPath;
CAShapeLayer *maskLayer2 = [CAShapeLayer layer];
maskLayer.frame = thetableView.bounds;
maskLayer.path = maskPath2.CGPath;
// Set the newly created shape layer as the mask for the image view's layer
[thetableView.layer addSublayer:maskLayer];
[thetableView.layer addSublayer:maskLayer2];
这将是同样的问题。我的问题通常是任何UIView或其子类。所以我需要弄清楚这一点。 – 2011-12-25 06:53:30
http://stackoverflow.com/questions/2264083/rounded-uiview-using-calayers-only-some-corners-how检查出来可能会帮助你。 – Emon 2011-12-25 07:17:57
哦,而不是做addSublayer,我应该只是设置CCLayer的mask属性。那么如何在一个掩码中添加多个UIRextconrners? – 2011-12-25 07:31:56