2013-10-13 74 views

回答

1

你可以使用动画块吗?在动画,你可以通过

UIGraphicsBeginImageContext(scrollView.frame.size); 
CGContextRef context = UIGraphicsGetCurrentContext(); 
[scrollView.layer renderInContext:context]; 
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

渲染滚动视图的内容一个UIImage你会把此图像中滚动视图的图像预览(图像视图的内容模式设置为调整大小以适应)覆盖现有的内容并使图像视图始终与滚动视图大小相同。使其看起来像整个滚动视图正在调整大小。

这里是动画块代码。

缩小

scrollView.frame = icon.frame 


    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDuration:0.5]; 
    [UIView setAnimationDelay:1.0]; 
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; 

    scrollview.frame = window.frame; 

    [UIView commitAnimations]; 

放大

scrollView.frame = window.frame 


    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDuration:0.5]; 
    [UIView setAnimationDelay:1.0]; 
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; 

    scrollview.frame = icon.frame; 

    [UIView commitAnimations]; 
+0

这对我不起作用 – Alfa

0

你可以用它复制iOS主屏幕的大部分功能this源代码。

+0

只是一个问题:由于存在链接腐烂的风险(我过去曾被低估过),仅仅通过链接回答问题通常是不被接受的。您应该粘贴链接在答案中的任何相关代码。 – Andrew

+0

只要它回答的问题我不是事情,它不需要粘贴代码。 –