画图2

作者: nothing_c | 来源:发表于2016-10-30 23:33 被阅读16次

定时器画图


- (id)initWithFrame:(CGRect)frame {

self= [super initWithFrame:frame];

if(self) {

_movePoint= CGPointMake(10, 10);

_linePoint = CGPointMake(10, 10);

[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];

}

return self;

}

- (void)onTimer {

CGPoint movePoint =_movePoint;

movePoint.x += 10;

movePoint.y += 10;

_movePoint = movePoint;

CGPoint linePoint = _linePoint;

linePoint.x += 5;

linePoint.y += 20;

_linePoint = linePoint;

//调用drawRect方法重新绘制

[self setNeedsDisplay];

}

- (void)drawRect:(CGRect)rect {

[super drawRect:rect];

//创建画布获取当前画板

CGContextRefcontext = UIGraphicsGetCurrentContext();

CGContextSetLineWidth(context, 10);

CGContextSetRGBStrokeColor(context, 1, 1, 0, 1);

CGContextSetLineJoin(context,kCGLineJoinRound);

CGContextMoveToPoint(context,_movePoint.x,_movePoint.y);

CGContextAddLineToPoint(context,_linePoint.x,_linePoint.y);

CGContextStrokePath(context);

}

相关文章

  • 画图2

    定时器画图 - (id)initWithFrame:(CGRect)frame { self= [super in...

  • pheatmap()画图2

    一:创建矩阵: # Create test matrixtest = matrix(rnorm(200), 20,...

  • 批量ROC

    1、建模 2、画图 3、保存

  • ggplot2 中 scale 的使用

    ggplot 中 scale 的使用 ggplot画图是画图中的战斗机,但是往往在我们用ggplot2画图时候,需...

  • 用sklearn 实践AUC画图

    sklearn 画AUC图 图例 1, 加载包 2, 加载数据 3, 加入噪音 4, 遍历画图 5, 画图

  • Matplotlib教程-初级

    [TOC] 1. 画图——基础 了解图的基本组成部分 2. 画图——样式 数据线的样式设置 3. 画图——公式Te...

  • html5 Canvas画图5:曲线之arc

    本文属于《html5 Canvas画图系列教程》 在《html5 Canvas画图教程2:Canvas画线条 基础...

  • 跟着Nature Communications 学画图~ggpl

    今天继续 跟着Nature Communications学画图系列第五篇。学习R语言ggplot2包画图。然后多个...

  • 丹心入画图(2)

    长篇小说《丹心入画图》 第一章 初见良人2 江南烟雨,太湖绝佳。细雨如丝中,云宜撑伞立在船头。 最近一次去苏城是...

  • Matplotlib画图教程(2)

    控制画图的大小 子图 面向对象 fig,ax=plt.subplot() fig,ax=plt.subplots(...

网友评论

      本文标题:画图2

      本文链接:https://www.haomeiwen.com/subject/daiuuttx.html