0
我添加CAShapeLayer作爲子在給定的視圖self.layer這樣:CALayer subLayer正在繪製不同的幀起源。邊界問題
//balloonrect's value is this one
_balloonRect = CGRectMake(0, 55, 239, 118);
CAShapeLayer *balloonFrame = [CAShapeLayer layer];
balloonFrame.cornerRadius = 15.0f;
balloonFrame.frame = _balloonRect;
balloonFrame.fillColor = _balloonColor.CGColor;
balloonFrame.strokeColor = _balloonStrokeColor.CGColor;
balloonFrame.lineWidth = 5.0f;
balloonFrame.lineCap = kCALineCapRound;
balloonFrame.lineJoin = kCALineJoinRound;
balloonFrame.masksToBounds = YES;
UIBezierPath *fillPath = [UIBezierPath bezierPathWithRoundedRect: CGRectInset(_balloonRect, balloonFrame.lineWidth, balloonFrame.lineWidth) cornerRadius: 15.0f];
balloonFrame.path = fillPath.CGPath;
但是,不明白爲什麼,形狀在balloonRect指定的高度下畫,它似乎應該是110 px而不是55。 奇怪的是,如果我添加行
balloonFrame.bounds = _balloonRect;
設置層的框架後,一切似乎都很正常,什麼是正是發生了什麼?爲什麼我必須設置邊界,如果他們是爲了自己的圖層?