使用AHKActionSheet

使用AHKActionSheet

使用AHKActionSheet_第1张图片

 

https://github.com/fastred/AHKActionSheet

使用AHKActionSheet_第2张图片

基本配置代码:

    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;
}

模糊背景怎么实现的呢?

使用AHKActionSheet_第3张图片

先截图:

使用AHKActionSheet_第4张图片

再模糊:

使用AHKActionSheet_第5张图片

惯用伎俩哦:)

 

 

 

你可能感兴趣的:(action)