我用了this example在 uiview
上绘制虚线:
UIBezierPath *path = [UIBezierPath bezierPath];
//draw a line
[path moveToPoint:yourStartPoint]; //add yourStartPoint here
[path addLineToPoint:yourEndPoint];// add yourEndPoint here
[path stroke];
float dashPattern[] = {1,1,1,1}; //make your pattern here
[path setLineDash:dashPattern count:4 phase:0];
UIColor *fill = [UIColor blueColor];
shapelayer.strokeStart = 0.0;
shapelayer.strokeColor = fill.CGColor;
shapelayer.lineWidth = 7.0;
shapelayer.lineJoin = kCALineJoinMiter;
shapelayer.lineDashPattern = [NSArray arrayWithObjects:[NSNumber numberWithInt:10],[NSNumber numberWithInt:10], nil];
shapelayer.lineDashPhase = 3.0f;
shapelayer.path = path.CGPath;
它有效,但问题是即使我将 uiview
高度设置为 1,我得到的线还是很粗。
可以再薄一点吗?
最佳答案
您可以在代码的这一部分更改线条的粗细:
shapelayer.lineWidth = 7.0;
将 7.0
更改为您希望线条具有的任何粗细。
关于ios - 在 IOS 上更改虚线粗细,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40927930/