/DTAlertView

Custom alert view solved the ios UIAlertView can't addSubview problem at iOS7.

Primary LanguageHTMLOtherNOASSERTION

DTAlertView

IMPORTANT: UIWindow appearance changed on iOS 8, I cant not fix it on landscape view.

So I will create a new one for iOS8.

Perview 1Perview 2

Custom alert view to solved the UIAlertView can't addSubview problem on iOS7.

NEW Feature:

New effect for show and dismiss animations.

  • DTAlertViewAnimationSlideTop

Slide to top

  • DTAlertViewAnimationSlideBottom

Slide to bottom

  • DTAlertViewAnimationSlideLeft

Slide to left

  • DTAlertViewAnimationSlideRight

Slide to right

And also can use different dismiss animation at click different button.

Use different animation

New method -showForPasswordInputWithAnimation: for input password scenario, and animation -shakeAlertView for password error scenario.

Password error

##ATTENTION##

  • This demo code create on Xcode 5.0, but probably have issues on Xcode 4 or less.
  • Demo code use at non-ARC mode, but DTAlertView main class support ARC and non-ARC mode.

##Q & A##

Q: How to hidden status bar when alert presented on iOS 7?

A: Set UIViewControllerBasedStatusBarAppearance to NO in your info.plist, the status bar won't appear again.

##Installation##

  1. Add QuartzCore framework.
  2. Drag the DTAlertView folder into your project.

##Usage##

Import the header file and declare in want to used class.

#import "DTAlertView.h"

###Initializing DTAlertView in your class:###

// initial for class method
DTAlertView *alertView = [DTAlertView alertViewWithTitle:@"Demo" message:@"This is normal alert view." delegate:nil cancelButtonTitle:@"Cancel" positiveButtonTitle:@"OK"];

// inital for instance method
DTAlertView *alertView = [[DTAlertView alloc] initWithTitle:@"Demo" message:@"This is normal alert view." delegate:nil cancelButtonTitle:@"Cancel" positiveButtonTitle:@"OK"];

and you can use Block with alert view:

DTAlertViewButtonClickedBlock block = ^(DTAlertView *_alertView, NSUInteger buttonIndex, NSUInteger cancelButtonIndex){
	// You can get button title of clicked button.
    NSLog(@"%@", _alertView.clickedButtonTitle);
};

DTAlertView *alertView = [DTAlertView alertViewUseBlock:block title:@"Demo" message:@"This is normal alert view with block." cancelButtonTitle:@"Cancel" positiveButtonTitle:nil];

###Show & dismiss:###

Show alert view:

[alertView show];

Dismiss alert view:

[alertView dismiss];

##Install Code Snippet## Copy codesnippet files under Code Snippet folder to ~/Library/Developer/Xcode/UserData/CodeSnippets/.

  • If your Xcode is opened, please quit Xcode and reopen Xcode

You can find code snippet at there.

Code Snippet

Or use key word DTAlertViewButtonClickedBlock or DTAlertViewTextDidChangeBlock.

Key Word

##Inatall Document Set##

###USE Xcode Documentation Viewer### Copy com.darktt.DTAlertView.docset file under Docset folder to ~/Library/Developer/Shared/Documentation/DocSets/.

  • If your Xcode is opened, please quit Xcode and reopen Xcode

You can find it in Documentation Viewer.

###Use Dash### Add com.darktt.DTAlertView.docset file under Docset folder on Dash preferences.

Dash preferences

##License## Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied.
See the License for the specific language governing permissions
and limitations under the License.