交替划实线和虚线:
// 划直实线
- (voID)drawline:(CGPoint)from topoint:(CGPoint)to {
float lengths[] = {4,0};
// Drawing lines with a white stroke color
CGContextRef context =UIGraphicsGetCurrentContext();
CGContextBeginPath(context);
CGContextSetlinewidth(context,1.0);
CGContextSetstrokecolorWithcolor(context,[UIcolor graycolor].CGcolor);
@H_404_40@// Draw a single line from left to right
CGContextSetlineDash(context,0,lengths,0);
CGContextMovetoPoint(context,from.x,from.y);
CGContextAddlinetoPoint(context,to.x,to.y);
CGContextstrokePath(context);
}
// 划虚线
- (voID)drawlineDash:(CGPoint)from topoint:(CGPoint)to {
float lengths[] = {4,4};
CGContextRef context =UIGraphicsGetCurrentContext();
CGContextBeginPath(context);
CGContextSetlinewidth(context,[UIcolor graycolor].CGcolor);
@H_404_40@CGContextSetlineDash(context,2);
CGContextMovetoPoint(context,to.y);
CGContextstrokePath(context);
}
通过 CGContextSetlineDash 来设置线条。 总结以上是内存溢出为你收集整理的cocoa简单的划线全部内容,希望文章能够帮你解决cocoa简单的划线所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)