Skip to content
This repository was archived by the owner on Apr 27, 2019. It is now read-only.

Commit 56fe681

Browse files
author
Carson Perrotti
committed
Fixes #35, Adds animation timing property, Version Bump
1 parent f88967d commit 56fe681

File tree

6 files changed

+27
-119
lines changed

6 files changed

+27
-119
lines changed

CNPPopupController.podspec

Lines changed: 3 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
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-
91
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-
182
s.name = "CNPPopupController"
19-
s.version = "0.3.1"
3+
s.version = "0.3.2"
204
s.summary = "A versatile popup for iOS"
215

226
s.description = <<-DESC
@@ -31,102 +15,12 @@ Pod::Spec.new do |s|
3115

3216
s.homepage = "https://github.com/carsonperrotti/CNPPopupController"
3317
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-
4318
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" => "[email protected]" }
5719
s.author = "Carson Perrotti"
58-
# s.authors = { "Carson Perrotti" => "[email protected]" }
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-
20+
s.social_media_url = "http://twitter.com/carsonp"
6721
s.platform = :ios, "6.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.3.1" }
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-
22+
s.source = { :git => "https://github.com/carsonperrotti/CNPPopupController.git", :tag => "0.3.2" }
9123
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-
11524
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-
12825
s.requires_arc = true
129-
130-
# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
131-
13226
end

CNPPopupController/CNPPopupController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ typedef NS_ENUM(NSInteger, CNPPopupMaskType) {
7676
@property (nonatomic, assign) BOOL movesAboveKeyboard; // Popup should move up when the keyboard appears (Default yes)
7777
@property (nonatomic, assign) CGFloat contentVerticalPadding; // Spacing between each vertical element (Default 12.0)
7878
@property (nonatomic, assign) CGFloat maxPopupWidth; // Maxiumum width that the popup should be (Default 300)
79+
@property (nonatomic, assign) CGFloat animationDuration; // Duration of presentation animations (Default 0.3s)
7980

8081
// Factory method to help build a default theme
8182
+ (CNPPopupTheme *)defaultTheme;

CNPPopupController/CNPPopupController.m

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ - (void)dealloc {
7676

7777
- (void)orientationWillChange {
7878

79-
[UIView animateWithDuration:0.3 animations:^{
79+
[UIView animateWithDuration:self.theme.animationDuration animations:^{
8080
self.maskView.frame = self.applicationWindow.bounds;
8181
self.popupView.center = [self endingPoint];
8282
}];
@@ -88,7 +88,7 @@ - (void)orientationChanged {
8888
CGFloat angle = CNP_UIInterfaceOrientationAngleOfOrientation(statusBarOrientation);
8989
CGAffineTransform transform = CGAffineTransformMakeRotation(angle);
9090

91-
[UIView animateWithDuration:0.3 animations:^{
91+
[UIView animateWithDuration:self.theme.animationDuration animations:^{
9292
self.maskView.frame = self.applicationWindow.bounds;
9393
self.popupView.center = [self endingPoint];
9494
if (CNP_SYSTEM_VERSION_LESS_THAN(@"8.0")) {
@@ -172,7 +172,7 @@ - (CGSize)calculateContentSizeThatFits:(CGSize)size andUpdateLayout:(BOOL)update
172172
}
173173
else {
174174
if (update) {
175-
view.frame = CGRectMake((size.width-_size.width+inset.left+inset.right)*0.5, result.height, _size.width, _size.height);
175+
view.frame = CGRectMake(0, result.height, _size.width, _size.height);
176176
}
177177
}
178178
result.height += _size.height + self.theme.contentVerticalPadding;
@@ -183,7 +183,12 @@ - (CGSize)calculateContentSizeThatFits:(CGSize)size andUpdateLayout:(BOOL)update
183183
result.height -= self.theme.contentVerticalPadding;
184184
result.width += inset.left + inset.right;
185185
result.height = MIN(INFINITY, MAX(0.0f, result.height + inset.bottom));
186-
if (update) self.popupView.frame = CGRectMake(0, 0, result.width, result.height);
186+
if (update) {
187+
for (UIView *view in self.popupView.subviews) {
188+
view.frame = CGRectMake((result.width - view.frame.size.width) * 0.5, view.frame.origin.y, view.frame.size.width, view.frame.size.height);
189+
}
190+
self.popupView.frame = CGRectMake(0, 0, result.width, result.height);
191+
}
187192
return result;
188193
}
189194

@@ -254,7 +259,7 @@ - (void)presentPopupControllerAnimated:(BOOL)flag {
254259
self.popupView.center = [self originPoint];
255260
[self.applicationWindow addSubview:self.maskView];
256261
self.maskView.alpha = 0;
257-
[UIView animateWithDuration:flag?0.3:0.0 animations:^{
262+
[UIView animateWithDuration:flag?self.theme.animationDuration:0.0 animations:^{
258263
self.maskView.alpha = 1.0;
259264
self.popupView.center = [self endingPoint];;
260265
} completion:^(BOOL finished) {
@@ -269,7 +274,7 @@ - (void)dismissPopupControllerAnimated:(BOOL)flag {
269274
if ([self.delegate respondsToSelector:@selector(popupControllerWillDismiss:)]) {
270275
[self.delegate popupControllerWillDismiss:self];
271276
}
272-
[UIView animateWithDuration:flag?0.3:0.0 animations:^{
277+
[UIView animateWithDuration:flag?self.theme.animationDuration:0.0 animations:^{
273278
self.maskView.alpha = 0.0;
274279
self.popupView.center = [self dismissedPoint];;
275280
} completion:^(BOOL finished) {
@@ -411,6 +416,7 @@ + (CNPPopupTheme *)defaultTheme {
411416
defaultTheme.movesAboveKeyboard = YES;
412417
defaultTheme.contentVerticalPadding = 16.0f;
413418
defaultTheme.maxPopupWidth = 300.0f;
419+
defaultTheme.animationDuration = 0.3f;
414420
return defaultTheme;
415421
}
416422

CNPPopupControllerExample/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.3.0</string>
18+
<string>0.3.2</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>551</string>
22+
<string>554</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>UILaunchStoryboardName</key>

CNPPopupControllerExampleSwift/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0</string>
18+
<string>0.3.2</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,23 @@ A `CNPPopupTheme` instance can be created and assigned to the `theme` property o
6363

6464
`@property (nonatomic, assign) CGFloat maxPopupWidth;`
6565

66+
`@property (nonatomic, assign) CGFloat animationDuration;`
67+
6668
## Notes
6769

6870
### Deployment
69-
`CNPPopupController ` works on **iOS 6 - iOS 9**
71+
`CNPPopupController ` works on **iOS 6 - iOS 10**
7072

7173
##Credits
7274
CNPPopupController was created by [Carson Perrotti](http://carsonperrotti.com)
7375

7476
##Version History
7577

78+
**July 14, 2016 v0.3.2**
79+
- Fixes an issue where content would not be perfectly centred.
80+
- Project compatibility fixes to prevent ‘duplicate symbols` errors.
81+
- Added property to adjust animation transition duration.
82+
7683
**September 13, 2015 v0.3.1**
7784
- Sets `movesAboveKeyboard` to `YES` in the default theme.
7885

0 commit comments

Comments
 (0)