No, there’s no way to turn off anti-aliasing, and these days you shouldn’t be even considering it if you’re writing properly vector-based scalable UIs. If you care about this stuff, you’re probably sitting too close to the screen.
And think about what a line is. It’s actually a rectangle, 1 pixel wide. So if you draw a line that is centred at y=3, it will actually cover the range 2.5 to 3.5, which will be smudged across 2 pixels. If you want it to lie within a single pixel, you could either draw it at y = 2.5, so that it goes from 2.0 to 3.0, or better still, use a rectangle, because what you’re trying to draw isn’t really a line at all, it’s a 1-pixel high rectangle.
I’m sure this topic has been raised many many times before, and people have drawn nice diagrams to explain it, but I can’t seem to find any of them.