IOS encapsulation button, ios encapsulation button
Add button
# Pragma mark Add button-(void) addButtonWithImage :( NSString *) image highImage :( NSString *) highImage disableImage :( NSString *) disableImage frame :( CGRect) frame tag :( NSInteger) tag action :( SEL) action {// create button UIButton * btn = [[UIButton alloc] init]; // set the background image [btn setBackgroundImage: [UIImage imageNamed: image] forState: UIControlStateNormal]; [btn setBackgroundImage: [UIImage imageNamed: highImage] forState: Unknown]; [btn setBackgroundImage: [UIImage imageNamed: disableImage] forState: UIControlStateDisabled] // set the position and size of btn. frame = frame; // click the listening button [btn addTarget: self action: action forControlEvents: UIControlEventTouchUpInside]; // bind the tag to btn. tag = tag; // Add button [self. view addSubview: btn];}