【发布时间】:2020-02-25 16:00:30
【问题描述】:
此代码仅创建 topLeft 边框,但我也想要 topRight。怎么样?
UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:self.colorSliderBackgroundView.bounds
byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)
cornerRadii:CGSizeMake(10.0,10.0)];
CAShapeLayer *borderLayer = [[CAShapeLayer alloc] init];
borderLayer.frame = self.colorSliderBackgroundView.bounds;
borderLayer.path = maskPath.CGPath;
borderLayer.lineWidth = 1.5f;
borderLayer.strokeColor = [UIColor colorWithRed:243.0/255.0 green:243.0/255.0 blue:243.0/255.0 alpha:1.0].CGColor;
borderLayer.fillColor = [UIColor clearColor].CGColor;
[self.colorSliderBackgroundView.layer addSublayer:borderLayer];
【问题讨论】:
-
您应该使用 colorSliderBackgroundView 的边界更改来更新 shapelayer 的路径。
-
@Cy-4AH,你能写代码吗
-
@iOS - 你希望
colorSliderBackgroundView被勾勒出来,顶部圆角吗?或者你想让colorSliderBackgroundView有一个sublayer,它是一个带有圆角的轮廓矩形?
标签: ios objective-c uiview