GithubHelp home page GithubHelp logo

nealyoung / nyalertviewcontroller Goto Github PK

View Code? Open in Web Editor NEW
609.0 21.0 107.0 23.34 MB

Highly configurable iOS Alert Views with custom content views

License: MIT License

Objective-C 97.12% Ruby 1.19% Shell 1.69%

nyalertviewcontroller's Introduction

NYAlertViewController

NYAlertViewController is a replacement for UIAlertController/UIAlertView with support for content views and UI customization.

Example

Features

  • Includes content view property for adding custom views to the alert view
  • Block-based API similar to UIAlertController/UIAlertAction
  • Support for all screen orientations and iPad screen sizes
  • Easily add text fields with simple API identical to UIAlertController
  • Choose between fade (similar to UIAlertController) or slide transition animations

Installation

Manual

Add the files to your project manually by dragging the NYAlertViewController directory into your Xcode project.

CocoaPods

Add pod 'NYAlertViewController' to your Podfile, and run pod install.

Usage Example

An Objective-C example project demonstrating customization options is included in the NYAlertViewControllerDemo directory.

Objective-C

// Import the class and create an NYAlertViewController instance
#import "NYAlertViewController.h"

// ...

// Set a title and message
NSString *title = @"Location Permission";
NSString *message = @"Set the alertViewContentView property to add custom views to the alert view";

// Customize appearance as desired
NYAlertViewControllerConfiguration *configuration = [NYAlertViewControllerConfiguration new];
configuration.contentViewInset = UIEdgeInsetsMake(12.0f, 8.0f, 8.0f, 8.0f);
configuration.alertViewBackgroundColor = [UIColor colorWithRed:0.23f green:0.23f blue:0.27f alpha:1.0f];
configuration.separatorColor = [UIColor colorWithRed:0.16f green:0.16f blue:0.2f alpha:1.0f];
configuration.titleTextColor = [UIColor whiteColor];
configuration.messageTextColor = [UIColor whiteColor];

configuration.buttonConfiguration = [NYAlertActionConfiguration new];
configuration.buttonConfiguration.titleColor = [UIColor whiteColor];

configuration.cancelButtonConfiguration.titleColor = [UIColor whiteColor];

// Set up alert actions
NYAlertAction *cancelAction = [[NYAlertAction alloc] initWithTitle:@"Later"
                                                             style:UIAlertActionStyleCancel
                                                           handler:nil];
NYAlertAction *okAction = [[NYAlertAction alloc] initWithTitle:@"Ok"
                                                         style:UIAlertActionStyleDefault
                                                       handler:^(NYAlertAction *action) {
                                                           [self doSomething];
                                                       }]];

NYAlertViewController *alertViewController = [[NYAlertViewController alloc] initWithOptions:configuration
                                                                                      title:title
                                                                                    message:message
                                                                                    actions:@[cancelAction, okAction]];

// Optionally add a content view
UIImageView *iconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"MapIcon"]];
iconImageView.contentMode = UIViewContentModeScaleAspectFit;
[iconImageView.heightAnchor constraintEqualToConstant:60.0f].active = YES;
alertViewController.alertViewContentView = iconImageView;

// Present the alert view controller
[self presentViewController:alertViewController animated:YES completion:nil];

License

This project is released under the MIT License.

nyalertviewcontroller's People

Contributors

justinekay avatar nealyoung 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

nyalertviewcontroller's Issues

IOS7 cause AutoLayout issue!

ultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x14d9eeb0 V:|-(NSSpace(20))-[UILabel:0x14e71890] (Names: '|':UIView:0x14e717b0 )>",
"<NSLayoutConstraint:0x14d69fc0 V:[UILabel:0x14e71890]-(2)-[NYAlertTextView:0x15b68200]>",
"<NSLayoutConstraint:0x14d3e400 V:[NYAlertTextView:0x15b68200]-(0)-[UIView:0x14e7d1a0]>",
"<NSLayoutConstraint:0x14d78910 V:[UIView:0x14e7d1a0]-(0)-[UIView:0x14e71560]>",
"<NSLayoutConstraint:0x14db66b0 V:[UIView:0x14e71560]-(0)-[UIView:0x14e6fb90]>",
"<NSLayoutConstraint:0x14d72630 V:[UIView:0x14e6fb90]-(NSSpace(20))-| (Names: '|':UIView:0x14e717b0 )>",
"<NSLayoutConstraint:0x14e6fac0 UIView:0x14e717b0.height <= 0.9*NYAlertView:0x14e714a0.height>",
"<NSAutoresizingMaskLayoutConstraint:0x14dccaa0 h=--& v=--& V:[NYAlertView:0x14e714a0(0)]>"
)

iOS7 issue

It`s really nice project. but I run this demo use iOS7+ environment, it cause AutoLayout issue. please check it out.

How to set Text Alignment?

Hi,
Can someone tell me how to set text alignment on this control. I found it on line# 251 and line# 262 inn NYAlertView.m but want to do it from my ViewController because on some ViewControllers I want Left text alignment and in some ViewController I want center.

Button borderColor

First of all thanks for this masterpiece! It's by far the best i have ever seen. The only thing it's missing is the option to set the borderColor of the buttons in case you don't want to fill the button with the color. Is it easy to expose this property?

how to add custom view?

Hi, I read your demo, and still don't know how to add custom view.
Do I have to use Auto Layout?

Please add carthage support

Dependency "NYAlertViewController" has no shared framework schemes for any of the platforms: iOS

If you believe this to be an error, please file an issue with the maintainers at https://github.com/nealyoung/NYAlertViewController/issues/new

Podspec issue?

[!] Unable to satisfy the following requirements:

  • NYAlertViewController required by Podfile
  • NYAlertViewController required by Podfile
  • NYAlertViewController required by Podfile

Touch getting passed to Presenting VC

In some cases the touch is getting passed to the presenting viewController. the UI for the Alert becomes disabled and all interactions are passed to the the Presenting view controller in the background.

Not abe to understand why this is happening. Any Clues ?

How can we add UITableView as alertViewContentView?

Hi,

I have downloaded NYAlertViewController and able to run demo app with out any issue. I want to add UITableView as alertViewContentView, so can you please let me know is it possible?

Thanks,
Venkat.

Pod version 2.0.0 is not available

I tried updating to version 2.0.0 but Pod version is not available.
Can you please let me know if its still not released to Cocoapods.

And how can I use this library

Thanks

Make statusbar style adjustable

Since we already have the ability to determine whether the status bar is shown or not, I think it makes sense to also expose the statusbar style through the API.
You would just have one more property statusBarStyle that the client can set before presenting the view controller. This value would be returned in preferredStatusBarStyle. I would also default the statusBarStyle to .LightContent since the dark background has better contrast for a white font.

UITextfield covered by Keyboard

When the message is long,and there is a UITextField under it, the UITextField is covered by the keyboard. Is there a way to shift the UITextField to uncover it?

Cant make the alertViewContentView appear!

Hi guys,
I use NYAlertViewController through cocoa pods.

I can't get the contentView to work...
My code:
alertViewController.alertViewContentView = contentView

Could you please help me?

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.