Objective c 核心图形拖动到像素上而不是点上

Objective c 核心图形拖动到像素上而不是点上,objective-c,ios,core-graphics,drawrect,pixels,Objective C,Ios,Core Graphics,Drawrect,Pixels,好的,我哪儿都没找到。如果我想用每像素的核心图形绘制,我应该怎么做?比如…我想画一条到像素(45,61)和(46,63)的线,而不是画到点(23,31)或类似的东西。那么在这种情况下我该怎么办 我应该使用类似于: CGContextAddLineToPoint(context,22.5,30.5); CGContextAddLineToPoint(context,23,31.5); 还是有更好的办法 我知道contentScaleFactor,但我应该将其用作(例如,在绘制某些函数时): fo

好的,我哪儿都没找到。如果我想用每像素的核心图形绘制,我应该怎么做?比如…我想画一条到像素(45,61)和(46,63)的线,而不是画到点(23,31)或类似的东西。那么在这种情况下我该怎么办

我应该使用类似于:

CGContextAddLineToPoint(context,22.5,30.5);
CGContextAddLineToPoint(context,23,31.5);
还是有更好的办法

我知道
contentScaleFactor
,但我应该将其用作(例如,在绘制某些函数时):


for(int x=bounds.origin.x;x听起来像是在做iOS uTunes斯坦福课程的作业3:)
我认为您走上了正确的道路,因为我的实现看起来非常相似:

for(int x=self.bounds.origin.x; x<=self.bounds.origin.x + (self.bounds.size.width * self.contentScaleFactor); x++) {
    // get the scaled X Value to ask dataSource
    CGFloat axeX = (x/self.contentScaleFactor - self.origin.x) / self.scale;

    // using axeX here for testing, which draws a x=y graph
    // replace axeX with the dataSource Y-Point calculation
    CGFloat axeY = -1 * ((axeX * self.scale) + self.origin.y); 

    if (x == self.bounds.origin.x) {
        CGContextMoveToPoint(context, x/self.contentScaleFactor, axeY);
    } else {
        CGContextAddLineToPoint(context, x/self.contentScaleFactor, axeY);          
    }
}

<代码> >(int x=己.n..Orth.x;席)完全相同的解决方案。接受第一X的处理(但它不影响比例因子:)
for(int x=self.bounds.origin.x; x<=self.bounds.origin.x + (self.bounds.size.width * self.contentScaleFactor); x++) {
    // get the scaled X Value to ask dataSource
    CGFloat axeX = (x/self.contentScaleFactor - self.origin.x) / self.scale;

    // using axeX here for testing, which draws a x=y graph
    // replace axeX with the dataSource Y-Point calculation
    CGFloat axeY = -1 * ((axeX * self.scale) + self.origin.y); 

    if (x == self.bounds.origin.x) {
        CGContextMoveToPoint(context, x/self.contentScaleFactor, axeY);
    } else {
        CGContextAddLineToPoint(context, x/self.contentScaleFactor, axeY);          
    }
}