“renderInContext:” and CATransform3D

后端 未结 3 866
粉色の甜心
粉色の甜心 2021-02-04 21:27

I have an view that have mutiples views inside it, and an image presentation (aka. \'cover flow\') into that too... And I need to make a screenshot programatically !

Sin

3条回答
  •  时光取名叫无心
    2021-02-04 21:45

    I got it working with protocols.... I'm implementing a protocol in all UIViews classes that make 3D transforms. So when I request a screenshot, it make all subviews screenshot, and generate one UIImage.. Not so good for lots of views, but I'm doing in a few views.

    #pragma mark - Protocol implementation 'TDITransitionCustomTransform'
    
    //Conforms to "TDITransitionCustomTransform" protocol, return currrent image view state , by current layer
    
    - (UIImage*)imageForCurrentState {
    
    //Make print
    
    UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0);
    
    [self.layer renderInContext:UIGraphicsGetCurrentContext()];
    
    UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
    
    UIGraphicsEndImageContext();
    
    //return printed image
    
    return screenShot;
    
    }
    

    I was thinking it may works now because I'm doing that render in the transformed view layer, which have being transformed it self... And it wasn't working because "renderInContext:" doesn't get layers of it subviews, may it possible ?

    Anyone interest in a bit more code of this solution, can be found here . in the apple dev forum.

    It may be a function bug, or it just not being design for this purpose ...

提交回复
热议问题