Latest 0.1.0
Homepage https://github.com/zzdjk6/ZZCustomAlertView
License MIT
Platforms ios 8.0, requires ARC
Authors

CI Status
Version
License
Platform

ZZCustomAlertView is an ios alert view that you can totally customize it.

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Here is a brief introduction.

To generate and show a new plain ZZCustomAlertView, write:

ZZCustomAlertView *alert = [ZZCustomAlertView alertViewWithParentView:self.view andContentView:nil];
[alert show];

The code above give you an alert view like bellow, you can tap anywhere to dismiss it.

![ZZCustomAlertView Plain](./ZZCustomAlertView Plain.png)

Remember you should always give it a parentView. If you don’t give it a contentView, it will generate a plain default one.

To generate a customized ZZCustomAlertView, there is an example:

UIImage *img = [UIImage imageNamed:@"Perfect Button"];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(0, 0, img.size.width, img.size.height);
[btn setImage:img forState:UIControlStateNormal];
[btn addTarget:self action:@selector(customButtonPressed) forControlEvents:UIControlEventTouchUpInside];

ZZCustomAlertView *alert = [ZZCustomAlertView alertViewWithParentView:self.view andContentView:btn];
alert.shouldBlurBackground = YES;
alert.allowTapBackgroundToDismiss = NO;
alert.shadowColor = [UIColor whiteColor];
alert.shadowAlpha = 0.1f;
[alert show];

The code above just give you an alert view with a single image button, with blurred background, like bellow.

![ZZCustomeAlertView Customized](./ZZCustomeAlertView Customized.png)

There are some parameters you can use to customize ZZCustomAlertView, look at the header file and you can get all of them with detail comment.

/** If set to YES, the background will be blured, using iOS 8 VisualEffect, default is NO. */
@property(nonatomic, assign) BOOL shouldBlurBackground;

/** If set to YES, tap anywhere on the alert view (include background) will dismiss the alert view, default is YES. */
@property(nonatomic, assign) BOOL allowTapBackgroundToDismiss;

/** the alpha of the modal shadow, default is 0.3f. */
@property(nonatomic, assign) CGFloat shadowAlpha;

/** the color of the modal shadow, default is black. */
@property(nonatomic, strong) UIColor *shadowColor;

/** the content view of the alert view, you can put any view you write here. */
@property(nonatomic, strong) UIView *contentView;

/** the parent view of the alert view, you have to provide one. */
@property(nonatomic, strong) UIView *parentView;

And there are some methods to show and dismiss ZZCustomAlertView:

/**
 *  Show alert view.
 */
- (void)show;

/**
 *  Dismiss alert view.
 */
- (void)dismiss;

/**
 *  Show alert view with a block which will be executed when alert view finish show animation
 *
 *  @param completion A block which will be executed when alert view finish show animation
 */
- (void)showWithCompletionBlock:(void (^)(BOOL finished))completion;

/**
 *  Dismiss alert view with a block which will be executed when alert view finish dismiss animation
 *
 *  @param completion A block which will be executed when alert view finish dismiss animation
 */
- (void)dismissWithCompletionBlock:(void (^)(BOOL finished))completion;

You can get the alert view on present by call:

/**
 *  Get the alert view on present.
 *
 *  @return ZZCustomAlertView instance or nil.
 */
+ (instancetype)alertViewOnPresent;

Requirements

  • iOS 8 SDK
  • Use ARC

Installation

ZZCustomAlertView is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "ZZCustomAlertView"

Author

zzdjk6, [email protected]

License

ZZCustomAlertView is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "ZZCustomAlertView",
    "version": "0.1.0",
    "summary": "ZZCustomAlertView is an alert view that you can totally customize it.",
    "description": "ZZCustomAlertView is an alert view that you can totally customize it.nnvisit https://github.com/zzdjk6/ZZCustomAlertView for more details.n",
    "homepage": "https://github.com/zzdjk6/ZZCustomAlertView",
    "screenshots": [
        "https://github.com/zzdjk6/ZZCustomAlertView/raw/master/ZZCustomeAlertView%20Customized.png",
        "https://github.com/zzdjk6/ZZCustomAlertView/raw/master/ZZCustomAlertView%20Plain.png"
    ],
    "license": "MIT",
    "authors": {
        "zzdjk6": "[email protected]"
    },
    "source": {
        "git": "https://github.com/zzdjk6/ZZCustomAlertView.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "resource_bundles": {
        "ZZCustomAlertView": [
            "Pod/Assets/*.png"
        ]
    }
}

Pin It on Pinterest

Share This