使用AHKActionSheet
使用AHKActionSheet
https://github.com/fastred/AHKActionSheet
基本配置代码:
AHKActionSheet *actionSheet = [[AHKActionSheet alloc] initWithTitle:NSLocalizedString(@"您确定需要编辑?", nil)]; actionSheet.cancelButtonTitle = @"取消"; [actionSheet addButtonWithTitle:NSLocalizedString(@"信息", nil) image:[UIImage imageNamed:@"Icon1"] type:AHKActionSheetButtonTypeDefault handler:^(AHKActionSheet *as) { NSLog(@"Info tapped"); }]; [actionSheet addButtonWithTitle:NSLocalizedString(@"添加收藏", nil) image:[UIImage imageNamed:@"Icon2"] type:AHKActionSheetButtonTypeDefault handler:^(AHKActionSheet *as) { NSLog(@"Favorite tapped"); }]; [actionSheet addButtonWithTitle:NSLocalizedString(@"分享", nil) image:[UIImage imageNamed:@"Icon3"] type:AHKActionSheetButtonTypeDefault handler:^(AHKActionSheet *as) { NSLog(@"Share tapped"); }]; [actionSheet addButtonWithTitle:NSLocalizedString(@"删除", nil) image:[UIImage imageNamed:@"Icon4"] type:AHKActionSheetButtonTypeDestructive handler:^(AHKActionSheet *as) { NSLog(@"Delete tapped"); }]; [actionSheet show];
高级配置代码:
- (IBAction)advancedExampleTapped:(id)sender { AHKActionSheet *actionSheet = [[AHKActionSheet alloc] initWithTitle:nil]; actionSheet.blurTintColor = [UIColor colorWithWhite:0.0f alpha:0.75f]; actionSheet.blurRadius = 8.0f; actionSheet.buttonHeight = 50.0f; actionSheet.cancelButtonHeight = 50.0f; actionSheet.animationDuration = 0.5f; actionSheet.cancelButtonShadowColor = [UIColor colorWithWhite:0.0f alpha:0.1f]; actionSheet.separatorColor = [UIColor colorWithWhite:1.0f alpha:0.3f]; actionSheet.selectedBackgroundColor = [UIColor colorWithWhite:0.0f alpha:0.5f]; UIFont *defaultFont = [UIFont fontWithName:@"Avenir" size:17.0f]; actionSheet.buttonTextAttributes = @{ NSFontAttributeName : defaultFont, NSForegroundColorAttributeName : [UIColor whiteColor] }; actionSheet.destructiveButtonTextAttributes = @{ NSFontAttributeName : defaultFont, NSForegroundColorAttributeName : [UIColor redColor] }; actionSheet.cancelButtonTextAttributes = @{ NSFontAttributeName : defaultFont, NSForegroundColorAttributeName : [UIColor whiteColor] }; actionSheet.cancelButtonTitle = @"取消"; UIView *headerView = [[self class] fancyHeaderView]; actionSheet.headerView = headerView; [actionSheet addButtonWithTitle:NSLocalizedString(@"信息", nil) image:[UIImage imageNamed:@"Icon1"] type:AHKActionSheetButtonTypeDefault handler:nil]; [actionSheet addButtonWithTitle:NSLocalizedString(@"添加收藏", nil) image:[UIImage imageNamed:@"Icon2"] type:AHKActionSheetButtonTypeDefault handler:nil]; for (int i = 0; i < 5; i++) { [actionSheet addButtonWithTitle:[NSString stringWithFormat:@"分享 %d", i] image:[UIImage imageNamed:@"Icon3"] type:AHKActionSheetButtonTypeDefault handler:nil]; } [actionSheet addButtonWithTitle:NSLocalizedString(@"删除", nil) image:[UIImage imageNamed:@"Icon4"] type:AHKActionSheetButtonTypeDestructive handler:nil]; [actionSheet show]; } #pragma mark - Private + (UIView *)fancyHeaderView { UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 60)]; UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Cover"]]; imageView.frame = CGRectMake(10, 10, 40, 40); [headerView addSubview:imageView]; UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(60, 20, 200, 20)]; label1.text = @"你提供的一些有用信息"; label1.textColor = [UIColor whiteColor]; label1.font = [UIFont fontWithName:@"Avenir" size:17.0f]; [headerView addSubview:label1]; return headerView; }
模糊背景怎么实现的呢?
先截图:
再模糊:
惯用伎俩哦:)