开发者

What's faster: Creating a gradient programmatically using Quartz2D or just importing an image?

Let's assume the file space o开发者_运维问答n the iphone isn't an issue, what would perform better? Would there be any noticeable speed/smoothness difference between the two?


Whilst not specifically targeting gradients (rather patterns) this tutorial by Ray Wenderlich does have some basic information at the bottom with regards images vs. Core Graphics drawing.

TL;DR Core Graphics is seemingly quite a bit faster when used in this context.

For what it's worth, I do as much drawing as possible in my app using Core Graphics including such things as radial gradients and textured UILabel's. As a developer with limited design skills I find I often get far better results drawing this way than fumbling about using something like Photoshop.

Another advantage with using Core Graphics is that you can change things on the fly with ease, such as animating a gradient, which would be incredibly expensive were you to do it solely with images.


Importing an image hits the disk, so it's going to be marginally slower. After the image is rendered it doesn't matter where it came from because the result is cached. Unless you need to update the image and ask for a redraw, in which case, it depends on the complexity of the gradient vs displaying the already cached image, but the image is probably faster.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