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,
CALayerlives below your UIKit. So you basically get rid of the overhead that comes with a
UIViewand go directly to
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.
SPONSORED ViRE offers discoverable way of working with regex. It provides really readable regex experience, code complete & cheat sheet, unit tests, powerful replace system, step-by-step search & replace, regex visual scheme, regex history & playground. ViRE is available on Mac & iPad.
Link copied to your pasteboard.