Cocoa touch 多个屏幕尺寸不支持在UIView中绘制线?

Cocoa touch 多个屏幕尺寸不支持在UIView中绘制线?,cocoa-touch,uiview,core-graphics,Cocoa Touch,Uiview,Core Graphics,我想在基于UIView高度的UIView中绘制线。(即)线条高度应等于UIView的高度。为此,我使用以下代码 - (void)testDraw :(void(^)(UIImage *image, UIImage *selectedImage))done { CGSize imageSize = CGSizeMake(1000, self.bounds.size.height); //Begin the animation by checking the

我想在基于UIView高度的UIView中绘制线。(即)线条高度应等于UIView的高度。为此,我使用以下代码

- (void)testDraw :(void(^)(UIImage *image, UIImage *selectedImage))done
    {
        CGSize imageSize = CGSizeMake(1000, self.bounds.size.height);
        //Begin the animation by checking the screen is retina / ordinary
        if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
            UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0.0f);
        else
            UIGraphicsBeginImageContext(imageSize);

        CGContextRef context = UIGraphicsGetCurrentContext();

        for (NSInteger intSample=0; intSample < 1000; intSample++) {

            if(intSample % self.samplesPerSecond == 0){
                //draw separator line
                [self drawLine:context fromPoint:CGPointMake(intSample, 0) toPoint:CGPointMake(intSample, self.frame.size.height) color:self.lineColor lineWidth:2.0];
            }
        }
        UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
        CGRect drawRect = CGRectMake(0, 0, image.size.width, self.frame.size.height);
        [self.progressColor set];
        UIRectFillUsingBlendMode(drawRect, kCGBlendModeSourceAtop);
        UIImage *tintedImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        done(image, tintedImage);
}

//Draw the line based on the value received
- (void) drawLine:(CGContextRef) context fromPoint:(CGPoint) fromPoint toPoint:(CGPoint) toPoint color:(UIColor*) color lineWidth:(float) lineWidth{

    CGContextBeginPath(context);
    //add the lines with sizes that u want
    CGContextSetAlpha(context,1.0);
    CGContextSetLineWidth(context, lineWidth);
    CGContextSetStrokeColorWithColor(context, [color CGColor]);
    CGContextMoveToPoint(context, fromPoint.x, fromPoint.y);
    CGContextAddLineToPoint(context, toPoint.x, toPoint.y);
    CGContextStrokePath(context);


}
-(void)testDraw:(void(^)(UIImage*image,UIImage*selectedImage))完成
{
cgsizeimagesize=CGSizeMake(1000,self.bounds.size.height);
//通过检查屏幕是否正常开始动画
如果([[UIScreen Main Screen]响应选择器:@选择器(比例)])
UIGraphicsBeginImageContextWithOptions(图像大小,编号,0.0f);
其他的
UIGraphicsBeginImageContext(图像大小);
CGContextRef context=UIGraphicsGetCurrentContext();
对于(NSInteger intSample=0;intSample<1000;intSample++){
if(intSample%self.samplesPerSecond==0){
//画分隔线
[自绘制线:上下文fromPoint:CGPointMake(intSample,0)toPoint:CGPointMake(intSample,self.frame.size.height)颜色:self.lineColor线宽:2.0];
}
}
UIImage*image=UIGraphicsGetImageFromCurrentImageContext();
CGRect drawRect=CGRectMake(0,0,image.size.width,self.frame.size.height);
[self.progresscolorset];
UIRectFillUsingBlendMode(drawRect、KCGBlendModeSourceTop);
UIImage*TinteImage=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsSendImageContext();
完成(图像、着色图像);
}
//根据收到的值绘制线
-(void)绘图线:(CGContextRef)上下文fromPoint:(CGPoint)fromPoint toPoint:(CGPoint)toPoint颜色:(UIColor*)颜色线宽:(float)线宽{
CGContextBeginPath(上下文);
//添加具有所需大小的线条
CGContextSetAlpha(上下文,1.0);
CGContextSetLineWidth(上下文,线宽);
CGContextSetStrokeColorWithColor(上下文,[color CGColor]);
CGContextMoveToPoint(上下文,fromPoint.x,fromPoint.y);
CGContextAddLineToPoint(上下文,toPoint.x,toPoint.y);
CGContextStrokePath(上下文);
}
当我在3.5英寸显示屏上执行上面的代码时,它工作正常。但是,当我在4英寸的范围内运行相同的代码时,基于UIView的行高度并没有增加。这些线的工作方式与自动布局不同

提前谢谢,有人能给你建议解决这个问题吗