如何在视图中绘制多条垂直虚线?
我试图将边框添加到附带的视图中,如下所示:
// line top
UIView *line = [[UIView alloc] initWithFrame:CGRectMake(20, 50, 730, 1)];
//line.backgroundColor = [UIColor colorWithRed:15.0/255.0f green:144.0/255.0f blue:190.0/255.0f alpha:1.0];
CAShapeLayer *yourViewBorder = [CAShapeLayer layer];
yourViewBorder.strokeColor = [UIColor colorWithRed:15.0/255.0f green:144.0/255.0f blue:190.0/255.0f alpha:1.0].CGColor;
yourViewBorder.fillColor = nil;
yourViewBorder.lineDashPattern = @[@2, @2];
yourViewBorder.frame = line.bounds;
yourViewBorder.path = [UIBezierPath bezierPathWithRect:line.bounds].CGPath;
[line.layer addSublayer:yourViewBorder];
[pdfview addSubview:line];
//fine line top
Pdfview是第一个观点,我在她的内心画了很多虚线。 还有其他方法吗? 感谢
答案 0 :(得分:0)
为了提高效率,您可以申请CAReplicatorLayer。你不需要UIView
这是文档 https://developer.apple.com/documentation/quartzcore/careplicatorlayer?language=objc