CAShapeLayer *border = [CAShapeLayer layer];
// 虚线的颜色
border.strokeColor = kColorWithFloat(0xC9D4DE).CGColor;
// 填充的颜色
border.fillColor = [UIColor clearColor].CGColor;
// 设置路径
border.path = [[UIBezierPath bezierPathWithRoundedRect:self.contentiew.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(35, 35)] bezierPathByReversingPath].CGPath;
border.frame = self.contentiew.bounds;
// 虚线的宽度
border.lineWidth = 1.f;
// 虚线的间隔
border.lineDashPattern = @[@5, @4];
[self.contentView.layer addSublayer:border]
iOS画虚线
最新推荐文章于 2023-03-04 14:06:45 发布