Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c UIView中的UIImage和显示图像部分超出范围_Objective C_Ios_Uiview_Uiimage - Fatal编程技术网

Objective c UIView中的UIImage和显示图像部分超出范围

Objective c UIView中的UIImage和显示图像部分超出范围,objective-c,ios,uiview,uiimage,Objective C,Ios,Uiview,Uiimage,我在子视图中有一个图像,它比它本身的子视图大,是否可以显示子视图之外的部分图像!我试过了 view.clipsToBounds=NO; 但仍然不乏 这是我到目前为止的部分代码 xRayView = [[XRayView alloc] initWithFrame: CGRectMake((1024 - 800) / 2, self.device.frame.origin.y - 26, 800,530)]; xRayView.clipsToBounds=NO;

我在子视图中有一个图像,它比它本身的子视图大,是否可以显示子视图之外的部分图像!我试过了

view.clipsToBounds=NO; 
但仍然不乏

这是我到目前为止的部分代码

xRayView = [[XRayView alloc] initWithFrame: CGRectMake((1024 - 800) / 2, self.device.frame.origin.y - 26, 800,530)];
        xRayView.clipsToBounds=NO;
        [xRayView setForgroundImage: [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource: @"xray_foreground_01" ofType: @"png"]]];
        [xRayView setBackgroundImage: [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource: @"xray_background_01" ofType: @"png"]]];
前景和背景图像比X射线视图大

在x光视图中,我有两个属性

背景图像 前景图像

那方法呢

- (void)drawRect: (CGRect)rect
{
    [super drawRect: rect];

    CGRect forgroundClips[] = {
        CGRectMake((self.frame.size.width - self.forgroundImage.size.width)/2, 0, self.forgroundImage.size.width, currentPan.origin.y),
        CGRectMake((self.frame.size.width - self.forgroundImage.size.width)/2, currentPan.origin.y + currentPan.size.height, self.forgroundImage.size.width, self.forgroundImage.size.height - (currentPan.origin.y + currentPan.size.height))
    };

    CGContextSaveGState(UIGraphicsGetCurrentContext());
    CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0, self.bounds.size.height);
    CGContextScaleCTM(UIGraphicsGetCurrentContext(), 1, -1);
    CGContextClipToRects(UIGraphicsGetCurrentContext(), forgroundClips, sizeof(forgroundClips) / sizeof(forgroundClips[0]));
    //CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height), self.forgroundImage.CGImage);
    CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake((self.frame.size.width - self.forgroundImage.size.width)/2, 0, self.forgroundImage.size.width, self.forgroundImage.size.height), self.forgroundImage.CGImage);
    CGContextRestoreGState(UIGraphicsGetCurrentContext());

    CGContextSaveGState(UIGraphicsGetCurrentContext());
    CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0, self.bounds.size.height);
    CGContextScaleCTM(UIGraphicsGetCurrentContext(), 1, -1);
    CGContextClipToRect(UIGraphicsGetCurrentContext(), currentPan);
    CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 153, 153, 153, 0.5);
    CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 3);
    CGContextStrokeRect(UIGraphicsGetCurrentContext(), currentPan);
    //CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height), self.backgroundImage.CGImage);
    CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake((self.frame.size.width - self.backgroundImage.size.width)/2 , 0, self.backgroundImage.size.width, self.backgroundImage.size.height), self.backgroundImage.CGImage);
    CGContextRestoreGState(UIGraphicsGetCurrentContext());

    // Draw a yellow hollow rectangle

   // CGContextRestoreGState(UIGraphicsGetCurrentContext());
}

clipstobunds
表示图像将被剪裁到边界之外。确保将其设置为
NO
。(这是在原始帖子中说的
clipstobunds=YES;
)时发布的)

clipstobunds
意味着图像将被剪切到边界之外。确保将其设置为
NO
。(这是在最初的帖子中说的
clipsToBounds=YES;
)时发布的)

视图无论如何都不能超出其边界。设置
clipstobunds
将只允许在视图外部渲染子视图,但不会改变无法在视图外部绘制(在
drawRect
方法中)的事实


如果您有权访问
XRayView
源,请查看图像的渲染方式。它们可能是在
XRayView
drawRect
方法中绘制的。您必须添加一个视图。

视图无论如何都不能超出其边界。设置
clipstobunds
将只允许在视图外部渲染子视图,但不会改变无法在视图外部绘制(在
drawRect
方法中)的事实


如果您有权访问
XRayView
源,请查看图像的渲染方式。它们可能是在
XRayView
drawRect
方法中绘制的。您必须添加一个。

是的,对不起,我的错,它设置为“否”,但仍然存在问题!我想这可能是因为您正在使用这些背景图像,进入X光视图,确保backgroundImage(视图)和ForeggroundImage(视图)设置为
clipsToBounds=NO
是的,对不起,我的错,设置为NO,但仍然存在问题!我认为这可能是因为您正在使用这些背景图像,请进入x光视图,并确保backgroundImage(view)和ForeggroundImage(view)设置为
clipsToBounds=NO
尝试为保存
UIImageView
UIImageView
对象设置
CliptBounds
属性和
背景图像
。如果这还不行,您可能需要向我们提供有关
XRayView
的视图继承权的更多详细信息。请尝试为保存您的
forgroundImage
[SIC]和
backgroundImage
UIImageView
对象设置
cliptobunds
属性。如果这还不行,您可能需要向我们提供有关
XRayView
的视图继承权的更多详细信息。