BLACK FRIDAY SALE: Save 50% on all my Swift books and bundles! >>

Core Animation and UIKit performance comparisons

Recorded – watch the full episode on YouTube.

We've got all our UIKit code, we've got our Core Animation code. How well do you think the performance maps within the two? How do they perform compared to their equivalent in UIKit?

Janina Kutyn: I really think that for most of the functionality they're a little bit faster, but I think from most of the function, it's not that much faster. I think most of the functions that performance boost is negligible, but ultimately I guess if you think about it, CALayer lives below your UIKit. So you basically get rid of the overhead that comes with a UIView and go directly to CALayer. If there were things also happening in UIView equivalent methods, then you will get rid of that overhead. But if it's just a direct call straight through to CALayer, then you're not going to see much of a performance boost.

Paul Hudson: Is it ever really then worth the effort of trying to bypass UIKit and go down to CALayer or should we just stick with UIKit?

“I think most of the functions that performance boost is negligible, but ultimately I guess if you think about it, CALayer lives below your UIKit. So you basically get rid of the overhead that comes with a UIView and go directly to CALayer.”

Janina Kutyn: I think some of those layers, they do have a performance increase. Like if you measure drawing a UILabel versus a text layer, like you will see the text layer is faster to draw.

But you are missing on a lot of sort of features of UIKit. So I don't know, I would personally, I would not start with that but if I want to, for example, if I have text layer and I want to give that something special, like maybe that has a great effect in coloring of the text, then I might be thinking, “okay, text layer, overlaid with something as a mask or gradient layer.” I guess I would look at the designs and think about if there are advanced effects and that I can achieve by using layers. If there's nothing advanced, I would just personally I would stick to UIKit. And wouldn't over optimize yet.

This transcript was recorded as part of Swiftly Speaking. You can watch the full original episode on YouTube, or subscribe to the audio version on Apple Podcasts.

Listen on Apple Podcasts

Save 50% in my Black Friday sale.

SAVE 50% To celebrate Black Friday, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Sponsor Hacking with Swift and reach the world's largest Swift community!

BUY OUR BOOKS
Buy Pro Swift Buy Pro SwiftUI Buy Swift Design Patterns Buy Testing Swift Buy Hacking with iOS Buy Swift Coding Challenges Buy Swift on Sundays Volume One Buy Server-Side Swift Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Advanced iOS Volume Three Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with macOS Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Beyond Code

Was this page useful? Let us know!

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.