UIView drawRect drawing lines?

The integral coordinates indicate places half-way between pixels; that is, (0,0) is in the upper-left corner above and to the left of the upper-left pixel similarly, (1,0) is between the first and second pixels; finally, (0.5,0.5) is at the center of the upper-left pixel According to the documentation for CGContextSetLineWidth when stroked, the line straddles the path, with half of the total width on either side. " Thus, if the path is lying precisely in between the pixels, the line will be stroked half on one row of pixels, half on the other Hence, to get a sharp pixel line, you must offset your coordinates by half a pixel: for your x coordinate, use rect.size. Height - 7.5 instead of 7 By the way, when drawing rectangles, it is handy to use CGRectInset(rect, 0.5, 0.5) to achieve this.

The integral coordinates indicate places half-way between pixels; that is, (0,0) is in the upper-left corner, above and to the left of the upper-left pixel; similarly, (1,0) is between the first and second pixels; finally, (0.5,0.5) is at the center of the upper-left pixel. According to the documentation for CGContextSetLineWidth, "when stroked, the line straddles the path, with half of the total width on either side. " Thus, if the path is lying precisely in between the pixels, the line will be stroked half on one row of pixels, half on the other.

Hence, to get a sharp pixel line, you must offset your coordinates by half a pixel: for your x coordinate, use rect.size. Height - 7.5 instead of - 7. By the way, when drawing rectangles, it is handy to use CGRectInset(rect, 0.5, 0.5) to achieve this.

The iPhone 4 uses a coordinate system with a scale factor of 2. So you would need to set the line width to 0.5 in order to get what you want.(The coordinate system is set up that way so the same code produces the same output on all models.).

1 A line that is one pixel thick on a normal display should be two pixels thick on a Retina display. – David M. Sep 7 '10 at 22:37.

Lines are by default drawn antialiased (unless you configure otherwise). Thus any line that's not strictly vertical or horizontal and starting and ending on a pixel will likely partially cover multiple pixels in some rows and/or columns, making it look like a wider grey line instead of a thin higher-contrast line.

Yeah lines look like they are being antialiased, however when I turn antialiasing off, they still look that way. – almosnow Sep 7 '10 at 19:38.

By the way, when drawing rectangles, it is handy to use CGRectInset(rect, 0.5, 0.5) to achieve this.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions