[Solved] A UIImage created in coregraphics isn’t repeating


I don’t know what the context is that you’re passing in, but whatever it is, you shouldn’t be drawing into it. And you aren’t drawing anything into the context that you made with UIGraphicsBeginImageContextWithOptions.

If you want to generate an image, you don’t need to pass in a context, just use the one that UIGraphicsBeginImageContextWithOptions makes for you.

UIImage *paperBackgroundPattern() {
    UIGraphicsBeginImageContextWithOptions(CGSizeMake(320, 1), NO, 0);
    CGContextRef context = UIGraphicsGetCurrentContext();

    // draw into context, then...

    UIImage *paperImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return paperImage;
}

Also — are you really trying to make an image that’s 320 pt wide and 1 high? It seems odd that you are drawing such elaborate stuff into such a tiny image.

1

solved A UIImage created in coregraphics isn’t repeating