弹出视图,支持任何定制,整合UIAlertView和UIActionSheet两种风格的弹框,支持iOS7

发布于 2021-12-29 09:57:08 字数 2293 浏览 778 评论 0

整合了UIAlertView和UIActionSheet这两种系统风格的弹框,创建弹框再也不用兼容iOS8以前和iOS8以后了。代码也不会因为delegate而分离,直接接受Block回调。如果您觉得我的代码帮到了您,我会非常欣慰。同时如果您想兼容到iOS7以前,或者您觉得有其他地方需要改进的,或者代码有什么Bug,非常欢迎您与我联系,我的qq:1522949535,邮箱:qq邮箱

这里的代码可能不是最新的,如果您想下载最新代码,欢迎您到GitHub下载:https://github.com/XIAMOON/LQPopUpView

创建方式1:
LQPopUpView *popUpView = [[LQPopUpView alloc] initWithTitle:@"提示" message:@"这是用第一种初始化方法创建的弹出视图"];

[popUpView addBtnWithTitle:@"取消" type:LQPopUpBtnStyleCancel handler:^{
// do something...
}];

[popUpView addBtnWithTitle:@"确定" type:LQPopUpBtnStyleDefault handler:^{
// do something...
}];

[popUpView showInView:self.view preferredStyle:_segmentControl.selectedSegmentIndex];

创建方式2:
LQPopUpView *popUpView = [[LQPopUpView alloc] initWithTitle:@"提示" message:@"这是第二种创建方式,也是一种快捷创建方式,没有太多的代码分离,使用起来特别方便,而且你可以单独再次加入任何按钮" cancelButtonTitle:@"取消" otherButtonTitles:@[@"提示一次", @"提示两次", @"确定"] actionWithIndex:^(NSInteger index) {
// do something...
}];
[popUpView showInView:self.view preferredStyle:_segmentControl.selectedSegmentIndex];

创建方式3:
LQPopUpView *popUpView = [[LQPopUpView alloc] initWithTitleConfiguration:^(TitleConfiguration *configuration) {
configuration.text = @"提示";
} messageConfiguration:^(MessageConfiguration *configuration) {
configuration.text = @"这是第三种创建方式,这个创建方式可以对title和message的文本、字号、字体颜色、文本上下边距进行定制,随时适应您的需求";
configuration.fontSize = 15.0;
configuration.textColor = [UIColor purpleColor];
configuration.bottom = 25.0;
}];

[popUpView addBtnWithTitle:@"取消" type:LQPopUpBtnStyleCancel handler:^{
// do something...
}];
[popUpView showInView:self.view preferredStyle:_segmentControl.selectedSegmentIndex];

下载地址:http://www.wenjiangs.com/wp-content/uploads/2021/docimg35/92c455a18b57a31a26ea99173c183f1d.zip

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文