2013-10-13 73 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

只要它回答的問題我不是事情,它不需要粘貼代碼。 –