我正在创建一个带有 LeftCapWidth:topCapHeight可拉伸图像
float shrinkFactor = 0.2; NSTimeInterval slowSpeed = 5.0; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:slowSpeed]; UIButton *thisButton = (UIButton *)[self.view viewWithTag:2]; thisButton.frame = CGRectMake(thisButton.frame.origin.x, thisButton.frame.origin.y, buttonStretchedWidth * shrinkFactor, thisButton.frame.size.height); [UIView commitAnimations];
按钮图像大小不会设置动画,它只是捕捉到新的大小。
当我做出决定的时候 背景色 对于可见的按钮,我看到帧本身正确地设置了动画。
我从来没有能够得到图像拉伸不断更新。试着把你的图像分割成大写和中间区域,然后创建八个或九个 UIImageView 子视图具有适当的 autoresizingMask 设置例如,右上角视图应具有 UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin ,底部中心视图(正在拉伸)应具有 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin 等等在iPhone操作系统上,一旦创建了视图,它们的价格就相当便宜,所以我认为,除非你同时制作六个按钮的动画,否则你不会看到性能的提升。尽管合成非不透明视图非常昂贵,但请确保尽可能使其不透明。
UIImageView
autoresizingMask
UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin