Ios UImageView在设置其旧帧后变得模糊,因为我取消了收缩手势

Ios UImageView在设置其旧帧后变得模糊,因为我取消了收缩手势,ios,uiimageview,uiimage,pinchzoom,uipinchgesturerecognizer,Ios,Uiimageview,Uiimage,Pinchzoom,Uipinchgesturerecognizer,我正在编写一个应用程序,以便用户可以在UIImageView上绘制 他还可以在放大/缩小时捏一下它 我实现了一个撤销功能 因此,每次用户绘制笔划或捏图片时,我都会保存图像和帧: ImageWithFrame *imageWithFrame = [[ImageWithFrame alloc] initWithImageAndFrame:imageViewSubject.image andFrame:imageViewSubject.frame]; [self.tabImag

我正在编写一个应用程序,以便用户可以在UIImageView上绘制

他还可以在放大/缩小时捏一下它

我实现了一个撤销功能

因此,每次用户绘制笔划或捏图片时,我都会保存图像和帧:

    ImageWithFrame *imageWithFrame = [[ImageWithFrame alloc]
    initWithImageAndFrame:imageViewSubject.image andFrame:imageViewSubject.frame];
    [self.tabImageForUndo addObject:imageWithFrame];
我试图在数组中保存整个UIImageView,但它不起作用,这就是我保存UIImage和帧的原因

在用户点击撤销按钮后,我从数组中获得了最后一张imageWithFrame

    ImageWithFrame *imageWithFrame = [self.tabImageForUndo lastObject];
我这样做:

    ImageWithFrame *imageWithFrame = [self.tabImageForUndo lastObject];

    self.imageViewSubject.frame = CGRectIntegral(imageWithFrame.frame);
    self.imageViewSubject.image = imageWithFrame.image;

    self.imageViewSubject.autoresizingMask = UIViewAutoresizingFlexibleWidth |     UIViewAutoresizingFlexibleHeight;

    [self.tabImageForUndo removeLastObject];
我会清除图形上下文,以防万一:

    UIGraphicsBeginImageContext(self.view.bounds.size);

    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextClearRect(context, self.view.bounds);

   // clean up context
   UIGraphicsEndImageContext();
======================================

我的UIImageView出现了,我做了一个笔划,我做了一个撤销,它工作了

在我进行收缩之后,UIImageView的大小将被调整(缩小或放大),我将执行撤消操作,以便UIImageView返回到其旧帧

但是

如果我再画一笔,图片就会变得模糊,UIImageView会变得越来越小

看这个视频

我得到了同样的效果(但在整个UIImage上,这是正常的,因为UIImage已经用笔划重新绘制)

它已由另一个用户从以下帖子上载:

但我不认为它的问题来源与我的有关

请注意,如果我不做捏,它的工作非常完美,所以我认为问题是当我在捏手势后设置旧框架时

我希望我足够清楚


非常感谢:)

我终于用

UIGraphicsBeginImageContextWithOptions(self.imageViewSubject.bounds.size, self.imageViewSubject.opaque, 0.0);
而不是

UIGraphicsBeginImageContext(self.imageViewSubject.bounds.size);

[主题外]抱歉,我不知道,但我必须说效果看起来很神奇。就像“颜料”在水中溶解一样。