SMAlertView 1.0.2

SMAlertView 1.0.2

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布上次发布2017年12月

liqingfa维护。



  • liqingfa

SMAlertView

Pod Version
Pod Platform
Pod License

SMAlertView是一个简洁易用的iOS AlertView。

SMAlert

安装

从CocoaPods

CocoaPods是一个Objective-C的依赖管理器,它自动化并简化了在项目中使用类似于SMAlertView的第三方库的过程。首先,将以下行添加到您的Podfile

pod 'SMAlertView', '~> 1.0.1'

然后,将SMAlertView安装到您的项目中

pod install

手动安装

AlertDemo/SMAlert文件夹拖入您的项目中。

使用方法

(请参阅SMAlertView中的示例Xcode项目)

SMAlertView以单例的形式创建(即不需要显式分配和初始化;直接调用[SMAlert method])。

显示AlertView

您可以使用以下任一方法只显示内容:

+ (void)showContent:(NSString*)content;
+ (void)showContent:(NSString*)content confirmButton:(SMButton*)confirmButton;
+ (void)showContent:(NSString*)content confirmButton:(SMButton*)confirmButton cancleButton:(SMButton*)cancleButton;

如果您想要带有图像的AlertView

+ (void)showImage:(UIImage*)image content:(NSString*)content;
+ (void)showImage:(UIImage*)image content:(NSString*)content confirmButton:(SMButton*)confirmButton;
+ (void)showImage:(UIImage*)image content:(NSString*)content confirmButton:(SMButton*)confirmButton cancleButton:(SMButton*)cancleButton;

此外,您还可以显示带有自定义视图的AlertView

+ (void)showCustomView:(UIView*)view;
+ (void)showCustomView:(UIView*)view confirmButton:(SMButton*)confirmButton;
+ (void)showCustomView:(UIView*)view confirmButton:(SMButton*)confirmButton cancleButton:(SMButton*)cancleButton;

关闭AlertView

可以使用以下方法关闭AlertView:

+(void)hide; 	//隐藏当前AlertView
+(void)hideAll; //隐藏当前AlertView并清空待显示队列

如果您想在AlertView隐藏完成后执行某些动作

+(void)hideCompletion:(void (^)(void))completion;

定制

SMAlertView可以通过以下方法进行定制:

+ (void)setFadeInAnimationDuration:(NSTimeInterval)duration;	// default is 0.15
+ (void)setFadeOutAnimationDuration:(NSTimeInterval)duration;	// default is 0.15
+ (void)setAlertBackgroundColor:(UIColor*)color;				// default is clear clolor
+ (void)setConfirmBtBackgroundColor:(UIColor*)color;			// default is white clolor
+ (void)setCancleBtBackgroundColor:(UIColor*)color;				// default is white clolor
+ (void)setConfirmBtTitleColor:(UIColor*)color;					// default is red clolor
+ (void)setCancleBtTitleColor:(UIColor*)color;					// default is blue clolor
+ (void)setContentTextColor:(UIColor*)color;					// default is black clolor
+ (void)setContentFont:(UIFont*)font;							// default is 15 
+ (void)setBtTitleFont:(UIFont*)font;							// default is 15 
+ (void)setContentLineSpace:(CGFloat)lineSpace;					// default is 4
+ (void)setTouchToHide:(BOOL)touchToHide;						// default is NO
+ (void)setContentTextAlignment:(NSTextAlignment)textAlignment;	// default is left

许可证

SMAlert遵守MIT许可证的条款和条件