objective c 截屏代碼
-(void)save{
UIGraphicsBeginImageContext(mybackgroundview.bounds.size); //currentView 當前的view
[mybackgroundview.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
}截取 您想要的一層
UIGraphicsBeginImageContext(CGSizeMake(320, 300)); //currentView 當前的view
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
截取自定義的大小
剛剛用到 不知道 是不是您想要的
更多信息請查看IT技術專欄