NEW: Learn to build the incredible iOS 15 Weather app today! >>

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

Hacking with Swift is sponsored by Essential Developer

SPONSORED Learn the most up-to-date techniques and strategies for testing new and legacy Swift code in this free practical course for iOS devs who want to become complete Senior iOS Developers.

Learn more

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

BUY OUR BOOKS
Buy Pro Swift 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 (Vapor Edition) 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 Server-Side Swift (Kitura Edition) 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.