Custom alert view to solved the UIAlertView can't addSubview problem on iOS7.
NEW Feature:
New effect for show and dismiss animations.
- DTAlertViewAnimationSlideTop
- DTAlertViewAnimationSlideBottom
- DTAlertViewAnimationSlideLeft
- DTAlertViewAnimationSlideRight
And also can use different dismiss animation at click different button.
New method -showForPasswordInputWithAnimation: for input password scenario, and animation -shakeAlertView for password error scenario.
##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##
- Add
QuartzCore
framework. - 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.
Or use key word DTAlertViewButtonClickedBlock
or DTAlertViewTextDidChangeBlock
.
##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.
##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
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.