2012-11-24 24 views
0

以下是在一個UITableViewCell具有相同功能的繪製的兩行的圖片,和相同的寬度,和顏色 enter image description here線畫出

如當在尺寸有時會發生變化你可以看到底線比另一條線厚很多。

我使用繪圖代碼:

[CSDrawing drawLineWithColor:[UIColor blackColor] width:1.0 yPosition:1.0 rect:rect]; 
    [CSDrawing drawLineWithColor:[UIColor blackColor] width:1.0 yPosition:CGRectGetMaxY(rect) - 3.0 rect:rect]; // draw a line on top and bottom 

    +(void)drawLineWithColor:(UIColor *)color width:(CGFloat)width yPosition:(CGFloat)yPosition rect:(CGRect)rect { 

      CGContextRef context = UIGraphicsGetCurrentContext(); 
      CGContextSaveGState(context); 

      CGContextMoveToPoint(context, 0.0, yPosition); 
      CGContextAddLineToPoint(context, CGRectGetMaxX(rect), yPosition); 

      CGContextSetStrokeColorWithColor(context, color.CGColor); 
      CGContextSetLineWidth(context, width); 

      CGContextStrokePath(context); 

      CGContextRestoreGState(context); 
    } 

回答

-1

的問題是與backgroundView被拉伸是被重複使用的電池時,以適應單元格的內容。當細胞更大時,像素被拉伸。這是解決的設置contentMode屬性爲UIViewContentModeRedraw

+0

爲什麼downvote?很高興知道 – AlexWien