To add to Jim‘s answer above using a category
@implementation UIButton (NSCopying)
- (id)copyWithZone:(NSZone *)zone {
NSData *archivedData = [NSKeyedArchiver archivedDataWithRootObject:self];
UIButton *buttonCopy = [NSKeyedUnarchiver unarchiveObjectWithData: archivedData];
return buttonCopy;
}
@end
if you wanted to copy all of the actions from one button to another, add something like this:
for (id target in button.allTargets) {
NSArray *actions = [button actionsForTarget:target forControlEvent:UIControlEventTouchUpInside];
for (NSString *action in actions) {
[newButton addTarget:target action:NSSelectorFromString(action) forControlEvents:UIControlEventTouchUpInside];
}