一些 UIKit 的 block 功能扩展。
只需将源代码复制/链接到您的项目中,使用它!使用起来非常简单。
您也可以使用 CocoaPods 安装 HTBlock。
`pod 'HTBlock', '~> 0.1.0'`
UIAlertView
[[[UIAlertView alloc] initWithTitle:@"Title"
message:@"Message"
cancelButtonTitle:@"No"
otherButtonTitles:@[@"Yes"]
dismissBlock:^(UIAlertView *alertView, NSUInteger buttonIndex) {
if (buttonIndex == alertView.cancelButtonIndex) {
return;
} else {
NSLog(@"YES");
}
}] show];
UIControl
[button addTargetBlock:^(id sender) {
NSLog(@"Button Pressed");
} forControlEvents:UIControlEventTouchUpInside];