iOS 画线

时间:2014-09-24 18:18:08   收藏:0   阅读:201
@interface ShowLineView : UIView

-(void)drawRect:(CGRect)rect{

    
CGContextRef context = UIGraphicsGetCurrentContext();
    
CGContextSetLineCap(context, kCGLineCapSquare);//设置线条样式
    
CGContextSetLineWidth(context, 0.2);    //设置线条粗细宽度
    
CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);   //设置颜色
    
CGContextBeginPath(context);    //开始一个起始路径
    
CGContextMoveToPoint(context, 1030);  //起始点设置为(0,0):注意这是上下文对应区域中的相对坐标,
    
CGContextAddLineToPoint(context, 30030); //设置下一个坐标点
    
CGContextStrokePath(context);  //连接上面定义的坐标点
}
-----------------
-(void)showLine{

    
ShowLineView *view = [[ShowLineView allocinitWithFrame:CGRectMake(030320100)];
    view.
backgroundColor = [UIColor cyanColor];
    [
self.view addSubview:view];

}


bubuko.com,布布扣


原文:http://blog.csdn.net/u010241322/article/details/39525393

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!