• 使用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;
    }

    模糊背景怎么实现的呢?

    先截图:

    再模糊:

    惯用伎俩哦:)

  • 相关阅读:
    java.lang.IllegalStateException: getOutputStream() has already been called for this response
    html5之table嵌入form表单布局(务必注意:table标签必须在form表单内部,不能再form表单外部!)
    两张图搞清楚Eclipse上的Web项目目录
    使用VS 2019发布.net core程序并部署到IIS的最新教程
    国外便宜虚拟主机有哪些?
    怎样收用电汇来收adsense的广告费呢
    程序员同性交友网站github在国内不能访问了
    直接引用MrAdvice.dll文件不能实现AOP拦截,教你1分钟解决这个问题
    VS2019打包WPF安装程序最新教程
    通过VS2017发布.net core程序并使用Web 部署到远程服务器最新教程
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/3790337.html
Copyright © 2020-2023  润新知