简体   繁体   中英

Reusing a Custom Toolbar in iOS

I created this nice custom toolbar that sits on one of my scenes, this scene uses its own viewcontroller. Prior to this I had no need to put it on any other viewcontroller, but after making modifications to my application I now need to put this toolbar on another viewcontroller/scene. I would prefer not to have to re-create the whole UI aspect of it again and connect up everything.

Ive created this toolbar on a scene using a storyboard. Is it possible somehow to reuse all the elements I've created for this toolbar (the code for all the logic already sits in its own class)? Or would I need to create the entire toolbar in the code for this to be possible? Is there any easier way that I just dont know about?

I think you have two options here. One would be to keep the custom toolbar view always on the screen, and change the views around it to whatever you like. Another option would be to create an instance of your toolbar from any class you need, then add it's view as a subview everytime you need it.

Either way, I think you may need to rework some the toolbar to not sit on a scene, but have it's own.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM