Giter VIP home page Giter VIP logo

cxalertview's Introduction

CXAlertView

Sorry guys, I was busy in survival a startup last year. I will make an update ASAP. You can mail me if you have any thoughts about improvement.

Version 1.1.0

  • Replace LiveFrost by native blur function
  • Simulate appearance in iOS7.1
  • Bug fix

Version 1.0.1

You cannot customize the appearance of alert views.' - iOS 7 Design Resources

If you ever try to mess up with the UIAlertView, it is easy. Go to add at least five buttons on it. Therefore We change the layout with buttons.

This is a custom alert view developed by Chris Xu and enhanced by other contributors which allows you to following things

  • Show ios7 styled alerts in ios 5 and 6.

    ScreenShot 2

  • Unlike iOS 6 and below , on IOS 7 is non-customisable i.e., you can't modify to customise it. This alert allows you to Add view as you like in iOS7.

    ScreenShot 1

  • Multilined alert texts and button titles.

    Multilined Button Titles

  • Fully customizable alertview with interchangable colors,radiuses,fonts..etc.


Installation

  • CocoaPods add pod 'CXAlertView'

  • If using as a git submodule, you will also need to add LiveFrost

How to use


// Create
- (id)initWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle;
- (id)initWithTitle:(NSString *)title contentView:(UIView *)contentView cancelButtonTitle:(NSString *)cancelButtonTitle;
// Buttons
- (void)addButtonWithTitle:(NSString *)title type:(CXAlertViewButtonType)type handler:(CXAlertViewHandler)handler;
- (void)setDefaultButtonImage:(UIImage *)defaultButtonImage forState:(UIControlState)state NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;
// AlertView action
- (void)show;
- (void)dismiss;
// Operation
- (void)cleanAllPenddingAlert;
There are three parts of alertview, Top (Title View), Middle (Content View) and Bottom (Buttons Container).
  • showButtonLine show buttons dividing line.
  • showBlurBackground use blur background.

Next


  • Replace blur function by UIVisualEffect in iOS8
  • Bug fix.

Thanks


Support


  • Xcode 5
  • Framework : QuartzCore, Accelerate
  • ARC

Contact


Chris Xu

License


Copyright (c) 2013 Chris Xu, Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Bitdeli Badge

cxalertview's People

Contributors

bitdeli-chef avatar bryant1410 avatar christophercarranza avatar chrisxu avatar czeluff avatar heikkihautala avatar jonathanramirez avatar ki1l3r avatar mlilback avatar ran-ii avatar scottphc avatar skx926 avatar yam-liu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cxalertview's Issues

New version?

Hello,
Cloud you please release(tag) a new version and modify the cocoapods spec for it? The "newest" version released is 7 month ago!! We hope to enjoy this great tool via cocoapods and need a newer tag.
Thanks.

orientation bug iOS 8

I think the problem involves using

[UIScreen mainScreen].bounds]

when trying to determine the background's position and size, it's causing issues.

Issue getting only in iOS 9 above versions

I am entering some text in text field then after click on submit button (at that time key board is appeared).... after one alert view or custom alert will come.... But in ios 9 above versions popups(alert views, custom alerts) automatically disappeared

[CXAlertView dismiss] bug

Dear,
There is a bug after invoking [youCXAlertView dismiss], please see the detail below.

In the screenshot, you could see that there is still a CXAlertView on the top layer
receiving all touch events after invoking [youCXAlertView dismiss], which hangs up the app just like blocking the main-thread.

Revision:

My revision is 2014/03/28, downloaded from git repo directly.

Reproduce steps:

  1. press OK to login. The CXAlertView doesn't execute [cxAlertView dismiss] because giving by a wrong password.
  2. press Cancel.

Here is my code:

- (void)showLoginDialog:(NASServer *)targetNAS withResultBlock:(void(^)(BOOL success, NSError *e))loginResult{
    NSString *bundleName = @"ASViewController";
    ASViewController *loginViewController =[[[NSBundle mainBundle] loadNibNamed:bundleName
                                                                          owner:self
                                                                        options:nil] objectAtIndex:0];

    loginViewController.loginResultBlock = loginResult;
    loginViewController.targetNASServer = targetNAS;
    [CXAlertView showContentViewAlert:NSLocalizedString(@"PwdConfirm", nil)
                      withActionTitle:NSLocalizedString(@"OK", nil)
                      withContentView:loginViewController
                    withActionHandler:^(CXAlertView *alert, CXAlertButtonItem *btn){
                        QNVideoStationAPIManager *videoStation = [QNAPCommunicationManager share].videoStationManager;
                        [videoStation authLogin:loginViewController.usernameField.text
                                   withPassword:loginViewController.passwordField.text
                               withSuccessBlock:^(RKObjectRequestOperation *o, RKMappingResult *r){
                                   [alert dismiss];
                                   loginResult(YES, nil);
                               }
                               withFailureBlock:^(RKObjectRequestOperation *o, NSError *error){
                                   loginResult(NO, error);
                               }];
                    }];
}

+ (CXAlertView *)showContentViewAlert:(NSString *)title withActionTitle:(NSString *)actionTitle withContentView:(UIView *)contentView withActionHandler:(void(^)(CXAlertView *alert, CXAlertButtonItem *btn))cxHandler{
    CXAlertView *alert = [[CXAlertView alloc] initWithTitle:title
                                                contentView:contentView
                                          cancelButtonTitle:NSLocalizedString(@"Cancel", nil)];
    if (actionTitle != nil) {
        [alert addButtonWithTitle:actionTitle
                             type:CXAlertViewButtonTypeCustom
                          handler:^(CXAlertView *_alert, CXAlertButtonItem *btn){
                              cxHandler(_alert, btn);
                          }];
    }

    alert.cancelButtonFont = [UIFont systemFontOfSize:18.0f];
    alert.customButtonFont = [UIFont boldSystemFontOfSize:18.0f];
    alert.cancelButtonColor = [UIColor colorWithHexString:@"007aff" alpha:1.0f];
    alert.customButtonColor = [UIColor colorWithHexString:@"007aff" alpha:1.0f];

    [alert show];

    alert.showBlurBackground = NO;
    return alert;
}

2014-06-05 2 47 13

CXAlertBackgroundWindow.h

Im getting this error

CXAlertView/CXAlertBackgroundWindow.m:9:9: 'CXAlertBackgroundWindow.h' file not found

Frost background issue

Hello, I am showing this alert from a viewcontroller i pressented as modalview, but the frosted background is showing the root viewcontroller of the app, why?

thanks

possible to show images?

Hello
Is it possible to show images? I see the demo you have shows the image on click.

Thanks

Crashing on sharedQueue

Bad access on sharedQueue shows as cause of crash. I was able to fix this by changing the sharedQueue method to alloc and init the NSMutableArray. The nextAlertView in CXAlertView.m also causes a problem when there's not a next alert view because it's not initialized at all, just declared as CXAlertView *nextAlertView, so this also throws a bad access error unless it's allocated. When I resolved both of those things, there is no more crashing and the alert is dismissed properly when I hit the cancel button.

Here's my change to the sharedQueue method:

pragma mark - CXAlertView PV

  • (NSMutableArray *)sharedQueue
    {
    if (!__cx_pending_alert_queue) {
    NSMutableArray *array = [[NSMutableArray alloc] init];
    __cx_pending_alert_queue = array;
    }
    return __cx_pending_alert_queue;
    }

alert another cxalertview in button handler will make self.view unaccessable after dismiss this two alertview.

Just replace following code in your demo with this, and you can see how this bug come out.

