SMAlertView 1.0.2

SMAlertView 1.0.2

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2017

Maintained by liqingfa.



  • By
  • liqingfa

SMAlertView

Pod Version
Pod Platform
Pod License

SMAlertView is a clean and easy-to-use AlertView on iOS.

SMAlert

Installation

From CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like SMAlertView in your projects. First, add the following line to your Podfile:

pod 'SMAlertView', '~> 1.0.1'

Second, install SMAlertView into your project:

pod install

Manually

Drag the AlertDemo/SMAlert folder into your project.

Usage

(see sample Xcode project in SMAlertView)

SMAlertView is created as a singleton (i.e. it doesn't need to be explicitly allocated and instantiated; you directly call [SMAlert method]).

Showing the AlertView

You can show content only using one of the following:

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

If you'd like the AlertView with an image:

+ (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;

In addition, you also can show the AlertView with a custom view:

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

Dismissing the AlertView

The AlertView can be dismissed using:

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

If you'd like to perform some action after the AlertView hide completion

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

Customization

SMAlertView can be customized via the following methods:

+ (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

License

SMAlert is distributed under the terms and conditions of the MIT license