├── .gitignore ├── CNPPopupController.podspec ├── CNPPopupController ├── CNPPopupController.h └── CNPPopupController.m ├── CNPPopupControllerExample.xcodeproj ├── project.pbxproj └── xcshareddata │ └── xcschemes │ └── CNPPopupControllerExample.xcscheme ├── CNPPopupControllerExample ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── LaunchImage.launchimage │ │ └── Contents.json │ ├── icon.imageset │ │ ├── Contents.json │ │ └── icon.pdf │ └── sad-cat-8.imageset │ │ ├── Contents.json │ │ └── sad-cat-8.jpg ├── Info.plist ├── ViewController.h ├── ViewController.m ├── demo.gif └── main.m ├── CNPPopupControllerExampleTests ├── CNPPopupControllerExampleTests.m └── Info.plist ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | *.xcworkspace 13 | !default.xcworkspace 14 | xcuserdata 15 | profile 16 | *.moved-aside 17 | DerivedData 18 | .idea/ 19 | /Pods 20 | -------------------------------------------------------------------------------- /CNPPopupController.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint CNPPopupController.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | s.name = "CNPPopupController" 19 | s.version = "0.1.2" 20 | s.summary = "A versatile popup for iOS" 21 | 22 | s.description = <<-DESC 23 | CNPPopupController is a simple and versatile class for presenting a custom popup in a variety of fashions. 24 | It includes a many options for controlling how your popup appears and behaves. 25 | 26 | * Think: Why did you write this? What is the focus? What does it do? 27 | * CocoaPods will be using this to generate tags, and improve search results. 28 | * Try to keep it short, snappy and to the point. 29 | * Finally, don't worry about the indent, CocoaPods strips it! 30 | DESC 31 | 32 | s.homepage = "https://github.com/carsonperrotti/CNPPopupController" 33 | s.screenshots = "https://raw.githubusercontent.com/carsonperrotti/CNPPopupController/master/CNPPopupControllerExample/CNPPopupController.gif" 34 | 35 | 36 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 37 | # 38 | # Licensing your code is important. See http://choosealicense.com for more info. 39 | # CocoaPods will detect a license file if there is a named LICENSE* 40 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 41 | # 42 | 43 | s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" } 44 | 45 | 46 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 47 | # 48 | # Specify the authors of the library, with email addresses. Email addresses 49 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 50 | # accepts just a name if you'd rather not provide an email address. 51 | # 52 | # Specify a social_media_url where others can refer to, for example a twitter 53 | # profile URL. 54 | # 55 | 56 | # s.author = { "Carson Perrotti" => "carsonperrotti@gmail.com" } 57 | s.author = "Carson Perrotti" 58 | # s.authors = { "Carson Perrotti" => "carsonperrotti@gmail.com" } 59 | # s.social_media_url = "http://twitter.com/Carson Perrotti" 60 | 61 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 62 | # 63 | # If this Pod runs only on iOS or OS X, then specify the platform and 64 | # the deployment target. You can optionally include the target after the platform. 65 | # 66 | 67 | s.platform = :ios, "7.0" 68 | 69 | # When using multiple platforms 70 | # s.ios.deployment_target = "5.0" 71 | # s.osx.deployment_target = "10.7" 72 | 73 | 74 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 75 | # 76 | # Specify the location from where the source should be retrieved. 77 | # Supports git, hg, bzr, svn and HTTP. 78 | # 79 | 80 | s.source = { :git => "https://github.com/carsonperrotti/CNPPopupController.git", :tag => "0.1.2" } 81 | 82 | 83 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 84 | # 85 | # CocoaPods is smart about how it includes source code. For source files 86 | # giving a folder will include any h, m, mm, c & cpp files. For header 87 | # files it will include any header in the folder. 88 | # Not including the public_header_files will make all headers public. 89 | # 90 | 91 | s.source_files = "CNPPopupController", "CNPPopupController/*.{h,m}" 92 | # s.public_header_files = "Classes/**/*.h" 93 | 94 | 95 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 96 | # 97 | # A list of resources included with the Pod. These are copied into the 98 | # target bundle with a build phase script. Anything else will be cleaned. 99 | # You can preserve files from being cleaned, please don't preserve 100 | # non-essential files like tests, examples and documentation. 101 | # 102 | 103 | # s.resource = "icon.png" 104 | # s.resources = "Resources/*.png" 105 | 106 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave" 107 | 108 | 109 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 110 | # 111 | # Link your library with frameworks, or libraries. Libraries do not include 112 | # the lib prefix of their name. 113 | # 114 | 115 | s.framework = "UIKit" 116 | # s.frameworks = "SomeFramework", "AnotherFramework" 117 | 118 | # s.library = "iconv" 119 | # s.libraries = "iconv", "xml2" 120 | 121 | 122 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 123 | # 124 | # If your library depends on compiler flags you can set them in the xcconfig hash 125 | # where they will only apply to your library. If you depend on other Podspecs 126 | # you can include multiple dependencies to ensure it works. 127 | 128 | s.requires_arc = true 129 | 130 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 131 | 132 | end 133 | -------------------------------------------------------------------------------- /CNPPopupController/CNPPopupController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CNPPopupController.h 3 | // CNPPopupController 4 | // 5 | // Created by Carson Perrotti on 2014-09-28. 6 | // Copyright (c) 2014 Carson Perrotti. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #define UIColorFromRGB(rgbValue) \ 12 | [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \ 13 | green:((float)((rgbValue & 0x00FF00) >> 8))/255.0 \ 14 | blue:((float)((rgbValue & 0x0000FF) >> 0))/255.0 \ 15 | alpha:1.0] 16 | 17 | @protocol CNPPopupControllerDelegate; 18 | @class CNPPopupTheme, CNPPopupButtonItem; 19 | 20 | @interface CNPPopupController : NSObject 21 | 22 | @property (nonatomic, strong) NSAttributedString *popupTitle; 23 | @property (nonatomic, strong) NSArray *contents; 24 | @property (nonatomic, strong) NSArray *buttonItems; 25 | @property (nonatomic, strong) CNPPopupButtonItem *destructiveButtonItem; 26 | @property (nonatomic, strong) CNPPopupTheme *theme; 27 | 28 | @property (nonatomic, weak) id delegate; 29 | 30 | - (instancetype)initWithTitle:(NSAttributedString *)popupTitle 31 | contents:(NSArray *)contents 32 | buttonItems:(NSArray *)buttonItems 33 | destructiveButtonItem:(CNPPopupButtonItem *)destructiveButtonItem; 34 | 35 | - (void)presentPopupControllerAnimated:(BOOL)flag; 36 | - (void)dismissPopupControllerAnimated:(BOOL)flag; 37 | 38 | @end 39 | 40 | @protocol CNPPopupControllerDelegate 41 | 42 | @optional 43 | - (void)popupControllerWillPresent:(CNPPopupController *)controller; 44 | - (void)popupControllerDidPresent:(CNPPopupController *)controller; 45 | - (void)popupController:(CNPPopupController *)controller willDismissWithButtonTitle:(NSString *)title; 46 | - (void)popupController:(CNPPopupController *)controller didDismissWithButtonTitle:(NSString *)title; 47 | 48 | @end 49 | 50 | // CNPPopupStyle: Controls how the popup looks once presented 51 | typedef NS_ENUM(NSUInteger, CNPPopupStyle) { 52 | CNPPopupStyleActionSheet = 0, // Displays the popup similar to an action sheet from the bottom. 53 | CNPPopupStyleCentered, // Displays the popup in the center of the screen. 54 | CNPPopupStyleFullscreen // Displays the popup similar to a fullscreen viewcontroller. 55 | }; 56 | 57 | // CNPPopupPresentationStyle: Controls how the popup is presented 58 | typedef NS_ENUM(NSInteger, CNPPopupPresentationStyle) { 59 | CNPPopupPresentationStyleFadeIn = 0, 60 | CNPPopupPresentationStyleSlideInFromTop, 61 | CNPPopupPresentationStyleSlideInFromBottom, 62 | CNPPopupPresentationStyleSlideInFromLeft, 63 | CNPPopupPresentationStyleSlideInFromRight 64 | }; 65 | 66 | // CNPPopupMaskType 67 | typedef NS_ENUM(NSInteger, CNPPopupMaskType) { 68 | CNPPopupMaskTypeNone = 0, // Allow interaction with underlying views. 69 | CNPPopupMaskTypeClear, // Don't allow interaction with underlying views. 70 | CNPPopupMaskTypeDimmed, // Don't allow interaction with underlying views, dim background. 71 | }; 72 | 73 | typedef void(^SelectionHandler) (CNPPopupButtonItem *item); 74 | 75 | @interface CNPPopupButtonItem : NSObject 76 | 77 | @property (nonatomic, strong) NSAttributedString *buttonTitle; 78 | @property (nonatomic, strong) UIColor *backgroundColor; 79 | @property (nonatomic, strong) UIColor *borderColor; 80 | @property (nonatomic, assign) CGFloat borderWidth; 81 | @property (nonatomic, assign) CGFloat cornerRadius; 82 | @property (nonatomic, assign) CGFloat buttonHeight; 83 | @property (nonatomic, strong) SelectionHandler selectionHandler; 84 | 85 | + (CNPPopupButtonItem *)defaultButtonItemWithTitle:(NSAttributedString *)title backgroundColor:(UIColor *)color; 86 | 87 | @end 88 | 89 | @interface CNPPopupTheme : NSObject 90 | 91 | @property (nonatomic, strong) UIColor *backgroundColor; // Background color of the popup content view (Default white) 92 | @property (nonatomic, assign) CGFloat cornerRadius; // Corner radius of the popup content view (Default 6.0) 93 | @property (nonatomic, assign) UIEdgeInsets popupContentInsets; // Inset of labels, images and buttons on the popup content view (Default 16.0 on all sides) 94 | @property (nonatomic, assign) CNPPopupStyle popupStyle; // How the popup looks once presented (Default centered) 95 | @property (nonatomic, assign) CNPPopupPresentationStyle presentationStyle; // How the popup is presented (Defauly slide in from bottom) 96 | @property (nonatomic, assign) BOOL dismissesOppositeDirection; // If presented from a direction, should it dismiss in the opposite? (Defaults to NO. i.e. Goes back the way it came in) 97 | @property (nonatomic, assign) CNPPopupMaskType maskType; // Backgound mask of the popup (Default dimmed) 98 | @property (nonatomic, assign) BOOL shouldDismissOnBackgroundTouch; // Popup should dismiss on tapping on background mask (Default yes) 99 | @property (nonatomic, assign) CGFloat contentVerticalPadding; // Spacing between each vertical element (Default 12.0) 100 | 101 | // Factory method to help build a default theme 102 | + (CNPPopupTheme *)defaultTheme; 103 | 104 | @end 105 | -------------------------------------------------------------------------------- /CNPPopupController/CNPPopupController.m: -------------------------------------------------------------------------------- 1 | // 2 | // CNPPopupController.m 3 | // CNPPopupController 4 | // 5 | // Created by Carson Perrotti on 2014-09-28. 6 | // Copyright (c) 2014 Carson Perrotti. All rights reserved. 7 | // 8 | 9 | #import "CNPPopupController.h" 10 | #import 11 | 12 | #define CNP_SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) 13 | #define CNP_IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 14 | 15 | typedef struct { 16 | CGFloat top; 17 | CGFloat bottom; 18 | } CNPTopBottomPadding; 19 | 20 | extern CNPTopBottomPadding CNPTopBottomPaddingMake(CGFloat top, CGFloat bottom) { 21 | CNPTopBottomPadding padding; 22 | padding.top = top; 23 | padding.bottom = bottom; 24 | return padding; 25 | }; 26 | 27 | @interface CNPPopupButton : UIButton 28 | 29 | @property (nonatomic, strong) CNPPopupButtonItem *item; 30 | 31 | @end 32 | 33 | @interface CNPPopupController () 34 | 35 | @property (nonatomic, strong) UIView *maskView; 36 | @property (nonatomic, strong) UIView *contentView; 37 | @property (nonatomic, strong) UIWindow *applicationKeyWindow; 38 | @property (nonatomic, strong) UITapGestureRecognizer *backgroundDismissGesture; 39 | 40 | @property (nonatomic, strong) NSLayoutConstraint *contentViewCenterXConstraint; 41 | @property (nonatomic, strong) NSLayoutConstraint *contentViewCenterYConstraint; 42 | @property (nonatomic, strong) NSLayoutConstraint *contentViewWidth; 43 | @property (nonatomic, strong) NSLayoutConstraint *contentViewHeight; 44 | @property (nonatomic, strong) NSLayoutConstraint *contentViewBottom; 45 | 46 | @end 47 | 48 | @implementation CNPPopupController 49 | 50 | - (instancetype)initWithTitle:(NSAttributedString *)popupTitle 51 | contents:(NSArray *)contents 52 | buttonItems:(NSArray *)buttonItems 53 | destructiveButtonItem:(CNPPopupButtonItem *)destructiveButtonItem { 54 | self = [super init]; 55 | if (self) { 56 | _popupTitle = popupTitle; 57 | _contents = contents; 58 | _buttonItems = buttonItems; 59 | _destructiveButtonItem = destructiveButtonItem; 60 | 61 | // Safety Checks 62 | if (contents) { 63 | for (id object in contents) { 64 | NSAssert([object class] != [NSAttributedString class] || [object class] != [UIImage class],@"Contents can only be of NSAttributedString or UIImage class."); 65 | } 66 | } 67 | if (buttonItems) { 68 | for (id object in buttonItems) { 69 | NSAssert([object class] == [CNPPopupButtonItem class],@"Button items can only be of CNPPopupButtonItem."); 70 | } 71 | } 72 | 73 | // Window setup 74 | NSEnumerator *frontToBackWindows = [[[UIApplication sharedApplication] windows] reverseObjectEnumerator]; 75 | for (UIWindow *window in frontToBackWindows) { 76 | if (window.windowLevel == UIWindowLevelNormal) { 77 | self.applicationKeyWindow = window; 78 | break; 79 | } 80 | } 81 | 82 | if (CNP_SYSTEM_VERSION_LESS_THAN(@"8.0")) { 83 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameOrOrientationChanged:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; 84 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameOrOrientationChanged:) name:UIApplicationDidChangeStatusBarFrameNotification object:nil]; 85 | } 86 | } 87 | return self; 88 | } 89 | 90 | -(void)dealloc { 91 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 92 | } 93 | 94 | #pragma mark - Touch Handling 95 | 96 | - (void)setUpPopup { 97 | 98 | // Set up mask view 99 | self.maskView = [[UIView alloc] init]; 100 | [self.maskView setTranslatesAutoresizingMaskIntoConstraints:NO]; 101 | self.maskView.alpha = 0.0; 102 | 103 | if (self.theme.shouldDismissOnBackgroundTouch) { 104 | self.backgroundDismissGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapOnMaskView)]; 105 | self.backgroundDismissGesture.numberOfTapsRequired = 1; 106 | [self.maskView addGestureRecognizer:self.backgroundDismissGesture]; 107 | } 108 | 109 | [self.applicationKeyWindow addSubview:self.maskView]; 110 | [self.applicationKeyWindow addConstraint:[NSLayoutConstraint constraintWithItem:self.maskView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.applicationKeyWindow attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]]; 111 | [self.applicationKeyWindow addConstraint:[NSLayoutConstraint constraintWithItem:self.maskView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.applicationKeyWindow attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0]]; 112 | [self.applicationKeyWindow addConstraint:[NSLayoutConstraint constraintWithItem:self.maskView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.applicationKeyWindow attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]]; 113 | [self.applicationKeyWindow addConstraint:[NSLayoutConstraint constraintWithItem:self.maskView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.applicationKeyWindow attribute:NSLayoutAttributeRight multiplier:1.0 constant:0]]; 114 | 115 | if (self.theme.popupStyle == CNPPopupStyleFullscreen) { 116 | self.maskView.backgroundColor = [UIColor whiteColor]; 117 | } 118 | else { 119 | if (self.theme.maskType == CNPPopupMaskTypeDimmed) { 120 | self.maskView.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.7f]; 121 | } else { 122 | self.maskView.backgroundColor = [UIColor clearColor]; 123 | } 124 | } 125 | 126 | self.contentView = [[UIView alloc] init]; 127 | [self.contentView setTranslatesAutoresizingMaskIntoConstraints:NO]; 128 | self.contentView.clipsToBounds = YES; 129 | self.contentView.backgroundColor = self.theme.backgroundColor; 130 | self.contentView.layer.cornerRadius = self.theme.popupStyle == CNPPopupStyleCentered ? self.theme.cornerRadius : 0.0f; 131 | [self.maskView addSubview:self.contentView]; 132 | 133 | 134 | if (self.popupTitle) { 135 | UILabel *title = [self multilineLabelWithAttributedString:self.popupTitle]; 136 | [self.contentView addSubview:title]; 137 | } 138 | 139 | if (self.contents) { 140 | for (NSObject *content in self.contents) { 141 | if ([content isKindOfClass:[NSAttributedString class]]) { 142 | UILabel *label = [self multilineLabelWithAttributedString:(NSAttributedString *)content]; 143 | [self.contentView addSubview:label]; 144 | } 145 | else if ([content isKindOfClass:[UIImage class]]) { 146 | UIImageView *imageView = [self centeredImageViewForImage:(UIImage *)content]; 147 | [imageView sizeToFit]; 148 | [self.contentView addSubview:imageView]; 149 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:imageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationLessThanOrEqual toItem:imageView attribute:NSLayoutAttributeWidth multiplier:1.0 constant:-60]]; 150 | } 151 | } 152 | } 153 | 154 | if (self.buttonItems) { 155 | for (CNPPopupButtonItem *item in self.buttonItems) { 156 | CNPPopupButton *button = [self buttonItem:item]; 157 | [self.contentView addSubview:button]; 158 | } 159 | } 160 | 161 | [self.contentView.subviews enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { 162 | if (idx == 0) { 163 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:self.theme.popupContentInsets.top]]; 164 | } 165 | else { 166 | UIView *previousSubView = [self.contentView.subviews objectAtIndex:idx - 1]; 167 | if (previousSubView) { 168 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:previousSubView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:self.theme.contentVerticalPadding]]; 169 | } 170 | } 171 | 172 | if (idx == self.contentView.subviews.count - 1) { 173 | 174 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-(self.theme.popupContentInsets.bottom + (self.destructiveButtonItem ? self.destructiveButtonItem.buttonHeight : 0.0f))]]; 175 | } 176 | 177 | if ([view isKindOfClass:[UIButton class]]) { 178 | CNPPopupButton *button = (CNPPopupButton *)view; 179 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:button.item.buttonHeight]]; 180 | [button addTarget:self action:@selector(actionButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; 181 | } 182 | 183 | [view setContentHuggingPriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisVertical]; 184 | [view setContentHuggingPriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal]; 185 | 186 | if ([view isKindOfClass:[UIImageView class]]) { 187 | [view setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal]; 188 | [view setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisVertical]; 189 | } 190 | else { 191 | [view setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal]; 192 | [view setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisVertical]; 193 | } 194 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:self.theme.popupContentInsets.left]]; 195 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-self.theme.popupContentInsets.right]]; 196 | }]; 197 | 198 | if (self.destructiveButtonItem) { 199 | CNPPopupButton *destructiveButton = [self buttonItem:self.destructiveButtonItem]; 200 | [self.contentView addSubview:destructiveButton]; 201 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:destructiveButton attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:self.destructiveButtonItem.buttonHeight]]; 202 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:destructiveButton attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0]]; 203 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:destructiveButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]]; 204 | [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:destructiveButton attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0]]; 205 | [destructiveButton addTarget:self action:@selector(actionButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; 206 | } 207 | 208 | [self.maskView addConstraint:[NSLayoutConstraint constraintWithItem:self.contentView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationLessThanOrEqual toItem:self.maskView attribute:NSLayoutAttributeHeight multiplier:1.0 constant:0]]; 209 | [self.maskView addConstraint:[NSLayoutConstraint constraintWithItem:self.contentView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationLessThanOrEqual toItem:self.maskView attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0]]; 210 | 211 | if (self.theme.popupStyle == CNPPopupStyleFullscreen) { 212 | self.contentViewWidth = [NSLayoutConstraint constraintWithItem:self.contentView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.maskView attribute:NSLayoutAttributeWidth multiplier:CNP_IS_IPAD?0.5:1.0 constant:0]; 213 | [self.maskView addConstraint:self.contentViewWidth]; 214 | self.contentViewCenterYConstraint = [NSLayoutConstraint constraintWithItem:self.contentView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.maskView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]; 215 | [self.maskView addConstraint:self.contentViewCenterYConstraint]; 216 | self.contentViewCenterXConstraint = [NSLayoutConstraint constraintWithItem:self.contentView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.maskView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]; 217 | [self.maskView addConstraint:self.contentViewCenterXConstraint]; 218 | } 219 | else if (self.theme.popupStyle == CNPPopupStyleActionSheet) { 220 | self.contentViewHeight = [NSLayoutConstraint constraintWithItem:self.contentView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.maskView attribute:NSLayoutAttributeWidth multiplier:CNP_IS_IPAD?0.5:1.0 constant:0]; 221 | [self.maskView addConstraint:self.contentViewHeight]; 222 | self.contentViewBottom = [NSLayoutConstraint constraintWithItem:self.contentView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.maskView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]; 223 | [self.maskView addConstraint:self.contentViewBottom]; 224 | self.contentViewCenterXConstraint = [NSLayoutConstraint constraintWithItem:self.contentView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.maskView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]; 225 | [self.maskView addConstraint:self.contentViewCenterXConstraint]; 226 | } 227 | else { 228 | if (CNP_IS_IPAD) { 229 | self.contentViewWidth = [NSLayoutConstraint constraintWithItem:self.contentView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.maskView attribute:NSLayoutAttributeWidth multiplier:0.4 constant:0]; 230 | } 231 | else { 232 | self.contentViewWidth = [NSLayoutConstraint constraintWithItem:self.contentView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.maskView attribute:NSLayoutAttributeWidth multiplier:1.0 constant:-140]; 233 | } 234 | [self.maskView addConstraint:self.contentViewWidth]; 235 | self.contentViewCenterYConstraint = [NSLayoutConstraint constraintWithItem:self.contentView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.maskView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]; 236 | [self.maskView addConstraint:self.contentViewCenterYConstraint]; 237 | self.contentViewCenterXConstraint = [NSLayoutConstraint constraintWithItem:self.contentView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.maskView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]; 238 | [self.maskView addConstraint:self.contentViewCenterXConstraint]; 239 | } 240 | 241 | } 242 | 243 | - (void)actionButtonPressed:(CNPPopupButton *)sender { 244 | if (sender.item.selectionHandler) { 245 | sender.item.selectionHandler(sender.item); 246 | } 247 | [self dismissPopupControllerAnimated:YES withButtonTitle:[sender attributedTitleForState:UIControlStateNormal].string]; 248 | } 249 | 250 | - (void)didTapOnMaskView { 251 | if (self.theme.shouldDismissOnBackgroundTouch) { 252 | [self dismissPopupControllerAnimated:YES withButtonTitle:nil]; 253 | } 254 | } 255 | 256 | #pragma mark - Presentation 257 | 258 | - (void)presentPopupControllerAnimated:(BOOL)flag { 259 | 260 | 261 | // Safety Checks 262 | NSAssert(self.theme!=nil,@"You must set a theme. You can use [CNPTheme defaultTheme] as a starting place"); 263 | [self setUpPopup]; 264 | if (CNP_SYSTEM_VERSION_LESS_THAN(@"8.0")) { 265 | [self rotateAccordingToStatusBarOrientationAndSupportedOrientations]; 266 | } 267 | [self setDismissedConstraints]; 268 | [self.maskView needsUpdateConstraints]; 269 | [self.maskView layoutIfNeeded]; 270 | [self setPresentedConstraints]; 271 | 272 | if ([self.delegate respondsToSelector:@selector(popupControllerWillPresent:)]) { 273 | [self.delegate popupControllerWillPresent:self]; 274 | } 275 | 276 | [UIView animateWithDuration:flag ? 0.3f : 0.0f 277 | delay:0 278 | options:UIViewAnimationOptionCurveEaseInOut 279 | animations:^{ 280 | self.maskView.alpha = 1.0f; 281 | [self.maskView needsUpdateConstraints]; 282 | [self.maskView layoutIfNeeded]; 283 | } 284 | completion:^(BOOL finished) { 285 | if ([self.delegate respondsToSelector:@selector(popupControllerDidPresent:)]) { 286 | [self.delegate popupControllerDidPresent:self]; 287 | } 288 | }]; 289 | } 290 | 291 | - (void)dismissPopupControllerAnimated:(BOOL)flag { 292 | [self dismissPopupControllerAnimated:flag withButtonTitle:nil]; 293 | } 294 | 295 | - (void)dismissPopupControllerAnimated:(BOOL)flag withButtonTitle:(NSString *)title { 296 | 297 | if (self.theme.dismissesOppositeDirection) { 298 | [self setDismissedConstraints]; 299 | } else { 300 | [self setOriginConstraints]; 301 | } 302 | 303 | if ([self.delegate respondsToSelector:@selector(popupController:willDismissWithButtonTitle:)]) { 304 | [self.delegate popupController:self willDismissWithButtonTitle:title]; 305 | } 306 | 307 | [UIView animateWithDuration:flag ? 0.3f : 0.0f 308 | delay:0 309 | options:UIViewAnimationOptionCurveEaseInOut 310 | animations:^{ 311 | self.maskView.alpha = 0.0f; 312 | [self.maskView needsUpdateConstraints]; 313 | [self.maskView layoutIfNeeded]; 314 | } 315 | completion:^(BOOL finished) { 316 | [self.maskView removeFromSuperview]; 317 | self.maskView = nil; 318 | self.contentView = nil; 319 | if ([self.delegate respondsToSelector:@selector(popupController:didDismissWithButtonTitle:)]) { 320 | [self.delegate popupController:self didDismissWithButtonTitle:title]; 321 | } 322 | }]; 323 | } 324 | 325 | - (void)setOriginConstraints { 326 | 327 | if (self.theme.popupStyle == CNPPopupStyleCentered) { 328 | switch (self.theme.presentationStyle) { 329 | case CNPPopupPresentationStyleFadeIn: 330 | self.contentViewCenterYConstraint.constant = 0; 331 | self.contentViewCenterXConstraint.constant = 0; 332 | break; 333 | case CNPPopupPresentationStyleSlideInFromTop: 334 | self.contentViewCenterYConstraint.constant = -self.applicationKeyWindow.bounds.size.height; 335 | self.contentViewCenterXConstraint.constant = 0; 336 | break; 337 | case CNPPopupPresentationStyleSlideInFromBottom: 338 | self.contentViewCenterYConstraint.constant = self.applicationKeyWindow.bounds.size.height; 339 | self.contentViewCenterXConstraint.constant = 0; 340 | break; 341 | case CNPPopupPresentationStyleSlideInFromLeft: 342 | self.contentViewCenterYConstraint.constant = 0; 343 | self.contentViewCenterXConstraint.constant = -self.applicationKeyWindow.bounds.size.height; 344 | break; 345 | case CNPPopupPresentationStyleSlideInFromRight: 346 | self.contentViewCenterYConstraint.constant = 0; 347 | self.contentViewCenterXConstraint.constant = self.applicationKeyWindow.bounds.size.height; 348 | break; 349 | default: 350 | self.contentViewCenterYConstraint.constant = 0; 351 | self.contentViewCenterXConstraint.constant = 0; 352 | break; 353 | } 354 | } 355 | else if (self.theme.popupStyle == CNPPopupStyleActionSheet) { 356 | self.contentViewBottom.constant = self.applicationKeyWindow.bounds.size.height; 357 | } 358 | } 359 | 360 | - (void)setDismissedConstraints { 361 | 362 | if (self.theme.popupStyle == CNPPopupStyleCentered) { 363 | switch (self.theme.presentationStyle) { 364 | case CNPPopupPresentationStyleFadeIn: 365 | self.contentViewCenterYConstraint.constant = 0; 366 | self.contentViewCenterXConstraint.constant = 0; 367 | break; 368 | case CNPPopupPresentationStyleSlideInFromTop: 369 | self.contentViewCenterYConstraint.constant = self.applicationKeyWindow.bounds.size.height; 370 | self.contentViewCenterXConstraint.constant = 0; 371 | break; 372 | case CNPPopupPresentationStyleSlideInFromBottom: 373 | self.contentViewCenterYConstraint.constant = -self.applicationKeyWindow.bounds.size.height; 374 | self.contentViewCenterXConstraint.constant = 0; 375 | break; 376 | case CNPPopupPresentationStyleSlideInFromLeft: 377 | self.contentViewCenterYConstraint.constant = 0; 378 | self.contentViewCenterXConstraint.constant = self.applicationKeyWindow.bounds.size.height; 379 | break; 380 | case CNPPopupPresentationStyleSlideInFromRight: 381 | self.contentViewCenterYConstraint.constant = 0; 382 | self.contentViewCenterXConstraint.constant = -self.applicationKeyWindow.bounds.size.height; 383 | break; 384 | default: 385 | self.contentViewCenterYConstraint.constant = 0; 386 | self.contentViewCenterXConstraint.constant = 0; 387 | break; 388 | } 389 | } 390 | else if (self.theme.popupStyle == CNPPopupStyleActionSheet) { 391 | self.contentViewBottom.constant = self.applicationKeyWindow.bounds.size.height; 392 | } 393 | } 394 | 395 | - (void)setPresentedConstraints { 396 | 397 | if (self.theme.popupStyle == CNPPopupStyleCentered) { 398 | self.contentViewCenterYConstraint.constant = 0; 399 | self.contentViewCenterXConstraint.constant = 0; 400 | } 401 | else if (self.theme.popupStyle == CNPPopupStyleActionSheet) { 402 | self.contentViewBottom.constant = 0; 403 | } 404 | } 405 | 406 | #pragma mark - Window Handling 407 | 408 | - (void)statusBarFrameOrOrientationChanged:(NSNotification *)notification 409 | { 410 | [self rotateAccordingToStatusBarOrientationAndSupportedOrientations]; 411 | } 412 | 413 | - (void)rotateAccordingToStatusBarOrientationAndSupportedOrientations 414 | { 415 | UIInterfaceOrientation statusBarOrientation = [UIApplication sharedApplication].statusBarOrientation; 416 | CGFloat angle = UIInterfaceOrientationAngleOfOrientation(statusBarOrientation); 417 | CGFloat statusBarHeight = [self getStatusBarHeight]; 418 | 419 | CGAffineTransform transform = CGAffineTransformMakeRotation(angle); 420 | CGRect frame = [self rectInWindowBounds:self.applicationKeyWindow.bounds statusBarOrientation:statusBarOrientation statusBarHeight:statusBarHeight]; 421 | 422 | [self setIfNotEqualTransform:transform frame:frame]; 423 | } 424 | 425 | - (void)setIfNotEqualTransform:(CGAffineTransform)transform frame:(CGRect)frame 426 | { 427 | if(!CGAffineTransformEqualToTransform(self.maskView.transform, transform)) 428 | { 429 | self.maskView.transform = transform; 430 | } 431 | if(!CGRectEqualToRect(self.maskView.frame, frame)) 432 | { 433 | self.maskView.frame = frame; 434 | } 435 | } 436 | 437 | - (CGFloat)getStatusBarHeight 438 | { 439 | UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; 440 | if(UIInterfaceOrientationIsLandscape(orientation)) 441 | { 442 | return [UIApplication sharedApplication].statusBarFrame.size.width; 443 | } 444 | else 445 | { 446 | return [UIApplication sharedApplication].statusBarFrame.size.height; 447 | } 448 | } 449 | 450 | - (CGRect)rectInWindowBounds:(CGRect)windowBounds statusBarOrientation:(UIInterfaceOrientation)statusBarOrientation statusBarHeight:(CGFloat)statusBarHeight 451 | { 452 | CGRect frame = windowBounds; 453 | frame.origin.x += statusBarOrientation == UIInterfaceOrientationLandscapeLeft ? statusBarHeight : 0; 454 | frame.origin.y += statusBarOrientation == UIInterfaceOrientationPortrait ? statusBarHeight : 0; 455 | frame.size.width -= UIInterfaceOrientationIsLandscape(statusBarOrientation) ? statusBarHeight : 0; 456 | frame.size.height -= UIInterfaceOrientationIsPortrait(statusBarOrientation) ? statusBarHeight : 0; 457 | return frame; 458 | } 459 | 460 | CGFloat UIInterfaceOrientationAngleOfOrientation(UIInterfaceOrientation orientation) 461 | { 462 | CGFloat angle; 463 | 464 | switch (orientation) 465 | { 466 | case UIInterfaceOrientationPortraitUpsideDown: 467 | angle = M_PI; 468 | break; 469 | case UIInterfaceOrientationLandscapeLeft: 470 | angle = -M_PI_2; 471 | break; 472 | case UIInterfaceOrientationLandscapeRight: 473 | angle = M_PI_2; 474 | break; 475 | default: 476 | angle = 0.0; 477 | break; 478 | } 479 | 480 | return angle; 481 | } 482 | 483 | UIInterfaceOrientationMask UIInterfaceOrientationMaskFromOrientation(UIInterfaceOrientation orientation) 484 | { 485 | return 1 << orientation; 486 | } 487 | 488 | #pragma mark - Factories 489 | 490 | - (UILabel *)multilineLabelWithAttributedString:(NSAttributedString *)attributedString { 491 | UILabel *label = [[UILabel alloc] init]; 492 | [label setTranslatesAutoresizingMaskIntoConstraints:NO]; 493 | [label setAttributedText:attributedString]; 494 | [label setNumberOfLines:0]; 495 | return label; 496 | } 497 | 498 | - (UIImageView *)centeredImageViewForImage:(UIImage *)image { 499 | UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; 500 | [imageView setTranslatesAutoresizingMaskIntoConstraints:NO]; 501 | // [imageView setContentMode:UIViewContentModeScaleAspectFit]; 502 | imageView.layer.masksToBounds = YES; 503 | imageView.layer.cornerRadius = 1.0f; 504 | return imageView; 505 | } 506 | 507 | - (CNPPopupButton *)buttonItem:(CNPPopupButtonItem *)item { 508 | CNPPopupButton *button = [[CNPPopupButton alloc] init]; 509 | [button setTranslatesAutoresizingMaskIntoConstraints:NO]; 510 | [button setAttributedTitle:item.buttonTitle forState:UIControlStateNormal]; 511 | [button setBackgroundColor:item.backgroundColor]; 512 | [button.layer setCornerRadius:item.cornerRadius]; 513 | [button.layer setBorderColor:item.borderColor.CGColor]; 514 | [button.layer setBorderWidth:item.borderWidth]; 515 | button.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:18.0]; 516 | button.item = item; 517 | return button; 518 | } 519 | 520 | @end 521 | 522 | #pragma mark - CNPPopupButton Methods 523 | 524 | @implementation CNPPopupButton 525 | 526 | @end 527 | 528 | #pragma mark - CNPPopupButtonItem Methods 529 | 530 | @implementation CNPPopupButtonItem 531 | 532 | + (CNPPopupButtonItem *)defaultButtonItemWithTitle:(NSAttributedString *)title backgroundColor:(UIColor *)color { 533 | CNPPopupButtonItem *item = [[CNPPopupButtonItem alloc] init]; 534 | item.buttonTitle = title; 535 | item.cornerRadius = 2; 536 | item.backgroundColor = color; 537 | item.buttonHeight = 44; 538 | return item; 539 | } 540 | 541 | @end 542 | 543 | @implementation CNPPopupTheme 544 | 545 | + (CNPPopupTheme *)defaultTheme { 546 | CNPPopupTheme *defaultTheme = [[CNPPopupTheme alloc] init]; 547 | defaultTheme.backgroundColor = [UIColor whiteColor]; 548 | defaultTheme.cornerRadius = 4.0f; 549 | defaultTheme.popupContentInsets = UIEdgeInsetsMake(16.0f, 16.0f, 16.0f, 16.0f); 550 | defaultTheme.popupStyle = CNPPopupStyleCentered; 551 | defaultTheme.presentationStyle = CNPPopupPresentationStyleSlideInFromBottom; 552 | defaultTheme.dismissesOppositeDirection = NO; 553 | defaultTheme.maskType = CNPPopupMaskTypeDimmed; 554 | defaultTheme.shouldDismissOnBackgroundTouch = YES; 555 | defaultTheme.contentVerticalPadding = 12.0f; 556 | return defaultTheme; 557 | } 558 | 559 | @end 560 | -------------------------------------------------------------------------------- /CNPPopupControllerExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B58F861319D858730044BACB /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B58F861219D858730044BACB /* main.m */; }; 11 | B58F861619D858730044BACB /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B58F861519D858730044BACB /* AppDelegate.m */; }; 12 | B58F861919D858730044BACB /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B58F861819D858730044BACB /* ViewController.m */; }; 13 | B58F861C19D858730044BACB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B58F861A19D858730044BACB /* Main.storyboard */; }; 14 | B58F861E19D858730044BACB /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B58F861D19D858730044BACB /* Images.xcassets */; }; 15 | B58F862119D858730044BACB /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = B58F861F19D858730044BACB /* LaunchScreen.xib */; }; 16 | B58F862D19D858730044BACB /* CNPPopupControllerExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B58F862C19D858730044BACB /* CNPPopupControllerExampleTests.m */; }; 17 | B5D3A81C19D85A5A0001B05D /* CNPPopupController.m in Sources */ = {isa = PBXBuildFile; fileRef = B5D3A81B19D85A5A0001B05D /* CNPPopupController.m */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | B58F862719D858730044BACB /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = B58F860519D858730044BACB /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = B58F860C19D858730044BACB; 26 | remoteInfo = CNPPopupControllerExample; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | AB3C8B47B956C70BF68BA19D /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | B58F860D19D858730044BACB /* CNPPopupControllerExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CNPPopupControllerExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | B58F861119D858730044BACB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | B58F861219D858730044BACB /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 35 | B58F861419D858730044BACB /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 36 | B58F861519D858730044BACB /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 37 | B58F861719D858730044BACB /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 38 | B58F861819D858730044BACB /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 39 | B58F861B19D858730044BACB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 40 | B58F861D19D858730044BACB /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 41 | B58F862019D858730044BACB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 42 | B58F862619D858730044BACB /* CNPPopupControllerExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CNPPopupControllerExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | B58F862B19D858730044BACB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | B58F862C19D858730044BACB /* CNPPopupControllerExampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CNPPopupControllerExampleTests.m; sourceTree = ""; }; 45 | B5D3A81A19D85A5A0001B05D /* CNPPopupController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNPPopupController.h; sourceTree = ""; }; 46 | B5D3A81B19D85A5A0001B05D /* CNPPopupController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNPPopupController.m; sourceTree = ""; }; 47 | /* End PBXFileReference section */ 48 | 49 | /* Begin PBXFrameworksBuildPhase section */ 50 | B58F860A19D858730044BACB /* Frameworks */ = { 51 | isa = PBXFrameworksBuildPhase; 52 | buildActionMask = 2147483647; 53 | files = ( 54 | ); 55 | runOnlyForDeploymentPostprocessing = 0; 56 | }; 57 | B58F862319D858730044BACB /* Frameworks */ = { 58 | isa = PBXFrameworksBuildPhase; 59 | buildActionMask = 2147483647; 60 | files = ( 61 | ); 62 | runOnlyForDeploymentPostprocessing = 0; 63 | }; 64 | /* End PBXFrameworksBuildPhase section */ 65 | 66 | /* Begin PBXGroup section */ 67 | 7D583C20BA8361CF4A18BD6E /* Frameworks */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | AB3C8B47B956C70BF68BA19D /* libPods.a */, 71 | ); 72 | name = Frameworks; 73 | sourceTree = ""; 74 | }; 75 | B58F860419D858730044BACB = { 76 | isa = PBXGroup; 77 | children = ( 78 | B5D3A81919D858BE0001B05D /* CNPPopupController */, 79 | B58F860F19D858730044BACB /* CNPPopupControllerExample */, 80 | B58F862919D858730044BACB /* CNPPopupControllerExampleTests */, 81 | B58F860E19D858730044BACB /* Products */, 82 | 7D583C20BA8361CF4A18BD6E /* Frameworks */, 83 | ); 84 | sourceTree = ""; 85 | }; 86 | B58F860E19D858730044BACB /* Products */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | B58F860D19D858730044BACB /* CNPPopupControllerExample.app */, 90 | B58F862619D858730044BACB /* CNPPopupControllerExampleTests.xctest */, 91 | ); 92 | name = Products; 93 | sourceTree = ""; 94 | }; 95 | B58F860F19D858730044BACB /* CNPPopupControllerExample */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | B58F861419D858730044BACB /* AppDelegate.h */, 99 | B58F861519D858730044BACB /* AppDelegate.m */, 100 | B58F861719D858730044BACB /* ViewController.h */, 101 | B58F861819D858730044BACB /* ViewController.m */, 102 | B58F861A19D858730044BACB /* Main.storyboard */, 103 | B58F861D19D858730044BACB /* Images.xcassets */, 104 | B58F861F19D858730044BACB /* LaunchScreen.xib */, 105 | B58F861019D858730044BACB /* Supporting Files */, 106 | ); 107 | path = CNPPopupControllerExample; 108 | sourceTree = ""; 109 | }; 110 | B58F861019D858730044BACB /* Supporting Files */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | B58F861119D858730044BACB /* Info.plist */, 114 | B58F861219D858730044BACB /* main.m */, 115 | ); 116 | name = "Supporting Files"; 117 | sourceTree = ""; 118 | }; 119 | B58F862919D858730044BACB /* CNPPopupControllerExampleTests */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | B58F862C19D858730044BACB /* CNPPopupControllerExampleTests.m */, 123 | B58F862A19D858730044BACB /* Supporting Files */, 124 | ); 125 | path = CNPPopupControllerExampleTests; 126 | sourceTree = ""; 127 | }; 128 | B58F862A19D858730044BACB /* Supporting Files */ = { 129 | isa = PBXGroup; 130 | children = ( 131 | B58F862B19D858730044BACB /* Info.plist */, 132 | ); 133 | name = "Supporting Files"; 134 | sourceTree = ""; 135 | }; 136 | B5D3A81919D858BE0001B05D /* CNPPopupController */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | B5D3A81A19D85A5A0001B05D /* CNPPopupController.h */, 140 | B5D3A81B19D85A5A0001B05D /* CNPPopupController.m */, 141 | ); 142 | path = CNPPopupController; 143 | sourceTree = ""; 144 | }; 145 | /* End PBXGroup section */ 146 | 147 | /* Begin PBXNativeTarget section */ 148 | B58F860C19D858730044BACB /* CNPPopupControllerExample */ = { 149 | isa = PBXNativeTarget; 150 | buildConfigurationList = B58F863019D858730044BACB /* Build configuration list for PBXNativeTarget "CNPPopupControllerExample" */; 151 | buildPhases = ( 152 | B58F860919D858730044BACB /* Sources */, 153 | B58F860A19D858730044BACB /* Frameworks */, 154 | B58F860B19D858730044BACB /* Resources */, 155 | B566014419E1DFC90021F16B /* ShellScript */, 156 | ); 157 | buildRules = ( 158 | ); 159 | dependencies = ( 160 | ); 161 | name = CNPPopupControllerExample; 162 | productName = CNPPopupControllerExample; 163 | productReference = B58F860D19D858730044BACB /* CNPPopupControllerExample.app */; 164 | productType = "com.apple.product-type.application"; 165 | }; 166 | B58F862519D858730044BACB /* CNPPopupControllerExampleTests */ = { 167 | isa = PBXNativeTarget; 168 | buildConfigurationList = B58F863319D858730044BACB /* Build configuration list for PBXNativeTarget "CNPPopupControllerExampleTests" */; 169 | buildPhases = ( 170 | B58F862219D858730044BACB /* Sources */, 171 | B58F862319D858730044BACB /* Frameworks */, 172 | B58F862419D858730044BACB /* Resources */, 173 | ); 174 | buildRules = ( 175 | ); 176 | dependencies = ( 177 | B58F862819D858730044BACB /* PBXTargetDependency */, 178 | ); 179 | name = CNPPopupControllerExampleTests; 180 | productName = CNPPopupControllerExampleTests; 181 | productReference = B58F862619D858730044BACB /* CNPPopupControllerExampleTests.xctest */; 182 | productType = "com.apple.product-type.bundle.unit-test"; 183 | }; 184 | /* End PBXNativeTarget section */ 185 | 186 | /* Begin PBXProject section */ 187 | B58F860519D858730044BACB /* Project object */ = { 188 | isa = PBXProject; 189 | attributes = { 190 | LastUpgradeCheck = 0600; 191 | ORGANIZATIONNAME = "Carson Perrotti"; 192 | TargetAttributes = { 193 | B58F860C19D858730044BACB = { 194 | CreatedOnToolsVersion = 6.0.1; 195 | }; 196 | B58F862519D858730044BACB = { 197 | CreatedOnToolsVersion = 6.0.1; 198 | TestTargetID = B58F860C19D858730044BACB; 199 | }; 200 | }; 201 | }; 202 | buildConfigurationList = B58F860819D858730044BACB /* Build configuration list for PBXProject "CNPPopupControllerExample" */; 203 | compatibilityVersion = "Xcode 3.2"; 204 | developmentRegion = English; 205 | hasScannedForEncodings = 0; 206 | knownRegions = ( 207 | en, 208 | Base, 209 | ); 210 | mainGroup = B58F860419D858730044BACB; 211 | productRefGroup = B58F860E19D858730044BACB /* Products */; 212 | projectDirPath = ""; 213 | projectRoot = ""; 214 | targets = ( 215 | B58F860C19D858730044BACB /* CNPPopupControllerExample */, 216 | B58F862519D858730044BACB /* CNPPopupControllerExampleTests */, 217 | ); 218 | }; 219 | /* End PBXProject section */ 220 | 221 | /* Begin PBXResourcesBuildPhase section */ 222 | B58F860B19D858730044BACB /* Resources */ = { 223 | isa = PBXResourcesBuildPhase; 224 | buildActionMask = 2147483647; 225 | files = ( 226 | B58F861C19D858730044BACB /* Main.storyboard in Resources */, 227 | B58F862119D858730044BACB /* LaunchScreen.xib in Resources */, 228 | B58F861E19D858730044BACB /* Images.xcassets in Resources */, 229 | ); 230 | runOnlyForDeploymentPostprocessing = 0; 231 | }; 232 | B58F862419D858730044BACB /* Resources */ = { 233 | isa = PBXResourcesBuildPhase; 234 | buildActionMask = 2147483647; 235 | files = ( 236 | ); 237 | runOnlyForDeploymentPostprocessing = 0; 238 | }; 239 | /* End PBXResourcesBuildPhase section */ 240 | 241 | /* Begin PBXShellScriptBuildPhase section */ 242 | B566014419E1DFC90021F16B /* ShellScript */ = { 243 | isa = PBXShellScriptBuildPhase; 244 | buildActionMask = 2147483647; 245 | files = ( 246 | ); 247 | inputPaths = ( 248 | ); 249 | outputPaths = ( 250 | ); 251 | runOnlyForDeploymentPostprocessing = 0; 252 | shellPath = /bin/sh; 253 | shellScript = "#!/bin/bash\nbuildNumber=$(/usr/libexec/PlistBuddy -c \"Print CFBundleVersion\" \"$INFOPLIST_FILE\")\nbuildNumber=$(($buildNumber + 1))\n/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion $buildNumber\" \"$INFOPLIST_FILE\""; 254 | }; 255 | /* End PBXShellScriptBuildPhase section */ 256 | 257 | /* Begin PBXSourcesBuildPhase section */ 258 | B58F860919D858730044BACB /* Sources */ = { 259 | isa = PBXSourcesBuildPhase; 260 | buildActionMask = 2147483647; 261 | files = ( 262 | B5D3A81C19D85A5A0001B05D /* CNPPopupController.m in Sources */, 263 | B58F861919D858730044BACB /* ViewController.m in Sources */, 264 | B58F861619D858730044BACB /* AppDelegate.m in Sources */, 265 | B58F861319D858730044BACB /* main.m in Sources */, 266 | ); 267 | runOnlyForDeploymentPostprocessing = 0; 268 | }; 269 | B58F862219D858730044BACB /* Sources */ = { 270 | isa = PBXSourcesBuildPhase; 271 | buildActionMask = 2147483647; 272 | files = ( 273 | B58F862D19D858730044BACB /* CNPPopupControllerExampleTests.m in Sources */, 274 | ); 275 | runOnlyForDeploymentPostprocessing = 0; 276 | }; 277 | /* End PBXSourcesBuildPhase section */ 278 | 279 | /* Begin PBXTargetDependency section */ 280 | B58F862819D858730044BACB /* PBXTargetDependency */ = { 281 | isa = PBXTargetDependency; 282 | target = B58F860C19D858730044BACB /* CNPPopupControllerExample */; 283 | targetProxy = B58F862719D858730044BACB /* PBXContainerItemProxy */; 284 | }; 285 | /* End PBXTargetDependency section */ 286 | 287 | /* Begin PBXVariantGroup section */ 288 | B58F861A19D858730044BACB /* Main.storyboard */ = { 289 | isa = PBXVariantGroup; 290 | children = ( 291 | B58F861B19D858730044BACB /* Base */, 292 | ); 293 | name = Main.storyboard; 294 | sourceTree = ""; 295 | }; 296 | B58F861F19D858730044BACB /* LaunchScreen.xib */ = { 297 | isa = PBXVariantGroup; 298 | children = ( 299 | B58F862019D858730044BACB /* Base */, 300 | ); 301 | name = LaunchScreen.xib; 302 | sourceTree = ""; 303 | }; 304 | /* End PBXVariantGroup section */ 305 | 306 | /* Begin XCBuildConfiguration section */ 307 | B58F862E19D858730044BACB /* Debug */ = { 308 | isa = XCBuildConfiguration; 309 | buildSettings = { 310 | ALWAYS_SEARCH_USER_PATHS = NO; 311 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 312 | CLANG_CXX_LIBRARY = "libc++"; 313 | CLANG_ENABLE_MODULES = YES; 314 | CLANG_ENABLE_OBJC_ARC = YES; 315 | CLANG_WARN_BOOL_CONVERSION = YES; 316 | CLANG_WARN_CONSTANT_CONVERSION = YES; 317 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 318 | CLANG_WARN_EMPTY_BODY = YES; 319 | CLANG_WARN_ENUM_CONVERSION = YES; 320 | CLANG_WARN_INT_CONVERSION = YES; 321 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 322 | CLANG_WARN_UNREACHABLE_CODE = YES; 323 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 324 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 325 | COPY_PHASE_STRIP = NO; 326 | ENABLE_STRICT_OBJC_MSGSEND = YES; 327 | GCC_C_LANGUAGE_STANDARD = gnu99; 328 | GCC_DYNAMIC_NO_PIC = NO; 329 | GCC_OPTIMIZATION_LEVEL = 0; 330 | GCC_PREPROCESSOR_DEFINITIONS = ( 331 | "DEBUG=1", 332 | "$(inherited)", 333 | ); 334 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 335 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 336 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 337 | GCC_WARN_UNDECLARED_SELECTOR = YES; 338 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 339 | GCC_WARN_UNUSED_FUNCTION = YES; 340 | GCC_WARN_UNUSED_VARIABLE = YES; 341 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 342 | MTL_ENABLE_DEBUG_INFO = YES; 343 | ONLY_ACTIVE_ARCH = YES; 344 | SDKROOT = iphoneos; 345 | TARGETED_DEVICE_FAMILY = "1,2"; 346 | }; 347 | name = Debug; 348 | }; 349 | B58F862F19D858730044BACB /* Release */ = { 350 | isa = XCBuildConfiguration; 351 | buildSettings = { 352 | ALWAYS_SEARCH_USER_PATHS = NO; 353 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 354 | CLANG_CXX_LIBRARY = "libc++"; 355 | CLANG_ENABLE_MODULES = YES; 356 | CLANG_ENABLE_OBJC_ARC = YES; 357 | CLANG_WARN_BOOL_CONVERSION = YES; 358 | CLANG_WARN_CONSTANT_CONVERSION = YES; 359 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 360 | CLANG_WARN_EMPTY_BODY = YES; 361 | CLANG_WARN_ENUM_CONVERSION = YES; 362 | CLANG_WARN_INT_CONVERSION = YES; 363 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 364 | CLANG_WARN_UNREACHABLE_CODE = YES; 365 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 366 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 367 | COPY_PHASE_STRIP = YES; 368 | ENABLE_NS_ASSERTIONS = NO; 369 | ENABLE_STRICT_OBJC_MSGSEND = YES; 370 | GCC_C_LANGUAGE_STANDARD = gnu99; 371 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 372 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 373 | GCC_WARN_UNDECLARED_SELECTOR = YES; 374 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 375 | GCC_WARN_UNUSED_FUNCTION = YES; 376 | GCC_WARN_UNUSED_VARIABLE = YES; 377 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 378 | MTL_ENABLE_DEBUG_INFO = NO; 379 | SDKROOT = iphoneos; 380 | TARGETED_DEVICE_FAMILY = "1,2"; 381 | VALIDATE_PRODUCT = YES; 382 | }; 383 | name = Release; 384 | }; 385 | B58F863119D858730044BACB /* Debug */ = { 386 | isa = XCBuildConfiguration; 387 | buildSettings = { 388 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 389 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 390 | INFOPLIST_FILE = CNPPopupControllerExample/Info.plist; 391 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 392 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 393 | PRODUCT_NAME = "$(TARGET_NAME)"; 394 | }; 395 | name = Debug; 396 | }; 397 | B58F863219D858730044BACB /* Release */ = { 398 | isa = XCBuildConfiguration; 399 | buildSettings = { 400 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 401 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 402 | INFOPLIST_FILE = CNPPopupControllerExample/Info.plist; 403 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 404 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 405 | PRODUCT_NAME = "$(TARGET_NAME)"; 406 | }; 407 | name = Release; 408 | }; 409 | B58F863419D858730044BACB /* Debug */ = { 410 | isa = XCBuildConfiguration; 411 | buildSettings = { 412 | BUNDLE_LOADER = "$(TEST_HOST)"; 413 | FRAMEWORK_SEARCH_PATHS = ( 414 | "$(SDKROOT)/Developer/Library/Frameworks", 415 | "$(inherited)", 416 | ); 417 | GCC_PREPROCESSOR_DEFINITIONS = ( 418 | "DEBUG=1", 419 | "$(inherited)", 420 | ); 421 | INFOPLIST_FILE = CNPPopupControllerExampleTests/Info.plist; 422 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 423 | PRODUCT_NAME = "$(TARGET_NAME)"; 424 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CNPPopupControllerExample.app/CNPPopupControllerExample"; 425 | }; 426 | name = Debug; 427 | }; 428 | B58F863519D858730044BACB /* Release */ = { 429 | isa = XCBuildConfiguration; 430 | buildSettings = { 431 | BUNDLE_LOADER = "$(TEST_HOST)"; 432 | FRAMEWORK_SEARCH_PATHS = ( 433 | "$(SDKROOT)/Developer/Library/Frameworks", 434 | "$(inherited)", 435 | ); 436 | INFOPLIST_FILE = CNPPopupControllerExampleTests/Info.plist; 437 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 438 | PRODUCT_NAME = "$(TARGET_NAME)"; 439 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CNPPopupControllerExample.app/CNPPopupControllerExample"; 440 | }; 441 | name = Release; 442 | }; 443 | /* End XCBuildConfiguration section */ 444 | 445 | /* Begin XCConfigurationList section */ 446 | B58F860819D858730044BACB /* Build configuration list for PBXProject "CNPPopupControllerExample" */ = { 447 | isa = XCConfigurationList; 448 | buildConfigurations = ( 449 | B58F862E19D858730044BACB /* Debug */, 450 | B58F862F19D858730044BACB /* Release */, 451 | ); 452 | defaultConfigurationIsVisible = 0; 453 | defaultConfigurationName = Release; 454 | }; 455 | B58F863019D858730044BACB /* Build configuration list for PBXNativeTarget "CNPPopupControllerExample" */ = { 456 | isa = XCConfigurationList; 457 | buildConfigurations = ( 458 | B58F863119D858730044BACB /* Debug */, 459 | B58F863219D858730044BACB /* Release */, 460 | ); 461 | defaultConfigurationIsVisible = 0; 462 | defaultConfigurationName = Release; 463 | }; 464 | B58F863319D858730044BACB /* Build configuration list for PBXNativeTarget "CNPPopupControllerExampleTests" */ = { 465 | isa = XCConfigurationList; 466 | buildConfigurations = ( 467 | B58F863419D858730044BACB /* Debug */, 468 | B58F863519D858730044BACB /* Release */, 469 | ); 470 | defaultConfigurationIsVisible = 0; 471 | defaultConfigurationName = Release; 472 | }; 473 | /* End XCConfigurationList section */ 474 | }; 475 | rootObject = B58F860519D858730044BACB /* Project object */; 476 | } 477 | -------------------------------------------------------------------------------- /CNPPopupControllerExample.xcodeproj/xcshareddata/xcschemes/CNPPopupControllerExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 76 | 82 | 83 | 84 | 85 | 89 | 90 | 91 | 92 | 98 | 99 | 105 | 106 | 107 | 108 | 110 | 111 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /CNPPopupControllerExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // CNPPopupControllerExample 4 | // 5 | // Created by Carson Perrotti on 2014-09-28. 6 | // Copyright (c) 2014 Carson Perrotti. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /CNPPopupControllerExample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // CNPPopupControllerExample 4 | // 5 | // Created by Carson Perrotti on 2014-09-28. 6 | // Copyright (c) 2014 Carson Perrotti. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /CNPPopupControllerExample/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /CNPPopupControllerExample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /CNPPopupControllerExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /CNPPopupControllerExample/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "ipad", 6 | "minimum-system-version" : "7.0", 7 | "extent" : "full-screen", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "landscape", 12 | "idiom" : "ipad", 13 | "minimum-system-version" : "7.0", 14 | "extent" : "full-screen", 15 | "scale" : "1x" 16 | }, 17 | { 18 | "orientation" : "landscape", 19 | "idiom" : "ipad", 20 | "minimum-system-version" : "7.0", 21 | "extent" : "full-screen", 22 | "scale" : "2x" 23 | }, 24 | { 25 | "orientation" : "portrait", 26 | "idiom" : "iphone", 27 | "minimum-system-version" : "7.0", 28 | "scale" : "2x" 29 | }, 30 | { 31 | "orientation" : "portrait", 32 | "idiom" : "iphone", 33 | "minimum-system-version" : "7.0", 34 | "subtype" : "retina4", 35 | "scale" : "2x" 36 | }, 37 | { 38 | "orientation" : "portrait", 39 | "idiom" : "ipad", 40 | "minimum-system-version" : "7.0", 41 | "extent" : "full-screen", 42 | "scale" : "1x" 43 | } 44 | ], 45 | "info" : { 46 | "version" : 1, 47 | "author" : "xcode" 48 | } 49 | } -------------------------------------------------------------------------------- /CNPPopupControllerExample/Images.xcassets/icon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "icon.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode", 11 | "template-rendering-intent" : "original" 12 | } 13 | } -------------------------------------------------------------------------------- /CNPPopupControllerExample/Images.xcassets/icon.imageset/icon.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/summerblue-ext-forks/CNPPopupController-Card/37358b2cdcaf71d03f8aedbedccbd22264d9e050/CNPPopupControllerExample/Images.xcassets/icon.imageset/icon.pdf -------------------------------------------------------------------------------- /CNPPopupControllerExample/Images.xcassets/sad-cat-8.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "sad-cat-8.jpg" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /CNPPopupControllerExample/Images.xcassets/sad-cat-8.imageset/sad-cat-8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/summerblue-ext-forks/CNPPopupController-Card/37358b2cdcaf71d03f8aedbedccbd22264d9e050/CNPPopupControllerExample/Images.xcassets/sad-cat-8.imageset/sad-cat-8.jpg -------------------------------------------------------------------------------- /CNPPopupControllerExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.carsonperrotti.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 0.1.2 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 294 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /CNPPopupControllerExample/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // CNPPopupControllerExample 4 | // 5 | // Created by Carson Perrotti on 2014-09-28. 6 | // Copyright (c) 2014 Carson Perrotti. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | - (IBAction)showPopupCentered:(id)sender; 14 | - (IBAction)showPopupFormSheet:(id)sender; 15 | - (IBAction)showPopupFullscreen:(id)sender; 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /CNPPopupControllerExample/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // CNPPopupControllerExample 4 | // 5 | // Created by Carson Perrotti on 2014-09-28. 6 | // Copyright (c) 2014 Carson Perrotti. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | #import "CNPPopupController.h" 12 | 13 | @interface ViewController () 14 | @property (weak, nonatomic) IBOutlet UIButton *showButton; 15 | 16 | @property (nonatomic, strong) CNPPopupController *popupController; 17 | 18 | @end 19 | 20 | @implementation ViewController 21 | 22 | 23 | - (void)viewDidLoad 24 | { 25 | [super viewDidLoad]; 26 | 27 | self.showButton.layer.cornerRadius = 4; 28 | } 29 | 30 | -(void)showPopupCentered:(id)sender { 31 | [self showPopupWithStyle:CNPPopupStyleCentered]; 32 | } 33 | 34 | - (void)showPopupFormSheet:(id)sender { 35 | [self showPopupWithStyle:CNPPopupStyleActionSheet]; 36 | } 37 | 38 | - (void)showPopupFullscreen:(id)sender { 39 | [self showPopupWithStyle:CNPPopupStyleFullscreen]; 40 | } 41 | 42 | - (void)showPopupWithStyle:(CNPPopupStyle)popupStyle { 43 | 44 | NSMutableParagraphStyle *paragraphStyle = NSMutableParagraphStyle.new; 45 | paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping; 46 | paragraphStyle.alignment = NSTextAlignmentCenter; 47 | 48 | NSAttributedString *title = [[NSAttributedString alloc] initWithString:@"宠物一家亲" 49 | attributes:@{ 50 | NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Bold" size:18.0], 51 | NSParagraphStyleAttributeName : paragraphStyle, 52 | NSForegroundColorAttributeName : UIColorFromRGB(0x666666) 53 | }]; 54 | 55 | // NSURL *myURL = [NSURL URLWithString:@"http://freephotos.atguru.in/hdphotos/sad-cat/sad-cat-8.jpg"]; 56 | // UIImage *icon = [UIImage imageWithData:[NSData dataWithContentsOfURL:myURL]]; 57 | UIImage *icon = [UIImage imageNamed:@"sad-cat-8.jpg"]; 58 | 59 | NSAttributedString *lineOne = [[NSAttributedString alloc] initWithString:@"12 成员 • Master: Keven" 60 | attributes:@{ 61 | NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue" size:11.0], 62 | NSParagraphStyleAttributeName : paragraphStyle, 63 | NSForegroundColorAttributeName : UIColorFromRGB(0x999999) 64 | }]; 65 | 66 | NSMutableParagraphStyle *detailParagraphStyle = [[NSMutableParagraphStyle alloc]init] ; 67 | [detailParagraphStyle setAlignment:NSTextAlignmentLeft]; 68 | [detailParagraphStyle setLineSpacing:3.0]; 69 | 70 | NSAttributedString *lineTwo = [[NSAttributedString alloc] initWithString:@"合创优设是基于互联网的珠宝首饰设计师项目交流平台,通过这个平台为设计师提供更多的订单机会和成长空间,同时合创优设的导师团也会助力设计师的成长。" 71 | attributes:@{ 72 | NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue" size:12.0], 73 | NSForegroundColorAttributeName : UIColorFromRGB(0x666666), 74 | NSParagraphStyleAttributeName : detailParagraphStyle 75 | }]; 76 | 77 | NSAttributedString *buttonTitle = [[NSAttributedString alloc] initWithString:@"加入聊天室" attributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:18], NSForegroundColorAttributeName : [UIColor whiteColor], NSParagraphStyleAttributeName : paragraphStyle}]; 78 | 79 | CNPPopupButtonItem *buttonItem = [CNPPopupButtonItem defaultButtonItemWithTitle:buttonTitle backgroundColor:UIColorFromRGB(0x54CE7C)]; 80 | buttonItem.selectionHandler = ^(CNPPopupButtonItem *item){ 81 | NSLog(@"Block for button: %@", item.buttonTitle.string); 82 | }; 83 | 84 | self.popupController = [[CNPPopupController alloc] initWithTitle:title contents:@[icon, lineOne, lineTwo] buttonItems:@[buttonItem] destructiveButtonItem:nil]; 85 | self.popupController.theme = [CNPPopupTheme defaultTheme]; 86 | self.popupController.theme.popupStyle = popupStyle; 87 | self.popupController.delegate = self; 88 | self.popupController.theme.presentationStyle = CNPPopupPresentationStyleSlideInFromBottom; 89 | [self.popupController presentPopupControllerAnimated:YES]; 90 | } 91 | 92 | #pragma mark - CNPPopupController Delegate 93 | 94 | - (void)popupController:(CNPPopupController *)controller didDismissWithButtonTitle:(NSString *)title { 95 | NSLog(@"Dismissed with button title: %@", title); 96 | } 97 | 98 | - (void)popupControllerDidPresent:(CNPPopupController *)controller { 99 | NSLog(@"Popup controller presented."); 100 | } 101 | 102 | @end 103 | -------------------------------------------------------------------------------- /CNPPopupControllerExample/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/summerblue-ext-forks/CNPPopupController-Card/37358b2cdcaf71d03f8aedbedccbd22264d9e050/CNPPopupControllerExample/demo.gif -------------------------------------------------------------------------------- /CNPPopupControllerExample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CNPPopupControllerExample 4 | // 5 | // Created by Carson Perrotti on 2014-09-28. 6 | // Copyright (c) 2014 Carson Perrotti. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CNPPopupControllerExampleTests/CNPPopupControllerExampleTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CNPPopupControllerExampleTests.m 3 | // CNPPopupControllerExampleTests 4 | // 5 | // Created by Carson Perrotti on 2014-09-28. 6 | // Copyright (c) 2014 Carson Perrotti. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface CNPPopupControllerExampleTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation CNPPopupControllerExampleTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /CNPPopupControllerExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.carsonperrotti.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright 2014 Carson Perrotti. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Introduction 2 | 3 | A little modified version of [CNPPopupController](https://github.com/carsonperrotti/CNPPopupController) . 4 | 5 | ![](https://raw.githubusercontent.com/summerblue/CNPPopupController-Card/master/CNPPopupControllerExample/demo.gif) 6 | --------------------------------------------------------------------------------