- (IBAction)showCXAlert:(id)sender
{
    CXAlertView *alertViewMe = [[CXAlertView alloc] initWithTitle:defaultMessageTitle message:@"Something about me...." cancelButtonTitle:nil];
    [alertViewMe addButtonWithTitle:@"click me first"
                               type:CXAlertViewButtonTypeDefault
                            handler:^(CXAlertView *alertView, CXAlertButtonItem *button) {
                                [alertView dismiss];
                                [[[CXAlertView alloc] initWithTitle:@"Alert"
                                                            message:@"Notice that this alert view's background is darker(double gray) than the first one, and no dark background on self.view"
                                                  cancelButtonTitle:@"Dismiss"] show];
                            }];

    [alertViewMe addButtonWithTitle:@"click me"
                               type:CXAlertViewButtonTypeDefault
                            handler:^(CXAlertView *alertView, CXAlertButtonItem *button) {
                                [[[CXAlertView alloc] initWithTitle:@"Alert"
                                                            message:@"After you dismiss this alert view, the self.view can not be accessable, only change background view's alpha to 1 but not removed?"
                                                  cancelButtonTitle:@"Dismiss"] show];
                                [alertView dismiss];
                            }];

    [alertViewMe show];
}

Background Scrim is Too Far Right

Hey All,
Today I moved to xcode6 and to a landscape ipad app. This is the 1st time I have opened the alert from a smaller child viewcontroller. My launching viewcontroller is a drop down menu. The menu brings up the alert, but the background scrim for the alert is about 200 pixels to the right.

Have any of you seen this?
Joe

option to hide button container

i am using this view to display a progress bar, i don't want any buttons to close it. you should have the option to disable buttons altogether in this.

im hacking it right now by setting button container height to 0

UIAlertView on ios7 seems to not bold the cancel button

Is there a reason why you are bolding the cancel button?. Example:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil
message:@"Message"
delegate:nil
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Ok",nil];

LiveFrost dependency

hi,
it's a problem with the podspec of this library. It doesn't contain the LiveFrost dependency.

main thread blocking

when i use it like this,
CXAlertView * alert=[[CXAlertView alloc] initWithTitle:@"warning" message:message cancelButtonTitle:@"cancel"];
[alert addButtonWithTitle:@"continue" type:CXAlertViewButtonTypeDefault handler:^(CXAlertView *alertView, CXAlertButtonItem *button) {
CXAlertView * secondeAlertView=[[CXAlertView alloc] initWithTitle:@"XX" message:@"xxxxxxxxxxxx" cancelButtonTitle:@"sure"];
[secondeAlertView show];
[alertView dismiss];
}];

when i click 'sure' button , the main thread is blocking. i can't touch my view any more!
can you fix the bug ?

Update release to 1.1.0

Pod is still referring to an older version, please update this so cocoa pods users can access the latest changes.

When string length is too long, view does not grow

I have a situation where I have an image set as the contentView and a string above it. when the string is too long, the image is hiding the text, instead of being below it, and having the container view grow.

CXAlertViewController force showing status bar

Hello,

I'm showing CXAlertView inside a Controller that hides status bar.

when alert is shown, status bar appears. I think the problem is that CXAlertViewController is not declaring anything about the new iOS7 code for status bar.

How to force status bar to be as main controller has requested?

Many thanks,
Daniele

IOS 7 deprecated warning

Hi,

First thanks for such class. I have a warning in xcode 5.1.1 saying :

CXAlertView.m:754:29: 'sizeWithFont:constrainedToSize:lineBreakMode:' is deprecated: first deprecated in iOS 7.0 - Use -boundingRectWithSize:options:attributes:context:

Regards

CGContext 0x0 issue

hi ~

I found there has some warning when running on iOS6 and iOS7 ,

I think the problem is in the

LFGlassView.m Line No. 197

[self.blurSuperView.layer renderInContext:effectInContext];

I think it should be check it before use it.

thanks

Add access to alertview buttons

In my project I use -[UIView accessibilityLabel] for ui testing. But, unfortunately, I cannot set the label for alertView buttons.

I see two possible solutions:

  1. Add @property (nonatomic, readonly) NSArray *buttons to the class interface.
  2. Change return type of - (void)addButton... to - (void)addButton.... But default button options will be still unavailable.

What do you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.