Create a copy of a UIView in Swift

后端 未结 7 1869
长发绾君心
长发绾君心 2020-11-29 05:01

Because objects are reference types, not value types, if you set a UIView equal to another UIView, the views are the same object. If you modify one

7条回答
  •  伪装坚强ぢ
    2020-11-29 05:29

    Additionally you can use this pattern to copy View controller view

    let vc = UIViewController() 
    let anotherVc = UIViewController()
    vc.view = anotherVc.copyView()
    

    You may need this for caching view controller or cloning.

提交回复
热议问题