2012-12-20 38 views

回答

2

你並不需要把它顯示出來。 該視圖對象只是通過這個功能,你會得到的圖像

+ (UIImage *) imageWithView:(UIView *)view 
{ 
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0); 
    [view.layer renderInContext:UIGraphicsGetCurrentContext()]; 

    UIImage * img = UIGraphicsGetImageFromCurrentImageContext(); 

    UIGraphicsEndImageContext(); 

    return img; 
} 
+0

我已經意識到,有一個半小時..感謝張貼的問題後, –

0
func imageWithView (view: UIView)->UIImage 
{ 
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, false, 0.0) 
    view.layer.renderInContext(UIGraphicsGetCurrentContext()) 
    newImage = UIGraphicsGetImageFromCurrentImageContext() 
    UIGraphicsEndImageContext() 
    return newImage 
} 

這是swift版本