自定义弹框

效果图:



自定义弹框简单使用
将Demo中的FTAlertView工具类文件夹添加进工程即可使用,代码调用如下

- (void)showAlertView {
    FTAlertView *alertView = [[FTAlertView alloc] init];
    // 设置提醒框大小
    [alertView setAlertViewSize:CGSizeMake(0.8*CGRectGetWidth([UIScreen mainScreen].bounds), 200)];
    
    // 自定义提醒框内容视图
    UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([UIScreen mainScreen].bounds), 150)];
    customView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [alertView customContentView:customView];
    
    // 设置对话框按钮 若不需要按钮 参数传nil即可
    [alertView setButtonTitles:@[@"Cancel",@"Next",@"OK"]];
    // 设置按钮高度 按钮可以自定义
    alertView.buttonHeight = 50.0;
    
    // 按钮点击事件响应 buttonIndex与数组titles索引一致
    [alertView clickButtonAction:^(NSInteger buttonIndex) {
        NSLog(@"---button %ld", buttonIndex);
    }];
    
    [alertView show];
}

Demo下载

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容