0
嗨,下面的代碼使一個灰色的小矩形與一個黑暗的邊框。角落收音機不工作,我不明白爲什麼,我試過應用maskToBounds = true,但這只是隱藏整個對象...CAShapeLayer cornerRadius不工作在UIBezierPath
我該如何實現這一目標?由於
CGRect r = CGRectMake(conX, conY, 220, 50);
UIBezierPath* conPath = [UIBezierPath bezierPathWithRect:r];
CAShapeLayer* conLayer = [CAShapeLayer layer];
conLayer.path = conPath.CGPath;
conLayer.cornerRadius = 5.0;
UIColor *bg = [UIColor colorWithWhite:1 alpha:0.7];
[conLayer setFillColor:bg.CGColor];
[conLayer setStrokeColor:[UIColor grayColor].CGColor];
[[self layer] addSublayer:conLayer];
如果它是你想要的遮罩效果,請將圖層的__mask__屬性設置爲具有圓形矩形路徑的形狀圖層 – nielsbot
Thanks Niels thats awesome mate! :d) – Baconbeastnz