开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (1)
master
master
分支 (1)
master
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (1)
master
SWViewController.m 7.61 KB
一键复制 编辑 原始数据 按行查看 历史
shede333 提交于 2019年11月03日 00:11 +08:00 . 完善Example
//
// SWViewController.m
// SWAlertController
//
// Created by shede333 on 11/01/2019.
// Copyright (c) 2019 shede333. All rights reserved.
//
#import "SWViewController.h"
#import <SWAlertController/SWAlertKit.h>
#import <YYKit/YYKit.h>
#define LocalLog(_text) [self showLog:_text]
@interface SWViewController ()
@property (weak, nonatomic) IBOutlet UITextView *logView;
@end
@implementation SWViewController
- (void)viewDidLoad{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)showLog:(NSString *)logText{
NSLog(@"%@", logText);
if (self.logView.text.length > 0) {
logText = [NSString stringWithFormat:@"%@\n%@", logText, self.logView.text];
}
self.logView.text = logText;
}
#pragma mark - action
- (IBAction)actionShowAlert:(id)sender {
SWAlertController *alertVC = [SWAlertController alertControllerWithTitle:@"Hello"];
//普通message的widget
NSString *message = @"这是一个带title+message的普通示例,支持点击哟";
SWAlertMessageItem *messageItem = [SWAlertMessageItem messageWithText:message
handler:^(SWAlertMessageItem * _Nonnull item) {
LocalLog(@"点击了:messageItem");
}];
[alertVC addWidgetItem:messageItem];
//添加 "取消"、"确定"按钮
SWAlertActionItem *cancelAction = [SWAlertActionItem actionWithTitle:@"取消"
style:SWAlertActionItemStyleCancel
handler:^(SWAlertActionItem * _Nonnull action) {
LocalLog(@"点击:取消按钮");
}];
SWAlertActionItem *confirmAction = [SWAlertActionItem actionWithTitle:@"确定"
style:SWAlertActionItemStyleDefault
handler:^(SWAlertActionItem * _Nonnull action) {
LocalLog(@"点击:确定按钮");
}];
[alertVC addAction:cancelAction];
[alertVC addAction:confirmAction];
//显示Alert弹框
[self presentViewController:alertVC animated:YES completion:nil];
}
- (IBAction)actionShowMutiAlert:(id)sender {
NSString *logText = @"显示了定制UI后的弹框,支持多种类型的widget,用户也可以自己定义新的widget";
LocalLog(logText);
SWAlertUIConfig *uiConfig = [SWAlertUIConfig new];
//蓝色的标题
uiConfig.titleColor = [UIColor blueColor];
//半透明墨绿色的HUB背景色
uiConfig.hubContentBgColor = [UIColorHex(0xCCE8CF) colorWithAlphaComponent:0.7];
SWAlertController *alertVC = [SWAlertController alertControllerWithTitle:@"Hello, blue"
uiConfig:uiConfig];
//普通message的widget
NSString *message = logText;
SWAlertMessageItem *messageItem = [SWAlertMessageItem messageWithText:message
handler:^(SWAlertMessageItem * _Nonnull item) {
LocalLog(@"点击:messageItem");
}];
messageItem.label.textAlignment = NSTextAlignmentLeft;
messageItem.label.backgroundColor = [UIColor whiteColor];
messageItem.label.font = [UIFont systemFontOfSize:14];
messageItem.label.layer.masksToBounds = YES;
messageItem.label.layer.cornerRadius = 6;
messageItem.topSpace = 10;
[alertVC addWidgetItem:messageItem];
//标题Label+详情Label的控件
SWAlertKVContentItem *kvItem = [SWAlertKVContentItem kvContentWithTitle:@"标题Label:"
detail:@"详情Label"];
kvItem.titleLabel.font = [UIFont boldSystemFontOfSize:16];
kvItem.detailLabel.textColor = [UIColor redColor];
[alertVC addWidgetItem:kvItem];
//webview控件,也支持url、本地html文件或者字符串;
NSString *url = @"https://www.qq.com";
SWAlertWebViewItem *webItem = [SWAlertWebViewItem webviewWithURL:url
height:150
clickURLHandler:^BOOL(NSURL * _Nonnull url) {
NSString *tmpLog = [NSString stringWithFormat:@"点击了URL: %@", url];
LocalLog(tmpLog);
return NO; //支持url跳转,则返回NO
}];
[alertVC addWidgetItem:webItem];
//自定义view 控件
NSArray *allTitle = @[@"123", @"自定义view", @"abc"];
UISegmentedControl *scView = [[UISegmentedControl alloc] initWithItems:allTitle];
scView.selectedSegmentIndex = 1;
SWAlertCustomViewItem *cvItem = [SWAlertCustomViewItem customWithView:scView
height:40];
cvItem.topSpace = 15;
[alertVC addWidgetItem:cvItem];
//添加 "取消"、"确定"按钮
SWAlertActionItem *cancelAction = [SWAlertActionItem actionWithTitle:@"取消"
style:SWAlertActionItemStyleCancel
handler:^(SWAlertActionItem * _Nonnull action) {
LocalLog(@"点击:取消按钮");
}];
SWAlertActionItem *confirmAction = [SWAlertActionItem actionWithTitle:@"确定"
style:SWAlertActionItemStyleDefault
handler:^(SWAlertActionItem * _Nonnull action) {
LocalLog(@"点击:确定按钮");
}];
[alertVC addAction:cancelAction];
[alertVC addAction:confirmAction];
//显示Alert弹框
[self presentViewController:alertVC animated:YES completion:nil];
}
- (IBAction)actionShowTextScrollAlert:(id)sender {
SWAlertController *alertVC = [SWAlertController alertControllerWithTitle:@"Hello"];
//普通message的widget
NSString *message = @"这个message的高度超过最大值后(默认200),会显示成类似textView的滑动格式,上下滑动试试看。\n\n";
message = [message stringByAppendingString:message];
message = [message stringByAppendingString:message];
message = [message stringByAppendingString:message];
message = [message stringByAppendingString:message];
//这里的handler必须为nil
SWAlertMessageItem *messageItem = [SWAlertMessageItem messageWithText:message
handler:nil];
messageItem.maxHeight = 100; //maxHeight默认为200;
messageItem.topSpace = 10;
messageItem.label.font = [UIFont systemFontOfSize:14];
[alertVC addWidgetItem:messageItem];
//添加 "取消"、"确定"按钮
SWAlertActionItem *cancelAction = [SWAlertActionItem actionWithTitle:@"取消"
style:SWAlertActionItemStyleCancel
handler:^(SWAlertActionItem * _Nonnull action) {
LocalLog(@"点击:取消按钮");
}];
SWAlertActionItem *confirmAction = [SWAlertActionItem actionWithTitle:@"确定"
style:SWAlertActionItemStyleDefault
handler:^(SWAlertActionItem * _Nonnull action) {
LocalLog(@"点击:确定按钮");
}];
[alertVC addAction:cancelAction];
[alertVC addAction:confirmAction];
//显示Alert弹框
[self presentViewController:alertVC animated:YES completion:nil];
}
@end
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

UIAlertController的自定义实现,支持更丰富的UI定制,支持更多的UI控件;
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Objective-C
1
https://gitee.com/Yimi178/SWAlertController2.git
git@gitee.com:Yimi178/SWAlertController2.git
Yimi178
SWAlertController2
SWAlertController2
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /