iOS 画线
时间:2014-09-24 18:18:08
收藏:0
阅读:201
@interface ShowLineView : UIView
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineCap(context, kCGLineCapSquare);//设置线条样式
CGContextSetLineWidth(context, 0.2); //设置线条粗细宽度
CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor); //设置颜色
CGContextBeginPath(context); //开始一个起始路径
CGContextMoveToPoint(context, 10, 30); //起始点设置为(0,0):注意这是上下文对应区域中的相对坐标,
CGContextAddLineToPoint(context, 300, 30); //设置下一个坐标点
CGContextStrokePath(context); //连接上面定义的坐标点
}
-----------------
-(void)showLine{
ShowLineView *view = [[ShowLineView alloc] initWithFrame:CGRectMake(0, 30, 320, 100)];
view.backgroundColor = [UIColor cyanColor];
[self.view addSubview:view];
}
ShowLineView *view = [[ShowLineView alloc] initWithFrame:CGRectMake(0, 30, 320, 100)];
view.backgroundColor = [UIColor cyanColor];
[self.view addSubview:view];
}
原文:http://blog.csdn.net/u010241322/article/details/39525393
评论(0)