How to duplicate a UIButton in Objective C?

后端 未结 6 667
梦谈多话
梦谈多话 2020-12-24 02:35

The object inherits from NSObject.

Is there a method to create a copy of it as a new object?

6条回答
  •  天命终不由人
    2020-12-24 03:29

    UIButton doesn't conform to the NSCopying protocol, so you have copy it by hand. On the other hand, it is not a bad thing, since it is not exactly clear what does it mean to copy a button. For example, should it add the button copy to the same view the original is in? Should it fire the same methods when tapped?

提交回复
热议问题