Skip to content

Commit

Permalink
V1.0 完善注释
Browse files Browse the repository at this point in the history
  • Loading branch information
kukumaluCN committed Dec 28, 2016
1 parent abca46a commit 968b2ca
Show file tree
Hide file tree
Showing 10 changed files with 251 additions and 156 deletions.
Binary file modified JXTAlertManagerDemo/.DS_Store
Binary file not shown.
14 changes: 0 additions & 14 deletions JXTAlertManagerDemo/JXTAlertManagerDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
A768DFA11E0A63BE005659B5 /* ShowViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A768DFA01E0A63BE005659B5 /* ShowViewController.m */; };
A768DFE51E0B7B67005659B5 /* JXTAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = A768DFE41E0B7B67005659B5 /* JXTAlertView.m */; };
A768E0121E0BBD6E005659B5 /* JXTAlertController.m in Sources */ = {isa = PBXBuildFile; fileRef = A768E0111E0BBD6E005659B5 /* JXTAlertController.m */; };
A768E0551E112AE4005659B5 /* JXTAlertManagerConstant.m in Sources */ = {isa = PBXBuildFile; fileRef = A768E0541E112AE4005659B5 /* JXTAlertManagerConstant.m */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -32,8 +31,6 @@
A768DFE41E0B7B67005659B5 /* JXTAlertView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JXTAlertView.m; sourceTree = "<group>"; };
A768E0101E0BBD6E005659B5 /* JXTAlertController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JXTAlertController.h; sourceTree = "<group>"; };
A768E0111E0BBD6E005659B5 /* JXTAlertController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JXTAlertController.m; sourceTree = "<group>"; };
A768E0531E112AE4005659B5 /* JXTAlertManagerConstant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JXTAlertManagerConstant.h; sourceTree = "<group>"; };
A768E0541E112AE4005659B5 /* JXTAlertManagerConstant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JXTAlertManagerConstant.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -91,7 +88,6 @@
isa = PBXGroup;
children = (
A768DFE01E0B7AF3005659B5 /* JXTAlertManagerHeader.h */,
A768E04C1E112A72005659B5 /* Base */,
A768DFE21E0B7B67005659B5 /* AlertView */,
A768DFE71E0B7B7C005659B5 /* AlertController */,
);
Expand All @@ -116,15 +112,6 @@
path = AlertController;
sourceTree = "<group>";
};
A768E04C1E112A72005659B5 /* Base */ = {
isa = PBXGroup;
children = (
A768E0531E112AE4005659B5 /* JXTAlertManagerConstant.h */,
A768E0541E112AE4005659B5 /* JXTAlertManagerConstant.m */,
);
path = Base;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -200,7 +187,6 @@
A768DF8A1E0A6388005659B5 /* main.m in Sources */,
A768DFE51E0B7B67005659B5 /* JXTAlertView.m in Sources */,
A768DFA11E0A63BE005659B5 /* ShowViewController.m in Sources */,
A768E0551E112AE4005659B5 /* JXTAlertManagerConstant.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file modified JXTAlertManagerDemo/JXTAlertManagerDemo/.DS_Store
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,41 +1,29 @@
//
// JXTAlertController.h
// JXTAlertManagerDemo
// JXTAlertManager
//
// Created by JXT on 2016/12/22.
// Copyright © 2016年 JXT. All rights reserved.
//

#import <UIKit/UIKit.h>

/**
* JXTAlertController简介:
1.针对系统UIAlertController封装,支持iOS8及以上
2.关于iOS9之后的`preferredAction`属性用法:
`alertController.preferredAction = alertController.actions[0];`
效果为将已存在的某个action字体加粗,原cancel样式的加粗字体成为deafult样式,cancel样式的action仍然排列在最下
总体意义不大,且仅限于`UIAlertControllerStyleAlert`,actionSheet无效,功能略微鸡肋,不再单独封装
3.关于`addTextFieldWithConfigurationHandler:`方法:
该方法同样仅限于`UIAlertControllerStyleAlert`使用,使用场景较为局限,推荐直接调用,不再针对封装
4.关于自定义按钮字体或者颜色,可以利用kvc间接访问这些私有属性,但是不推荐
`[alertAction setValue:[UIColor grayColor] forKey:@"titleTextColor"]`
*/


NS_ASSUME_NONNULL_BEGIN

#pragma mark - I.JXTAlertController构造

@class JXTAlertController;
//block
/**
JXTAlertController: alertAction配置链
@param title 标题
@return JXTAlertController对象
*/
typedef JXTAlertController * _Nonnull (^JXTAlertActionTitle)(NSString *title);

/**
alert按钮执行回调
JXTAlertController: alert按钮执行回调
@param buttonIndex 按钮index(根据添加action的顺序)
@param action UIAlertAction对象
Expand All @@ -44,32 +32,79 @@ typedef JXTAlertController * _Nonnull (^JXTAlertActionTitle)(NSString *title);
typedef void (^JXTAlertActionBlock)(NSInteger buttonIndex, UIAlertAction *action, JXTAlertController *alertSelf);


@interface JXTAlertController : UIAlertController
/**
JXTAlertController 简介:
1.针对系统UIAlertController封装,支持iOS8及以上
2.关于iOS9之后的`preferredAction`属性用法:
`alertController.preferredAction = alertController.actions[0];`
效果为将已存在的某个action字体加粗,原cancel样式的加粗字体成为deafult样式,cancel样式的action仍然排列在最下
总体意义不大,且仅限于`UIAlertControllerStyleAlert`,actionSheet无效,功能略微鸡肋,不再单独封装
3.关于`addTextFieldWithConfigurationHandler:`方法:
该方法同样仅限于`UIAlertControllerStyleAlert`使用,使用场景较为局限,推荐直接调用,不再针对封装
4.关于自定义按钮字体或者颜色,可以利用kvc间接访问这些私有属性,但是不推荐
`[alertAction setValue:[UIColor grayColor] forKey:@"titleTextColor"]`
*/
NS_CLASS_AVAILABLE_IOS(8_0) @interface JXTAlertController : UIAlertController

- (void)alertAnimateDisabled; //禁用alert弹出动画,默认执行系统的默认弹出动画

@property (nonatomic, copy) void (^alertDidShown)(); //alert弹出后,可配置的回调
@property (nonatomic, copy) void (^alertDidDismiss)();//alert关闭后,可配置的回调
/**
JXTAlertController: 禁用alert弹出动画,默认执行系统的默认弹出动画
*/
- (void)alertAnimateDisabled;

/**
JXTAlertController: alert弹出后,可配置的回调
*/
@property (nullable, nonatomic, copy) void (^alertDidShown)();

@property (nonatomic, assign) NSTimeInterval toastStyleDuration;//如果未添加任何按钮,将会以toast样式展示,这里设置展示时间,默认jxt_alertShowDurationDefault = 1s;
/**
JXTAlertController: alert关闭后,可配置的回调
*/
@property (nullable, nonatomic, copy) void (^alertDidDismiss)();

//添加一个alertAction按钮,参数为标题
- (JXTAlertActionTitle)addActionDefaultTitle; //默认样式
- (JXTAlertActionTitle)addActionCancelTitle; //取消样式,warning:该样式只能有一个!!!
- (JXTAlertActionTitle)addActionDestructiveTitle; //警告样式
/**
JXTAlertController: 设置toast模式展示时间:如果alert未添加任何按钮,将会以toast样式展示,这里设置展示时间,默认1s
*/
@property (nonatomic, assign) NSTimeInterval toastStyleDuration; //deafult jxt_alertShowDurationDefault = 1s


/**
JXTAlertController: 链式构造alert视图按钮,添加一个alertAction按钮,默认样式,参数为标题
@return JXTAlertController对象
*/
- (JXTAlertActionTitle)addActionDefaultTitle;

/**
JXTAlertController: 链式构造alert视图按钮,添加一个alertAction按钮,取消样式,参数为标题(warning:一个alert该样式只能添加一次!!!)
@return JXTAlertController对象
*/
- (JXTAlertActionTitle)addActionCancelTitle;

/**
JXTAlertController: 链式构造alert视图按钮,添加一个alertAction按钮,警告样式,参数为标题
@return JXTAlertController对象
*/
- (JXTAlertActionTitle)addActionDestructiveTitle;

@end


#pragma mark - II.UIViewController扩展使用JXTAlertController

//block
/**
JXTAlertController: alert构造块
@param alertMaker JXTAlertController配置对象
*/
typedef void(^JXTAlertAppearanceProcess)(JXTAlertController *alertMaker);

@interface UIViewController (JXTAlertController)

/**
展示alert
JXTAlertController: show-alert(iOS8)
@param title title
@param message message
Expand All @@ -82,7 +117,7 @@ typedef void(^JXTAlertAppearanceProcess)(JXTAlertController *alertMaker);
actionsBlock:(nullable JXTAlertActionBlock)actionBlock NS_AVAILABLE_IOS(8_0);

/**
展示actionSheet
JXTAlertController: show-actionSheet(iOS8)
@param title title
@param message message
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// JXTAlertController.m
// JXTAlertManagerDemo
// JXTAlertManager
//
// Created by JXT on 2016/12/22.
// Copyright © 2016年 JXT. All rights reserved.
Expand Down
Loading

0 comments on commit 968b2ca

Please sign in to comment.