首页 > 移动平台 > 详细

iOS Quartz2D图形上下文栈

时间:2015-03-23 15:00:11      阅读:178      评论:0      收藏:0      [点我收藏+]

    // 获取图形上下文

    CGContextRef ctx = UIGraphicsGetCurrentContext();

    // 存储上下文栈

    CGContextSaveGState(ctx);

    // 设置图形上下文

    CGContextSetLineWidth( ctx, 10);

    [[UIColor redColor] set];

    

    // 画第1根线

    CGContextMoveToPoint(ctx, 50, 50);

    CGContextAddLineToPoint(ctx, 200, 190);

    CGContextStrokePath(ctx);

    

    // 图形上下文栈的栈顶上下文出栈,替换当前上下文

    CGContextRestoreGState(ctx);

    

    // 画第2根线

    CGContextMoveToPoint(ctx, 10, 200);

    CGContextAddLineToPoint(ctx, 300, 50);

    CGContextStrokePath(ctx);

技术分享

iOS Quartz2D图形上下文栈

原文:http://www.cnblogs.com/oumygade/p/4359749.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!