iOS iPhone is it possible to clone UIView and have it draw itself to two UIViews?

后端 未结 4 1394
梦如初夏
梦如初夏 2020-12-15 08:05

I\'m thinking of a way to have a UIView render itself onto another UIView as well as the first one. So I have my main UIView with it\'s bounds, and the UIView also renders i

4条回答
  •  失恋的感觉
    2020-12-15 08:35

    This seems to be an oft asked question here on StackOverflow. For example:

    iphone, ipad Duplicate UIView - Cloned View

    Copying the drawn contents of one UIView to another

    UIView duplicate

    Duplicate, clone or copy UIView

    But if it were me doing this, my first approach would be to get a handle to the UIView I want to copy, then recursively iterate all the subviews of it and then copy & add them as subviews to the UIView I want to copy the main UIView into.

    I can't imagine there's too much layer operations going on with this, but you would likely need to figure out how to programmatically re-establish outlets and/or actions.

提交回复
热议问题