2010-08-10 73 views
1

我在用下面的代码的图绘制背景图像:与drawAsPatternInRect绘制一图象时如何忽略变换:

CGContextRef currentContext = UIGraphicsGetCurrentContext(); CGContextSaveGState(currentContext);您可以使用UIImage来创建自己的图片,并将其添加到您的图片中。 [image drawAsPatternInRect:rect];

CGContextRestoreGState(currentContext);

这效果很好。但是,当我改变该视图的大小动画绘制的图像缩放,直到它得到重绘。如何在动画期间忽略这种转换?

回答

1

我终于找到了解决方案。我使用contentMode UIViewContentModeTopLeft,所以它不会缩放。在调整大小动画之前,如果新大小大于旧大小,我只能重绘。动画之后,我总是重绘。

+0

好一个:)!很好的解决方法! – elslooo 2011-10-28 17:11:43

2

目前我不认为这是可能的。由于iPhone没有一个非常快的处理器,Apple选择禁用LiveRedraw功能(Mac上实际可用)。

1

尝试将视图的contentMode设置为UIViewContentModeRedraw

- (id)initWithFrame:(CGRect)frame { 
    if ((self = [super initWithFrame:frame])) { 

     // Get the view to redraw when it's frame is changed 
     self.contentMode = UIViewContentModeRedraw; 

    } 
    return self; 
} 
+0

只具有现在背景在变换前绘制的效果。所以现在动画中的hick不在它刚刚开始的动画的末尾。 – V1ru8 2010-08-10 12:00:30

+1

哦,好的。检查这个答案,认为这就是你要找的东西:http://stackoverflow.com/questions/818207/uiview-scaling-during-animation – 2010-08-10 12:29:43