使用平铺背景图像进行UIView旋转时的视觉瑕疵

使用平铺背景图像进行UIView旋转时的视觉瑕疵,uiview,background,rotation,design-patterns,tile,Uiview,Background,Rotation,Design Patterns,Tile,我有一个带有标准UIViewController/UIView设置的iPad应用程序-允许所有旋转。UIView绘制一些平铺图像作为背景(平铺为256*256像素): 当我转动我的iPad时,我可以看到在旋转过程中,原始方向的图像模式被缩放以适应新方向。然后-动画完成后,视图立即使用未缩放的最终配置重新绘制其背景图案。从缩放图案切换到未缩放图案看起来有点难看 有没有办法避免(或隐藏)这种背景图案的拉伸?为什么不使用图案图像作为背景“颜色”?这会自动生成平铺图案,并避免使用drawRect()进行

我有一个带有标准UIViewController/UIView设置的iPad应用程序-允许所有旋转。UIView绘制一些平铺图像作为背景(平铺为256*256像素):

当我转动我的iPad时,我可以看到在旋转过程中,原始方向的图像模式被缩放以适应新方向。然后-动画完成后,视图立即使用未缩放的最终配置重新绘制其背景图案。从缩放图案切换到未缩放图案看起来有点难看


有没有办法避免(或隐藏)这种背景图案的拉伸?

为什么不使用图案图像作为背景“颜色”?这会自动生成平铺图案,并避免使用drawRect()进行任何特技。例如:

UIImage *backgroundTile = [UIImage imageNamed: @"Background.png"];
UIColor *backgroundPattern = [[UIColor alloc] initWithPatternImage:backgroundTile];
[myView setBackgroundColor:backgroundPattern];
[backgroundPattern release];

为什么不使用图案图像作为背景“颜色”?这会自动生成平铺图案,并避免使用drawRect()进行任何特技。例如:

UIImage *backgroundTile = [UIImage imageNamed: @"Background.png"];
UIColor *backgroundPattern = [[UIColor alloc] initWithPatternImage:backgroundTile];
[myView setBackgroundColor:backgroundPattern];
[backgroundPattern release];
简言之

[myView setBackgroundColor:[UIColor WithPatternImage:[UIImage ImageName:@“Background.png”]]

简而言之


[myView setBackgroundColor:[UIColor WithPatternImage:[UIImage ImageName:@“Background.png”]]

我会尝试你的解决方案,但我自己也想出了一个解决方案:当我在viewController的“willRotateToInterfaceOrientation:duration”方法中使用“setNeedsDisplay”标记视图进行重画时,视图将在转动iPad后立即重画,但在旋转动画完成之前。这意味着,背景图像在动画开始时拉伸,并在动画过程中平滑无拉伸。这对人眼来说已经不明显了。我会尝试你的解决方案,但我自己也想出了一个解决方案:当我在viewController的“willRotateToInterfaceOrientation:duration”方法中使用“setNeedsDisplay”标记视图进行重绘时,视图将在转动iPad后立即重绘,但在旋转动画完成之前。这意味着,背景图像在动画开始时拉伸,并在动画过程中平滑无拉伸。人眼再也看不到这一点了。