CGContext and retina display

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

guys, this is my code:

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


        
4条回答
  •  天命终不由人
    2021-01-02 23:56

    You can just set the scale when you start the context

    + (UIImage *)imageWithView:(UIView *)view {
        UIGraphicsBeginImageContextWithOptions([view bounds].size, NO, [[UIScreen mainScreen] scale]);
    
        [[view layer] renderInContext:UIGraphicsGetCurrentContext()];
    
        UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
    
        UIGraphicsEndImageContext();
    
        return result;
    }
    

提交回复
热议问题