tableViewcell中的时间线

来源:互联网 发布:大数据岗位 编辑:程序博客网 时间:2024/06/09 20:11

在自定义的cell中:


-(void)drawRect:(CGRect)rect{
    NSLog(@"cell的绘制");
    //画圆
    [self drawCircle:CGPointMake(rect.size.width/2, rect.size.height/2) radius:6.0];
    //划线
    [self drawLine:rect];
}
-(void)drawLine:(CGRect)rect {
    CGContextRef context = UIGraphicsGetCurrentContext();
    //边缘样式
    CGContextSetLineCap(context, kCGLineCapRound);
    // 线的宽度
    CGContextSetLineWidth(context, 2);
    CGContextSetAllowsAntialiasing(context, true);
    //线的颜色
    CGContextSetRGBStrokeColor(context, 255, 0, 0, 1.0);
    CGContextBeginPath(context);
        //起点
        CGContextMoveToPoint(context, 12, 0);
        //终点坐标
        CGContextAddLineToPoint(context, 12, rect.size.height);
    CGContextStrokePath(context);
}
//画圆
-(void)drawCircle:(CGPoint)center radius:(float)radius{
    //一个不透明类型的Quartz 2D绘画环境,相当于一个画布,你可以在上面任意绘画
    CGContextRef context = UIGraphicsGetCurrentContext();
    /*画圆*/
    UIColor*aColor = [UIColor colorWithRed:1 green:0.0 blue:0 alpha:1];
    CGContextSetFillColorWithColor(context, aColor.CGColor);//填充颜色
    CGContextSetLineWidth(context, 0.1);//线的宽度
    CGContextAddArc(context, 12, center.y, radius, 0, 2*PI, 0);
    //添加一个圆
    //kCGPathFill填充非零绕数规则,kCGPathEOFill表示用奇偶规则,kCGPathStroke路径,kCGPathFillStroke路径填充,kCGPathEOFillStroke表示描线,不是填充
        CGContextDrawPath(context, kCGPathFillStroke); //绘制路径加填充
}


0 0
原创粉丝点击