SGAlertController 1.0.0

SGAlertController 1.0.0

slagslag 维护。



  • 作者:
  • slagslag

链接到 SGAlertController.h

系统提示框封装,传入标题、内容。传入取消、确定、其他选项。可选择提示样式: AlertSheet

作者:

slagslag,[email protected]

示例:

要运行示例项目,请先克隆仓库,然后从 Example 目录运行 pod install

安装:

SGAlertController 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中:

pod 'SGAlertController'
// 创建
[SGAlertController alertWithStyle:_style
title:@"语言选择"
message:@"请选择你最喜欢的语言!"
cancel:@"取消" sure:@""
settings:^(SGAlertController *alertView) {
// 修改显示样式
[alertView changTitleStyle:(ActionTitleStyleMake([UIColor randomColor], [UIFont boldSystemFontOfSize:20]))];
[alertView changMessageStyle:(ActionTitleStyleMake([UIColor randomColor], [UIFont systemFontOfSize:15]))];
[alertView changActionTitleColor:[UIColor redColor] actionTitle:@"Objective - C"];
[alertView changActionTitleColor:[UIColor yellowColor] index:5];
}
selectorAction:^(NSString *title, NSInteger index) {
if (index != 0) {
[_showBtn setTitle:title forState:(UIControlStateNormal)];
}
}
otherTitles:@"JavaScript", @"Objective - C",@"Java",@"Python",@"HTML",@"Ruby",@"C++", nil];

修改样式:

  • 修改标题
// 可使用 ActionTitleStyleMake() 传入
ActionTitleStyleMake([UIColor redColor], [UIFont boldSystemFontOfSize:20])
[alertView changMessageStyle:<#(ActionTitleStyle)#>]

// 可传入 AttributedString
[alertView changTitleAttributedString:]
  • 修改内容
// 可使用 ActionTitleStyleMake() 传入
ActionTitleStyleMake([UIColor redColor], [UIFont boldSystemFontOfSize:20])
[alertView changMessageStyle:<#(ActionTitleStyle)#>]

// 可传入 AttributedString
[alertView changMessageAttributedString:]
  • 修改某个 Action

在 present 之前修改 action 样式。使用 settings .

// 根据标题改变颜色
- (void)changActionTitleColor:(UIColor * _Nonnull)color actionTitle:(NSString *_Nonnull)title;

// 根据位置改变颜色
- (void)changActionTitleColor:(UIColor *)color index:(NSInteger)index;