How to implement a layers system for Pencil kit canvas similar to photoshop layers?

I want to implement layers system that is similar to photoshop layers system. I can't figure out how to use subviews for this purpose. Any leads/resources would be helpful. Thanks

How to implement a layers system for Pencil kit canvas similar to photoshop layers?
 
 
Q