CGContext and retina display

后端 未结 4 1171
面向向阳花
面向向阳花 2021-01-02 23:38

guys, this is my code:

- (void) renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx {
    //background
    CGContextSetFillColorWithColor(ctx, [[         


        
4条回答
  •  时光取名叫无心
    2021-01-03 00:14

    For Swift 3

    func getImageFromContext() -> UIImage{
    
        UIGraphicsBeginImageContextWithOptions(self.frame.size, false, UIScreen.main.scale)
        self.drawHierarchy(in: self.bounds, afterScreenUpdates: true)
        self.layer.render(in: UIGraphicsGetCurrentContext()!)
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
    
        return image!
    }
    

提交回复
热议问题