cocoa简单的划线

cocoa简单的划线,第1张

概述交替划实线和虚线: // 划直实线 - (void)drawLine:(CGPoint)from ToPoint:(CGPoint)to {     float lengths[] = {4, 0};     // Drawing lines with a white stroke color     CGContextRef context =UIGraphicsGetCurrentContex

交替划实线和虚线:

// 划直实线

- (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简单的划线所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1058482.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存