Compare commits

..

39 Commits

Author SHA1 Message Date
Cezary Wojcik 513ca17ffe Merge pull request #82 from kshdeo/swift
Swift Style selectors + Option to change Font size
2016-04-06 23:11:46 -07:00
Kshitij Deo a3aa9ca98f Formatting update 2016-04-07 11:36:52 +05:30
Kshitij Deo 445eafc3cb var to let 2016-04-07 11:02:34 +05:30
Kshitij Deo ac71e2f702 Reverting Font size changes 2016-04-07 11:00:55 +05:30
Kshitij Deo c16a9a2e71 Font size is public property 2016-04-06 14:42:28 +05:30
Kshitij Deo ac19e17ed6 Updated to new Swift style selectors 2016-04-06 12:39:27 +05:30
Cezary Wojcik 43fa3d60a5 Merge pull request #71 from PorterHoskins/rotationCrash
Rotation Crash
2015-10-07 08:11:42 -07:00
Porter Hoskins c5591a9b96 Removed private modifier to allow NSNotificationCenter to call function 2015-10-07 08:39:00 -06:00
Cezary Wojcik 2583aa5fb3 Merge pull request #70 from PorterHoskins/tapCrash
Fixed crash for tapping on status bar notification
2015-09-23 11:34:16 -07:00
Porter Hoskins dbd9e6d0e2 Fixed crash for tapping on status bar notification 2015-09-23 11:15:36 -06:00
Cezary Wojcik be8a8e51a9 trying out framework 2015-08-27 11:48:35 -07:00
Cezary Wojcik 88623f80a2 added build scheme 2015-08-25 12:40:55 -07:00
Cezary Wojcik 8c82ea5491 updated version number, if it matters 2015-07-12 19:24:58 -07:00
Cezary Wojcik b8b570c653 exposed enums to objective c 2015-07-12 19:19:44 -07:00
Cezary Wojcik 25335e297f updated demo gif 2015-07-12 19:16:21 -07:00
Cezary Wojcik bc4651499c added comment 2015-07-12 19:12:25 -07:00
Cezary Wojcik 3630ed6530 updated read 2015-07-12 19:07:54 -07:00
Cezary Wojcik d770665406 rewritten for Swift 2.0 2015-07-12 19:05:17 -07:00
Cezary Wojcik 63530d03ea Merge pull request #58 from mmcurtis55/swift
corrected errors caused by the newest version of swift.
2015-07-11 02:01:24 -07:00
mmcurtis55 9f1e7647ad corrected errors 2015-06-23 13:33:55 -05:00
Cezary Wojcik f7c7f5748f Merge pull request #46 from daylen/swift
Make the completion handler optional
2014-12-17 21:41:04 -08:00
Daylen Yang 3cdb92430b Fix issue with calling completion handler 2014-12-16 21:04:24 -08:00
Daylen Yang 95483a05ad Make the completion handler optional
Make the ? operator apply to the closure by putting in an extra set of parentheses.
2014-12-16 20:59:16 -08:00
Cezary Wojcik 2654541077 Merge pull request #34 from ricardopereira/swift-6.1
Xcode 6.1 compatibility
2014-10-10 01:43:58 -07:00
Ricardo Pereira dff58153e7 Xcode 6.1 compatibility 2014-10-09 17:13:58 +01:00
Cezary Wojcik 134b753a53 var -> let 2014-06-08 20:42:26 -07:00
Cezary Wojcik 51a988134e added a space 2014-06-08 20:40:58 -07:00
Cezary Wojcik 23effa5578 seeing double 2014-06-08 14:33:39 -07:00
Cezary Wojcik 062d342186 removed a copy 2014-06-08 14:31:58 -07:00
Cezary Wojcik 8cbd86b8f4 updated readme 2014-06-08 14:27:28 -07:00
Cezary Wojcik 6a7394f5e6 updated readme 2014-06-08 14:23:33 -07:00
Cezary Wojcik 3dd6a619d9 moved most initialization to property declarations 2014-06-08 13:47:07 -07:00
Cezary Wojcik 1338cd1b55 conversion to swift 2014-06-08 01:59:44 -07:00
Cezary Wojcik 8382cd9738 subclass UIWindow
thanks to @dzenbot for this fix
2014-05-28 09:46:32 -07:00
Cezary Wojcik 317b8e6db5 Merge pull request #22 from epologee/patch-1
Set the notification window to hidden
2014-05-16 11:46:40 -07:00
Eric-Paul Lecluse 8c68f3e2cd Set the notification window to hidden
By setting the hidden flag, the OS will poll the status bar style of the original view controller. Without this flag, the status bar will always become black after the notification animation.
2014-05-16 19:02:11 +02:00
Cezary Wojcik c8ba3fca9e added dismiss on tap with ability to override 2014-03-30 17:55:12 -07:00
Cezary Wojcik 194f00b40a updated readme with travis status image 2014-03-15 15:29:37 -07:00
Cezary Wojcik 2378a998fb travis 2014-03-15 15:21:37 -07:00
40 changed files with 2055 additions and 1053 deletions
+1
View File
@@ -0,0 +1 @@
language: objective-c
+123 -260
View File
@@ -7,167 +7,104 @@
objects = {
/* Begin PBXBuildFile section */
5E0D045E1838AE0D00CBFC35 /* CWStatusBarNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E0D045D1838AE0D00CBFC35 /* CWStatusBarNotification.m */; };
5E2FFB5718367C01003333F8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E2FFB5618367C01003333F8 /* Foundation.framework */; };
5E2FFB5918367C01003333F8 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E2FFB5818367C01003333F8 /* CoreGraphics.framework */; };
5E2FFB5B18367C01003333F8 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E2FFB5A18367C01003333F8 /* UIKit.framework */; };
5E2FFB6118367C01003333F8 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 5E2FFB5F18367C01003333F8 /* InfoPlist.strings */; };
5E2FFB6318367C01003333F8 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E2FFB6218367C01003333F8 /* main.m */; };
5E2FFB6718367C01003333F8 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E2FFB6618367C01003333F8 /* AppDelegate.m */; };
5E2FFB6918367C01003333F8 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5E2FFB6818367C01003333F8 /* Images.xcassets */; };
5E2FFB7018367C01003333F8 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E2FFB6F18367C01003333F8 /* XCTest.framework */; };
5E2FFB7118367C01003333F8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E2FFB5618367C01003333F8 /* Foundation.framework */; };
5E2FFB7218367C01003333F8 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E2FFB5A18367C01003333F8 /* UIKit.framework */; };
5E2FFB8E18367CA3003333F8 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E2FFB8C18367CA3003333F8 /* MainViewController.m */; };
5E2FFB8F18367CA3003333F8 /* MainViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5E2FFB8D18367CA3003333F8 /* MainViewController.xib */; };
5EB250971B5350580093E304 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EB250961B5350580093E304 /* AppDelegate.swift */; };
5EB250991B5350580093E304 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EB250981B5350580093E304 /* MainViewController.swift */; };
5EB2509C1B5350580093E304 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5EB2509A1B5350580093E304 /* Main.storyboard */; };
5EB2509E1B5350580093E304 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5EB2509D1B5350580093E304 /* Assets.xcassets */; };
5EB250A11B5350580093E304 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5EB2509F1B5350580093E304 /* LaunchScreen.storyboard */; };
5EC0FBB71B8F8C2900704169 /* CustomView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5EC0FBB61B8F8C2900704169 /* CustomView.xib */; };
5EC0FBBC1B8F8ED500704169 /* CWStatusBarNotification.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5EC0FBB81B8F8E6A00704169 /* CWStatusBarNotification.framework */; };
5EC0FBBD1B8F8ED500704169 /* CWStatusBarNotification.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 5EC0FBB81B8F8E6A00704169 /* CWStatusBarNotification.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
5E2FFB7318367C01003333F8 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 5E2FFB4B18367C01003333F8 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 5E2FFB5218367C01003333F8;
remoteInfo = CWNotificationDemo;
/* Begin PBXCopyFilesBuildPhase section */
5EC0FBBE1B8F8ED500704169 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
5EC0FBBD1B8F8ED500704169 /* CWStatusBarNotification.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXContainerItemProxy section */
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
5E0D045C1838AE0D00CBFC35 /* CWStatusBarNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CWStatusBarNotification.h; path = CWStatusBarNotification/CWStatusBarNotification.h; sourceTree = SOURCE_ROOT; };
5E0D045D1838AE0D00CBFC35 /* CWStatusBarNotification.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CWStatusBarNotification.m; path = CWStatusBarNotification/CWStatusBarNotification.m; sourceTree = SOURCE_ROOT; };
5E2FFB5318367C01003333F8 /* CWNotificationDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CWNotificationDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
5E2FFB5618367C01003333F8 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
5E2FFB5818367C01003333F8 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
5E2FFB5A18367C01003333F8 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
5E2FFB5E18367C01003333F8 /* CWNotificationDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CWNotificationDemo-Info.plist"; sourceTree = "<group>"; };
5E2FFB6018367C01003333F8 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
5E2FFB6218367C01003333F8 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
5E2FFB6418367C01003333F8 /* CWNotificationDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CWNotificationDemo-Prefix.pch"; sourceTree = "<group>"; };
5E2FFB6518367C01003333F8 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
5E2FFB6618367C01003333F8 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
5E2FFB6818367C01003333F8 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
5E2FFB6E18367C01003333F8 /* CWNotificationDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CWNotificationDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
5E2FFB6F18367C01003333F8 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
5E2FFB8B18367CA3003333F8 /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = "<group>"; };
5E2FFB8C18367CA3003333F8 /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = "<group>"; };
5E2FFB8D18367CA3003333F8 /* MainViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainViewController.xib; sourceTree = "<group>"; };
5EB250931B5350580093E304 /* CWNotificationDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CWNotificationDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
5EB250961B5350580093E304 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
5EB250981B5350580093E304 /* MainViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = "<group>"; };
5EB2509B1B5350580093E304 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
5EB2509D1B5350580093E304 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
5EB250A01B5350580093E304 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
5EB250A21B5350580093E304 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5EC0FBB61B8F8C2900704169 /* CustomView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CustomView.xib; sourceTree = "<group>"; };
5EC0FBB81B8F8E6A00704169 /* CWStatusBarNotification.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CWStatusBarNotification.framework; path = CWStatusBarNotification/CWStatusBarNotification.framework; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
5E2FFB5018367C01003333F8 /* Frameworks */ = {
5EB250901B5350580093E304 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
5E2FFB5918367C01003333F8 /* CoreGraphics.framework in Frameworks */,
5E2FFB5B18367C01003333F8 /* UIKit.framework in Frameworks */,
5E2FFB5718367C01003333F8 /* Foundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
5E2FFB6B18367C01003333F8 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
5E2FFB7018367C01003333F8 /* XCTest.framework in Frameworks */,
5E2FFB7218367C01003333F8 /* UIKit.framework in Frameworks */,
5E2FFB7118367C01003333F8 /* Foundation.framework in Frameworks */,
5EC0FBBC1B8F8ED500704169 /* CWStatusBarNotification.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
5E2FFB4A18367C01003333F8 = {
5EB2508A1B5350580093E304 = {
isa = PBXGroup;
children = (
5E2FFB8518367C1B003333F8 /* CWStatusBarNotification */,
5E2FFB5C18367C01003333F8 /* CWNotificationDemo */,
5E2FFB5518367C01003333F8 /* Frameworks */,
5E2FFB5418367C01003333F8 /* Products */,
5EB250A81B5350600093E304 /* CWStatusBarNotification */,
5EB250951B5350580093E304 /* CWNotificationDemo */,
5EB250941B5350580093E304 /* Products */,
);
sourceTree = "<group>";
};
5E2FFB5418367C01003333F8 /* Products */ = {
5EB250941B5350580093E304 /* Products */ = {
isa = PBXGroup;
children = (
5E2FFB5318367C01003333F8 /* CWNotificationDemo.app */,
5E2FFB6E18367C01003333F8 /* CWNotificationDemoTests.xctest */,
5EB250931B5350580093E304 /* CWNotificationDemo.app */,
);
name = Products;
sourceTree = "<group>";
};
5E2FFB5518367C01003333F8 /* Frameworks */ = {
5EB250951B5350580093E304 /* CWNotificationDemo */ = {
isa = PBXGroup;
children = (
5E2FFB5618367C01003333F8 /* Foundation.framework */,
5E2FFB5818367C01003333F8 /* CoreGraphics.framework */,
5E2FFB5A18367C01003333F8 /* UIKit.framework */,
5E2FFB6F18367C01003333F8 /* XCTest.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
5E2FFB5C18367C01003333F8 /* CWNotificationDemo */ = {
isa = PBXGroup;
children = (
5E2FFB6518367C01003333F8 /* AppDelegate.h */,
5E2FFB6618367C01003333F8 /* AppDelegate.m */,
5E2FFB8918367C75003333F8 /* View Controllers */,
5E2FFB6818367C01003333F8 /* Images.xcassets */,
5E2FFB5D18367C01003333F8 /* Supporting Files */,
5EB250961B5350580093E304 /* AppDelegate.swift */,
5EB250981B5350580093E304 /* MainViewController.swift */,
5EB2509A1B5350580093E304 /* Main.storyboard */,
5EB2509F1B5350580093E304 /* LaunchScreen.storyboard */,
5EC0FBB61B8F8C2900704169 /* CustomView.xib */,
5EB2509D1B5350580093E304 /* Assets.xcassets */,
5EB250A21B5350580093E304 /* Info.plist */,
);
path = CWNotificationDemo;
sourceTree = "<group>";
};
5E2FFB5D18367C01003333F8 /* Supporting Files */ = {
5EB250A81B5350600093E304 /* CWStatusBarNotification */ = {
isa = PBXGroup;
children = (
5E2FFB5E18367C01003333F8 /* CWNotificationDemo-Info.plist */,
5E2FFB5F18367C01003333F8 /* InfoPlist.strings */,
5E2FFB6218367C01003333F8 /* main.m */,
5E2FFB6418367C01003333F8 /* CWNotificationDemo-Prefix.pch */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
5E2FFB8518367C1B003333F8 /* CWStatusBarNotification */ = {
isa = PBXGroup;
children = (
5E0D045C1838AE0D00CBFC35 /* CWStatusBarNotification.h */,
5E0D045D1838AE0D00CBFC35 /* CWStatusBarNotification.m */,
5EC0FBB81B8F8E6A00704169 /* CWStatusBarNotification.framework */,
);
name = CWStatusBarNotification;
path = CWNotification;
sourceTree = "<group>";
};
5E2FFB8918367C75003333F8 /* View Controllers */ = {
isa = PBXGroup;
children = (
5E2FFB8A18367C85003333F8 /* MainViewController */,
);
name = "View Controllers";
sourceTree = "<group>";
};
5E2FFB8A18367C85003333F8 /* MainViewController */ = {
isa = PBXGroup;
children = (
5E2FFB8B18367CA3003333F8 /* MainViewController.h */,
5E2FFB8C18367CA3003333F8 /* MainViewController.m */,
5E2FFB8D18367CA3003333F8 /* MainViewController.xib */,
);
name = MainViewController;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
5E2FFB5218367C01003333F8 /* CWNotificationDemo */ = {
5EB250921B5350580093E304 /* CWNotificationDemo */ = {
isa = PBXNativeTarget;
buildConfigurationList = 5E2FFB7F18367C01003333F8 /* Build configuration list for PBXNativeTarget "CWNotificationDemo" */;
buildConfigurationList = 5EB250A51B5350580093E304 /* Build configuration list for PBXNativeTarget "CWNotificationDemo" */;
buildPhases = (
5E2FFB4F18367C01003333F8 /* Sources */,
5E2FFB5018367C01003333F8 /* Frameworks */,
5E2FFB5118367C01003333F8 /* Resources */,
5EB2508F1B5350580093E304 /* Sources */,
5EB250901B5350580093E304 /* Frameworks */,
5EB250911B5350580093E304 /* Resources */,
5EC0FBBE1B8F8ED500704169 /* Embed Frameworks */,
);
buildRules = (
);
@@ -175,124 +112,88 @@
);
name = CWNotificationDemo;
productName = CWNotificationDemo;
productReference = 5E2FFB5318367C01003333F8 /* CWNotificationDemo.app */;
productReference = 5EB250931B5350580093E304 /* CWNotificationDemo.app */;
productType = "com.apple.product-type.application";
};
5E2FFB6D18367C01003333F8 /* CWNotificationDemoTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 5E2FFB8218367C01003333F8 /* Build configuration list for PBXNativeTarget "CWNotificationDemoTests" */;
buildPhases = (
5E2FFB6A18367C01003333F8 /* Sources */,
5E2FFB6B18367C01003333F8 /* Frameworks */,
5E2FFB6C18367C01003333F8 /* Resources */,
);
buildRules = (
);
dependencies = (
5E2FFB7418367C01003333F8 /* PBXTargetDependency */,
);
name = CWNotificationDemoTests;
productName = CWNotificationDemoTests;
productReference = 5E2FFB6E18367C01003333F8 /* CWNotificationDemoTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
5E2FFB4B18367C01003333F8 /* Project object */ = {
5EB2508B1B5350580093E304 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0510;
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = "Cezary Wojcik";
TargetAttributes = {
5E2FFB5218367C01003333F8 = {
DevelopmentTeam = QMZH6X9D3C;
};
5E2FFB6D18367C01003333F8 = {
TestTargetID = 5E2FFB5218367C01003333F8;
5EB250921B5350580093E304 = {
CreatedOnToolsVersion = 7.0;
};
};
};
buildConfigurationList = 5E2FFB4E18367C01003333F8 /* Build configuration list for PBXProject "CWNotificationDemo" */;
buildConfigurationList = 5EB2508E1B5350580093E304 /* Build configuration list for PBXProject "CWNotificationDemo" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 5E2FFB4A18367C01003333F8;
productRefGroup = 5E2FFB5418367C01003333F8 /* Products */;
mainGroup = 5EB2508A1B5350580093E304;
productRefGroup = 5EB250941B5350580093E304 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
5E2FFB5218367C01003333F8 /* CWNotificationDemo */,
5E2FFB6D18367C01003333F8 /* CWNotificationDemoTests */,
5EB250921B5350580093E304 /* CWNotificationDemo */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
5E2FFB5118367C01003333F8 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5E2FFB6118367C01003333F8 /* InfoPlist.strings in Resources */,
5E2FFB8F18367CA3003333F8 /* MainViewController.xib in Resources */,
5E2FFB6918367C01003333F8 /* Images.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
5E2FFB6C18367C01003333F8 /* Resources */ = {
5EB250911B5350580093E304 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5EB250A11B5350580093E304 /* LaunchScreen.storyboard in Resources */,
5EC0FBB71B8F8C2900704169 /* CustomView.xib in Resources */,
5EB2509E1B5350580093E304 /* Assets.xcassets in Resources */,
5EB2509C1B5350580093E304 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
5E2FFB4F18367C01003333F8 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5E0D045E1838AE0D00CBFC35 /* CWStatusBarNotification.m in Sources */,
5E2FFB6718367C01003333F8 /* AppDelegate.m in Sources */,
5E2FFB6318367C01003333F8 /* main.m in Sources */,
5E2FFB8E18367CA3003333F8 /* MainViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
5E2FFB6A18367C01003333F8 /* Sources */ = {
5EB2508F1B5350580093E304 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5EB250991B5350580093E304 /* MainViewController.swift in Sources */,
5EB250971B5350580093E304 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
5E2FFB7418367C01003333F8 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 5E2FFB5218367C01003333F8 /* CWNotificationDemo */;
targetProxy = 5E2FFB7318367C01003333F8 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
5E2FFB5F18367C01003333F8 /* InfoPlist.strings */ = {
5EB2509A1B5350580093E304 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
5E2FFB6018367C01003333F8 /* en */,
5EB2509B1B5350580093E304 /* Base */,
);
name = InfoPlist.strings;
name = Main.storyboard;
sourceTree = "<group>";
};
5EB2509F1B5350580093E304 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
5EB250A01B5350580093E304 /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
5E2FFB7D18367C01003333F8 /* Debug */ = {
5EB250A31B5350580093E304 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
@@ -307,31 +208,37 @@
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
5E2FFB7E18367C01003333F8 /* Release */ = {
5EB250A41B5350580093E304 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
@@ -346,127 +253,83 @@
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
5E2FFB8018367C01003333F8 /* Debug */ = {
5EB250A61B5350580093E304 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "CWNotificationDemo/CWNotificationDemo-Prefix.pch";
INFOPLIST_FILE = "CWNotificationDemo/CWNotificationDemo-Info.plist";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
"$(PROJECT_DIR)/CWStatusBarNotification",
);
INFOPLIST_FILE = CWNotificationDemo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = CW.CWNotificationDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
WRAPPER_EXTENSION = app;
};
name = Debug;
};
5E2FFB8118367C01003333F8 /* Release */ = {
5EB250A71B5350580093E304 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "CWNotificationDemo/CWNotificationDemo-Prefix.pch";
INFOPLIST_FILE = "CWNotificationDemo/CWNotificationDemo-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
WRAPPER_EXTENSION = app;
};
name = Release;
};
5E2FFB8318367C01003333F8 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/CWNotificationDemo.app/CWNotificationDemo";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
"$(DEVELOPER_FRAMEWORKS_DIR)",
"$(PROJECT_DIR)",
"$(PROJECT_DIR)/CWStatusBarNotification",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "CWNotificationDemo/CWNotificationDemo-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = "CWNotificationDemoTests/CWNotificationDemoTests-Info.plist";
INFOPLIST_FILE = CWNotificationDemo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = CW.CWNotificationDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
WRAPPER_EXTENSION = xctest;
};
name = Debug;
};
5E2FFB8418367C01003333F8 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/CWNotificationDemo.app/CWNotificationDemo";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
"$(DEVELOPER_FRAMEWORKS_DIR)",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "CWNotificationDemo/CWNotificationDemo-Prefix.pch";
INFOPLIST_FILE = "CWNotificationDemoTests/CWNotificationDemoTests-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
WRAPPER_EXTENSION = xctest;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
5E2FFB4E18367C01003333F8 /* Build configuration list for PBXProject "CWNotificationDemo" */ = {
5EB2508E1B5350580093E304 /* Build configuration list for PBXProject "CWNotificationDemo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
5E2FFB7D18367C01003333F8 /* Debug */,
5E2FFB7E18367C01003333F8 /* Release */,
5EB250A31B5350580093E304 /* Debug */,
5EB250A41B5350580093E304 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
5E2FFB7F18367C01003333F8 /* Build configuration list for PBXNativeTarget "CWNotificationDemo" */ = {
5EB250A51B5350580093E304 /* Build configuration list for PBXNativeTarget "CWNotificationDemo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
5E2FFB8018367C01003333F8 /* Debug */,
5E2FFB8118367C01003333F8 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
5E2FFB8218367C01003333F8 /* Build configuration list for PBXNativeTarget "CWNotificationDemoTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
5E2FFB8318367C01003333F8 /* Debug */,
5E2FFB8418367C01003333F8 /* Release */,
5EB250A61B5350580093E304 /* Debug */,
5EB250A71B5350580093E304 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 5E2FFB4B18367C01003333F8 /* Project object */;
rootObject = 5EB2508B1B5350580093E304 /* Project object */;
}
-15
View File
@@ -1,15 +0,0 @@
//
// AppDelegate.h
// CWNotificationDemo
//
// Created by Cezary Wojcik on 11/15/13.
// Copyright (c) 2013 Cezary Wojcik. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
-54
View File
@@ -1,54 +0,0 @@
//
// AppDelegate.m
// CWNotificationDemo
//
// Created by Cezary Wojcik on 11/15/13.
// Copyright (c) 2013 Cezary Wojcik. All rights reserved.
//
#import "AppDelegate.h"
#import "MainViewController.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
MainViewController *mainViewController = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
UINavigationController *navigationController = [UINavigationController new];
self.window.rootViewController = navigationController;
[navigationController pushViewController:mainViewController animated:NO];
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// 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.
// 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.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// 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.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// 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.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// 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.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
+46
View File
@@ -0,0 +1,46 @@
//
// AppDelegate.swift
// CWNotificationDemo
//
// Created by Cezary Wojcik on 7/12/15.
// Copyright © 2015 Cezary Wojcik. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(application: UIApplication) {
// 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.
// 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.
}
func applicationDidEnterBackground(application: UIApplication) {
// 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.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
// 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.
}
func applicationDidBecomeActive(application: UIApplication) {
// 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.
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
@@ -5,16 +5,31 @@
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "29x29",
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8152.3" systemVersion="15A216g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="QpS-sz-u2p">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8124.4"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<scenes>
<!--Main View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="MainViewController" customModule="CWNotificationDemo" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="1UY-SC-Dlj">
<rect key="frame" x="20" y="72" width="560" height="29"/>
<animations/>
<segments>
<segment title="From Top"/>
<segment title="From Bottom"/>
<segment title="From Left"/>
<segment title="From Right"/>
</segments>
</segmentedControl>
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="aiP-me-Edw">
<rect key="frame" x="20" y="108" width="560" height="29"/>
<animations/>
<segments>
<segment title="To Top"/>
<segment title="To Bottom"/>
<segment title="To Left"/>
<segment title="To Right"/>
</segments>
</segmentedControl>
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="01l-OU-YTs">
<rect key="frame" x="20" y="144" width="560" height="29"/>
<animations/>
<segments>
<segment title="Status Bar"/>
<segment title="Navigation Bar"/>
</segments>
</segmentedControl>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="1" minValue="0.0" maxValue="10" translatesAutoresizingMaskIntoConstraints="NO" id="HxP-Xe-Dpi">
<rect key="frame" x="18" y="180" width="564" height="31"/>
<animations/>
<connections>
<action selector="sliderDurationChanged:" destination="BYZ-38-t0r" eventType="valueChanged" id="dH5-wH-CG2"/>
</connections>
</slider>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Duration: " lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1zE-R3-GMR">
<rect key="frame" x="20" y="218" width="75" height="20.5"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Wbo-6H-X5Z">
<rect key="frame" x="98" y="218" width="42" height="20.5"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="1Rz-8M-TP7">
<rect key="frame" x="20" y="248" width="560" height="30"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fcJ-3d-KJL">
<rect key="frame" x="240" y="286" width="121" height="30"/>
<animations/>
<state key="normal" title="Show Notification"/>
<connections>
<action selector="btnShowNotificationPressed:" destination="BYZ-38-t0r" eventType="touchUpInside" id="LRF-Da-EzM"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ry1-EC-da7">
<rect key="frame" x="192" y="324" width="216" height="30"/>
<animations/>
<state key="normal" title="Show Custom View Notification"/>
<connections>
<action selector="btnShowCustomNotificationPressed:" destination="BYZ-38-t0r" eventType="touchUpInside" id="HmQ-6U-Lks"/>
</connections>
</button>
</subviews>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="Wbo-6H-X5Z" firstAttribute="leading" secondItem="1zE-R3-GMR" secondAttribute="trailing" constant="3" id="2LZ-ih-fVM"/>
<constraint firstAttribute="leadingMargin" secondItem="1Rz-8M-TP7" secondAttribute="leading" id="4PN-JI-8I1"/>
<constraint firstAttribute="trailingMargin" secondItem="1UY-SC-Dlj" secondAttribute="trailing" id="7XX-LR-Had"/>
<constraint firstAttribute="leadingMargin" secondItem="aiP-me-Edw" secondAttribute="leading" id="D8i-Ow-rGN"/>
<constraint firstAttribute="trailingMargin" secondItem="01l-OU-YTs" secondAttribute="trailing" id="Ejd-k4-Dee"/>
<constraint firstAttribute="leadingMargin" secondItem="HxP-Xe-Dpi" secondAttribute="leading" id="FNy-pC-mNT"/>
<constraint firstItem="ry1-EC-da7" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="He1-cv-l7M"/>
<constraint firstItem="fcJ-3d-KJL" firstAttribute="top" secondItem="1Rz-8M-TP7" secondAttribute="bottom" constant="8" id="Kxg-bI-RI3"/>
<constraint firstAttribute="trailingMargin" secondItem="HxP-Xe-Dpi" secondAttribute="trailing" id="Rrk-8o-fxZ"/>
<constraint firstItem="1zE-R3-GMR" firstAttribute="top" secondItem="HxP-Xe-Dpi" secondAttribute="bottom" constant="8" id="Sk0-Ka-STc"/>
<constraint firstItem="01l-OU-YTs" firstAttribute="top" secondItem="aiP-me-Edw" secondAttribute="bottom" constant="8" id="SpS-Qt-aDx"/>
<constraint firstItem="1UY-SC-Dlj" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="8" id="VgS-tu-gi8"/>
<constraint firstItem="1Rz-8M-TP7" firstAttribute="top" secondItem="1zE-R3-GMR" secondAttribute="bottom" constant="9.5" id="Wce-Ac-dyK"/>
<constraint firstItem="Wbo-6H-X5Z" firstAttribute="top" secondItem="HxP-Xe-Dpi" secondAttribute="bottom" constant="8" id="WlR-Z4-lCN"/>
<constraint firstItem="ry1-EC-da7" firstAttribute="top" secondItem="fcJ-3d-KJL" secondAttribute="bottom" constant="8" id="WvV-Ik-N5a"/>
<constraint firstAttribute="leadingMargin" secondItem="01l-OU-YTs" secondAttribute="leading" id="ZSd-7u-GUp"/>
<constraint firstAttribute="leadingMargin" secondItem="1zE-R3-GMR" secondAttribute="leading" id="cc7-IT-fib"/>
<constraint firstAttribute="trailingMargin" secondItem="aiP-me-Edw" secondAttribute="trailing" id="d3D-an-x13"/>
<constraint firstItem="HxP-Xe-Dpi" firstAttribute="top" secondItem="01l-OU-YTs" secondAttribute="bottom" constant="8" id="fZk-zk-K9D"/>
<constraint firstItem="fcJ-3d-KJL" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="k5x-T9-oJ0"/>
<constraint firstItem="aiP-me-Edw" firstAttribute="top" secondItem="1UY-SC-Dlj" secondAttribute="bottom" constant="8" id="p3m-Tl-iFj"/>
<constraint firstAttribute="leadingMargin" secondItem="1UY-SC-Dlj" secondAttribute="leading" id="xWP-7N-GSi"/>
<constraint firstAttribute="trailingMargin" secondItem="1Rz-8M-TP7" secondAttribute="trailing" id="xfC-vI-7co"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="IMf-d6-Gvd"/>
<connections>
<outlet property="lblDuration" destination="Wbo-6H-X5Z" id="IGW-kk-vfR"/>
<outlet property="segFromStyle" destination="1UY-SC-Dlj" id="x4R-8M-hC4"/>
<outlet property="segNotificationStyle" destination="01l-OU-YTs" id="3Cy-CG-K5a"/>
<outlet property="segToStyle" destination="aiP-me-Edw" id="Smd-wy-ySI"/>
<outlet property="sliderDuration" destination="HxP-Xe-Dpi" id="abL-wz-PCv"/>
<outlet property="txtNotificationMessage" destination="1Rz-8M-TP7" id="kEW-gR-m1I"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="937" y="1080"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="qR2-eZ-SgX">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="QpS-sz-u2p" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="mIt-JP-OMn">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<animations/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="9ox-hT-OMy"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="kG4-MI-5Nt" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="154" y="1080"/>
</scene>
</scenes>
</document>
@@ -1,16 +0,0 @@
//
// Prefix header
//
// The contents of this file are implicitly included at the beginning of every source file.
//
#import <Availability.h>
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iOS SDK 3.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
+37
View File
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="8173.3" systemVersion="15A263e" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8142"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" animating="YES" style="white" translatesAutoresizingMaskIntoConstraints="NO" id="vcr-0m-Ym1">
<rect key="frame" x="8" y="290" width="20" height="20"/>
<animations/>
<color key="tintColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</activityIndicatorView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="This is a Custom View" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="42O-Eq-exg">
<rect key="frame" x="216" y="289" width="168" height="20.5"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<animations/>
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="42O-Eq-exg" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="0zn-V7-Ozv"/>
<constraint firstItem="vcr-0m-Ym1" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="Epl-JG-bte"/>
<constraint firstItem="42O-Eq-exg" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="NA4-ry-NNm"/>
<constraint firstItem="vcr-0m-Ym1" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="8" id="OrX-Xh-jKc"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
</view>
</objects>
</document>
@@ -1,51 +0,0 @@
{
"images" : [
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"subtype" : "retina4",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -4,16 +4,14 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>CW.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
@@ -21,9 +19,13 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
-25
View File
@@ -1,25 +0,0 @@
//
// MainViewController.h
// CWNotificationDemo
//
// Created by Cezary Wojcik on 11/15/13.
// Copyright (c) 2013 Cezary Wojcik. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "CWStatusBarNotification.h"
@interface MainViewController : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *lblDuration;
@property (weak, nonatomic) IBOutlet UISlider *sliderDuration;
@property (weak, nonatomic) IBOutlet UITextField *txtNotificationMessage;
@property (weak, nonatomic) IBOutlet UISegmentedControl *segFromStyle;
@property (weak, nonatomic) IBOutlet UISegmentedControl *segToStyle;
@property (strong, nonatomic) CWStatusBarNotification *notification;
- (IBAction)sliderDurationChanged:(UISlider *)sender;
- (IBAction)btnShowNotificationPressed:(UIButton *)sender;
@end
-68
View File
@@ -1,68 +0,0 @@
//
// MainViewController.m
// CWNotificationDemo
//
// Created by Cezary Wojcik on 11/15/13.
// Copyright (c) 2013 Cezary Wojcik. All rights reserved.
//
#import "MainViewController.h"
#import "CWStatusBarNotification.h"
@interface MainViewController ()
@end
@implementation MainViewController
@synthesize lblDuration, txtNotificationMessage, sliderDuration;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.title = @"CWStatusBarNotification";
[self updateDurationLabel];
UIFont *font = [UIFont boldSystemFontOfSize:10.0f];
NSDictionary *attributes = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
[self.segFromStyle setTitleTextAttributes:attributes forState:UIControlStateNormal];
[self.segToStyle setTitleTextAttributes:attributes forState:UIControlStateNormal];
// initialize CWNotification
self.notification = [CWStatusBarNotification new];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)updateDurationLabel
{
self.lblDuration.text = [NSString stringWithFormat:@"%f seconds", self.sliderDuration.value];
}
- (IBAction)sliderDurationChanged:(UISlider *)sender
{
[self updateDurationLabel];
}
# pragma mark - show notification
- (IBAction)btnShowNotificationPressed:(UIButton *)sender
{
self.notification.notificationAnimationInStyle = self.segFromStyle.selectedSegmentIndex;
self.notification.notificationAnimationOutStyle = self.segToStyle.selectedSegmentIndex;
[self.notification displayNotificationWithMessage:self.txtNotificationMessage.text forDuration:self.sliderDuration.value];
}
@end
@@ -0,0 +1,94 @@
//
// MainViewController.swift
// CWNotificationDemo
//
// Created by Cezary Wojcik on 7/11/15.
// Copyright © 2015 Cezary Wojcik. All rights reserved.
//
import UIKit
import CWStatusBarNotification
class MainViewController: UIViewController {
// MARK: - IB outlets
@IBOutlet weak var lblDuration: UILabel!
@IBOutlet weak var sliderDuration: UISlider!
@IBOutlet weak var txtNotificationMessage: UITextField!
@IBOutlet weak var segFromStyle: UISegmentedControl!
@IBOutlet weak var segToStyle: UISegmentedControl!
@IBOutlet weak var segNotificationStyle: UISegmentedControl!
// MARK: - properties
let notification = CWStatusBarNotification()
// MARK: - setup
override func viewDidLoad() {
super.viewDidLoad()
self.title = "CWStatusBarNotification"
self.updateDurationLabel()
// setup font
let font = UIFont.boldSystemFontOfSize(10.0)
let attributes = [NSFontAttributeName : font]
self.segFromStyle.setTitleTextAttributes(attributes, forState: .Normal)
self.segToStyle.setTitleTextAttributes(attributes, forState: .Normal)
// set default blue color (since iOS 7.1, default window `tintColor`
// is black)
self.notification.notificationLabelBackgroundColor = UIColor(red: 0.0,
green: 122.0/255.0, blue: 1.0, alpha: 1.0)
}
// MARK: - methods
func updateDurationLabel() {
self.lblDuration.text = NSString(format: "%.1f seconds",
self.sliderDuration.value) as String
}
func setupNotification() {
guard let inStyle = CWNotificationAnimationStyle(rawValue:
self.segFromStyle.selectedSegmentIndex) else {
return
}
guard let outStyle = CWNotificationAnimationStyle(rawValue:
self.segToStyle.selectedSegmentIndex) else {
return
}
guard let notificationStyle = CWNotificationStyle(rawValue:
self.segNotificationStyle.selectedSegmentIndex) else {
return
}
self.notification.notificationAnimationInStyle = inStyle
self.notification.notificationAnimationOutStyle = outStyle
self.notification.notificationStyle = notificationStyle
}
// MARK: - IB actions
@IBAction func sliderDurationChanged(sender: UISlider) {
self.updateDurationLabel()
}
@IBAction func btnShowNotificationPressed(sender: UIButton) {
self.setupNotification()
let duration = NSTimeInterval(self.sliderDuration.value)
self.notification.displayNotificationWithMessage(
self.txtNotificationMessage.text!, forDuration: duration)
}
@IBAction func btnShowCustomNotificationPressed(sender: UIButton) {
self.setupNotification()
let duration = NSTimeInterval(self.sliderDuration.value)
guard let view = NSBundle.mainBundle().loadNibNamed("CustomView",
owner: nil, options: nil)[0] as? UIView else {
return
}
self.notification.displayNotificationWithView(view,
forDuration: duration)
}
}
-107
View File
@@ -1,107 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13A3017" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3747"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MainViewController">
<connections>
<outlet property="lblDuration" destination="oAK-DR-B27" id="roa-nx-2td"/>
<outlet property="segFromStyle" destination="vWx-wx-d32" id="Zvu-PE-8D7"/>
<outlet property="segToStyle" destination="Bza-7R-910" id="CkD-Lr-RCl"/>
<outlet property="sliderDuration" destination="lnj-T4-sfz" id="BYx-MN-Cnz"/>
<outlet property="txtNotificationMessage" destination="VqG-wR-oYI" id="Dgh-h3-sie"/>
<outlet property="view" destination="1" id="3"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="1">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="DId-6z-9ak">
<rect key="frame" x="100" y="269" width="121" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Show Notification">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="btnShowNotificationPressed:" destination="-1" eventType="touchUpInside" id="HRd-ca-gcu"/>
</connections>
</button>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="1" minValue="0.0" maxValue="10" translatesAutoresizingMaskIntoConstraints="NO" id="lnj-T4-sfz">
<rect key="frame" x="18" y="159" width="284" height="34"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<connections>
<action selector="sliderDurationChanged:" destination="-1" eventType="valueChanged" id="bHo-Bt-cG4"/>
</connections>
</slider>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Duration: " lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nHX-St-Osi">
<rect key="frame" x="20" y="200" width="75" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<constraints>
<constraint firstAttribute="width" constant="75" id="Bek-Lg-K7h"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oAK-DR-B27">
<rect key="frame" x="103" y="200" width="197" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Notification Message" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="VqG-wR-oYI">
<rect key="frame" x="20" y="229" width="280" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="Bza-7R-910">
<rect key="frame" x="20" y="123" width="280" height="29"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<segments>
<segment title="To Top"/>
<segment title="To Bottom"/>
<segment title="To Left"/>
<segment title="To Right"/>
</segments>
</segmentedControl>
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="vWx-wx-d32">
<rect key="frame" x="20" y="87" width="280" height="29"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<segments>
<segment title="From Top"/>
<segment title="From Bottom"/>
<segment title="From Left"/>
<segment title="From Right"/>
</segments>
</segmentedControl>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="nHX-St-Osi" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" id="4tg-Qw-ILZ"/>
<constraint firstItem="lnj-T4-sfz" firstAttribute="top" secondItem="Bza-7R-910" secondAttribute="bottom" constant="8" id="6cG-SS-RNU"/>
<constraint firstItem="VqG-wR-oYI" firstAttribute="top" secondItem="nHX-St-Osi" secondAttribute="bottom" constant="8" id="9hr-jC-jbb"/>
<constraint firstAttribute="centerX" secondItem="DId-6z-9ak" secondAttribute="centerX" constant="-0.5" id="ECT-G3-ltp"/>
<constraint firstItem="VqG-wR-oYI" firstAttribute="top" secondItem="lnj-T4-sfz" secondAttribute="bottom" constant="37" id="Iej-w9-X3g"/>
<constraint firstItem="VqG-wR-oYI" firstAttribute="top" secondItem="oAK-DR-B27" secondAttribute="bottom" constant="8" id="PaN-1y-iK6"/>
<constraint firstAttribute="trailing" secondItem="oAK-DR-B27" secondAttribute="trailing" constant="20" id="RHA-aR-sFs"/>
<constraint firstItem="Bza-7R-910" firstAttribute="top" secondItem="vWx-wx-d32" secondAttribute="bottom" constant="8" id="Th2-HC-3XF"/>
<constraint firstItem="lnj-T4-sfz" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" id="WB4-6Z-Na6"/>
<constraint firstItem="DId-6z-9ak" firstAttribute="top" secondItem="VqG-wR-oYI" secondAttribute="bottom" constant="10" id="WNV-wr-Bat"/>
<constraint firstAttribute="trailing" secondItem="Bza-7R-910" secondAttribute="trailing" constant="20" id="h9H-xz-Gmn"/>
<constraint firstItem="vWx-wx-d32" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" id="iK5-oo-S2I"/>
<constraint firstAttribute="trailing" secondItem="lnj-T4-sfz" secondAttribute="trailing" constant="20" id="mKo-JE-12D"/>
<constraint firstItem="VqG-wR-oYI" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" id="rSQ-BG-N1Y"/>
<constraint firstItem="oAK-DR-B27" firstAttribute="leading" secondItem="nHX-St-Osi" secondAttribute="trailing" constant="8" id="s0T-uS-rNG"/>
<constraint firstItem="Bza-7R-910" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" id="tZA-D2-wfU"/>
<constraint firstAttribute="trailing" secondItem="vWx-wx-d32" secondAttribute="trailing" constant="20" id="wbE-dB-geM"/>
<constraint firstAttribute="trailing" secondItem="VqG-wR-oYI" secondAttribute="trailing" constant="20" id="wx3-Mc-klx"/>
<constraint firstAttribute="centerY" secondItem="DId-6z-9ak" secondAttribute="centerY" id="ynw-tb-3sz"/>
</constraints>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
</view>
</objects>
</document>
@@ -1,2 +0,0 @@
/* Localized versions of Info.plist keys */
-18
View File
@@ -1,18 +0,0 @@
//
// main.m
// CWNotificationDemo
//
// Created by Cezary Wojcik on 11/15/13.
// Copyright (c) 2013 Cezary Wojcik. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "CWStatusBarNotification"
s.version = "2.1.1"
s.version = "2.3.1"
s.summary = "A library that creates status bar notifications."
s.description = "CWStatusBarNotification is a library allows you to present a beautiful text-based notification in the status bar."
s.homepage = "http://github.com/cezarywojcik/CWStatusBarNotification"
@@ -0,0 +1,170 @@
// Generated by Apple Swift version 2.0 (swiftlang-700.0.52.2 clang-700.0.65)
#pragma clang diagnostic push
#if defined(__has_include) && __has_include(<swift/objc-prologue.h>)
# include <swift/objc-prologue.h>
#endif
#pragma clang diagnostic ignored "-Wauto-import"
#include <objc/NSObject.h>
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#if defined(__has_include) && __has_include(<uchar.h>)
# include <uchar.h>
#elif !defined(__cplusplus) || __cplusplus < 201103L
typedef uint_least16_t char16_t;
typedef uint_least32_t char32_t;
#endif
typedef struct _NSZone NSZone;
#if !defined(SWIFT_PASTE)
# define SWIFT_PASTE_HELPER(x, y) x##y
# define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y)
#endif
#if !defined(SWIFT_METATYPE)
# define SWIFT_METATYPE(X) Class
#endif
#if defined(__has_attribute) && __has_attribute(objc_runtime_name)
# define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X)))
#else
# define SWIFT_RUNTIME_NAME(X)
#endif
#if defined(__has_attribute) && __has_attribute(swift_name)
# define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X)))
#else
# define SWIFT_COMPILE_NAME(X)
#endif
#if !defined(SWIFT_CLASS_EXTRA)
# define SWIFT_CLASS_EXTRA
#endif
#if !defined(SWIFT_PROTOCOL_EXTRA)
# define SWIFT_PROTOCOL_EXTRA
#endif
#if !defined(SWIFT_ENUM_EXTRA)
# define SWIFT_ENUM_EXTRA
#endif
#if !defined(SWIFT_CLASS)
# if defined(__has_attribute) && __has_attribute(objc_subclassing_restricted)
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA
# define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
# else
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
# define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
# endif
#endif
#if !defined(SWIFT_PROTOCOL)
# define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
# define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
#endif
#if !defined(SWIFT_EXTENSION)
# define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__)
#endif
#if !defined(OBJC_DESIGNATED_INITIALIZER)
# if defined(__has_attribute) && __has_attribute(objc_designated_initializer)
# define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
# else
# define OBJC_DESIGNATED_INITIALIZER
# endif
#endif
#if !defined(SWIFT_ENUM)
# define SWIFT_ENUM(_type, _name) enum _name : _type _name; enum SWIFT_ENUM_EXTRA _name : _type
#endif
typedef float swift_float2 __attribute__((__ext_vector_type__(2)));
typedef float swift_float3 __attribute__((__ext_vector_type__(3)));
typedef float swift_float4 __attribute__((__ext_vector_type__(4)));
typedef double swift_double2 __attribute__((__ext_vector_type__(2)));
typedef double swift_double3 __attribute__((__ext_vector_type__(3)));
typedef double swift_double4 __attribute__((__ext_vector_type__(4)));
typedef int swift_int2 __attribute__((__ext_vector_type__(2)));
typedef int swift_int3 __attribute__((__ext_vector_type__(3)));
typedef int swift_int4 __attribute__((__ext_vector_type__(4)));
#if defined(__has_feature) && __has_feature(modules)
@import ObjectiveC;
@import CoreGraphics;
@import UIKit;
@import Foundation;
#endif
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
typedef SWIFT_ENUM(NSInteger, CWNotificationAnimationStyle) {
CWNotificationAnimationStyleTop = 0,
CWNotificationAnimationStyleBottom = 1,
CWNotificationAnimationStyleLeft = 2,
CWNotificationAnimationStyleRight = 3,
};
typedef SWIFT_ENUM(NSInteger, CWNotificationAnimationType) {
CWNotificationAnimationTypeReplace = 0,
CWNotificationAnimationTypeOverlay = 1,
};
typedef SWIFT_ENUM(NSInteger, CWNotificationStyle) {
CWNotificationStyleStatusBarNotification = 0,
CWNotificationStyleNavigationBarNotification = 1,
};
@class ScrollLabel;
@class UIView;
@class CWWindowContainer;
@class UIColor;
@class UIFont;
@class NSAttributedString;
SWIFT_CLASS("_TtC23CWStatusBarNotification23CWStatusBarNotification")
@interface CWStatusBarNotification : NSObject
@property (nonatomic) ScrollLabel * __nullable notificationLabel;
@property (nonatomic) UIView * __nullable statusBarView;
@property (nonatomic, copy) void (^ __nonnull notificationTappedClosure)(void);
@property (nonatomic) BOOL notificationIsShowing;
@property (nonatomic) BOOL notificationIsDismissing;
@property (nonatomic) CWWindowContainer * __nullable notificationWindow;
@property (nonatomic) UIColor * __nonnull notificationLabelBackgroundColor;
@property (nonatomic) UIColor * __nonnull notificationLabelTextColor;
@property (nonatomic) UIFont * __nonnull notificationLabelFont;
@property (nonatomic) CGFloat notificationLabelHeight;
@property (nonatomic) UIView * __nullable customView;
@property (nonatomic) BOOL multiline;
@property (nonatomic) UIInterfaceOrientationMask supportedInterfaceOrientations;
@property (nonatomic) NSTimeInterval notificationAnimationDuration;
@property (nonatomic) enum CWNotificationStyle notificationStyle;
@property (nonatomic) enum CWNotificationAnimationStyle notificationAnimationInStyle;
@property (nonatomic) enum CWNotificationAnimationStyle notificationAnimationOutStyle;
@property (nonatomic) enum CWNotificationAnimationType notificationAnimationType;
@property (nonatomic) UIStatusBarStyle preferredStatusBarStyle;
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
- (void)displayNotificationWithMessage:(NSString * __nonnull)message completion:(void (^ __nonnull)(void))completion;
- (void)displayNotificationWithMessage:(NSString * __nonnull)message forDuration:(NSTimeInterval)duration;
- (void)displayNotificationWithAttributedString:(NSAttributedString * __nonnull)attributedString completion:(void (^ __nonnull)(void))completion;
- (void)displayNotificationWithAttributedString:(NSAttributedString * __nonnull)attributedString forDuration:(NSTimeInterval)duration;
- (void)displayNotificationWithView:(UIView * __nonnull)view completion:(void (^ __nonnull)(void))completion;
- (void)displayNotificationWithView:(UIView * __nonnull)view forDuration:(NSTimeInterval)duration;
- (void)dismissNotificationWithCompletion:(void (^ __nullable)(void))completion;
- (void)dismissNotification;
@end
@class UIEvent;
@class NSCoder;
SWIFT_CLASS("_TtC23CWStatusBarNotification17CWWindowContainer")
@interface CWWindowContainer : UIWindow
- (UIView * __nullable)hitTest:(CGPoint)pt withEvent:(UIEvent * __nullable)event;
- (nonnull instancetype)initWithFrame:(CGRect)frame OBJC_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder * __nonnull)aDecoder OBJC_DESIGNATED_INITIALIZER;
@end
SWIFT_CLASS("_TtC23CWStatusBarNotification11ScrollLabel")
@interface ScrollLabel : UILabel
- (nullable instancetype)initWithCoder:(NSCoder * __nonnull)aDecoder OBJC_DESIGNATED_INITIALIZER;
- (void)drawTextInRect:(CGRect)rect;
@end
#pragma clang diagnostic pop
@@ -0,0 +1,19 @@
//
// CWStatusBarNotification.h
// CWStatusBarNotification
//
// Created by Cezary Wojcik on 8/27/15.
// Copyright © 2015 Cezary Wojcik. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for CWStatusBarNotification.
FOUNDATION_EXPORT double CWStatusBarNotificationVersionNumber;
//! Project version string for CWStatusBarNotification.
FOUNDATION_EXPORT const unsigned char CWStatusBarNotificationVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <CWStatusBarNotification/PublicHeader.h>
@@ -0,0 +1,10 @@
framework module CWStatusBarNotification {
umbrella header "CWStatusBarNotification.h"
export *
module * { export * }
}
module CWStatusBarNotification.Swift {
header "CWStatusBarNotification-Swift.h"
}
@@ -0,0 +1,167 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>files</key>
<dict>
<key>Headers/CWStatusBarNotification-Swift.h</key>
<data>
sHk9UTdVUQ+K2bnEze4Om700M5g=
</data>
<key>Headers/CWStatusBarNotification.h</key>
<data>
dKyiSWNdnUbx8kFZhyBOJeSw0IM=
</data>
<key>Info.plist</key>
<data>
vnpKR34QNRjEzSLsaiVc3ESfYak=
</data>
<key>Modules/CWStatusBarNotification.swiftmodule/arm.swiftdoc</key>
<data>
G40ZKxZeGbDiufsVP/4VgPLgqGY=
</data>
<key>Modules/CWStatusBarNotification.swiftmodule/arm.swiftmodule</key>
<data>
GgtVi9uEw7MXifjf18ZZ5F6i7jE=
</data>
<key>Modules/CWStatusBarNotification.swiftmodule/arm64.swiftdoc</key>
<data>
Fq4/GBaJtuC5ZnCk+gF/L2KS1cY=
</data>
<key>Modules/CWStatusBarNotification.swiftmodule/arm64.swiftmodule</key>
<data>
ssTzLsTAKPUkfcl07Pa/xiV723g=
</data>
<key>Modules/module.modulemap</key>
<data>
92f/QlE0cBcXT4XFRh5+RB4ItR8=
</data>
</dict>
<key>files2</key>
<dict>
<key>Headers/CWStatusBarNotification-Swift.h</key>
<data>
sHk9UTdVUQ+K2bnEze4Om700M5g=
</data>
<key>Headers/CWStatusBarNotification.h</key>
<data>
dKyiSWNdnUbx8kFZhyBOJeSw0IM=
</data>
<key>Modules/CWStatusBarNotification.swiftmodule/arm.swiftdoc</key>
<data>
G40ZKxZeGbDiufsVP/4VgPLgqGY=
</data>
<key>Modules/CWStatusBarNotification.swiftmodule/arm.swiftmodule</key>
<data>
GgtVi9uEw7MXifjf18ZZ5F6i7jE=
</data>
<key>Modules/CWStatusBarNotification.swiftmodule/arm64.swiftdoc</key>
<data>
Fq4/GBaJtuC5ZnCk+gF/L2KS1cY=
</data>
<key>Modules/CWStatusBarNotification.swiftmodule/arm64.swiftmodule</key>
<data>
ssTzLsTAKPUkfcl07Pa/xiV723g=
</data>
<key>Modules/module.modulemap</key>
<data>
92f/QlE0cBcXT4XFRh5+RB4ItR8=
</data>
</dict>
<key>rules</key>
<dict>
<key>^</key>
<true/>
<key>^.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^version.plist$</key>
<true/>
</dict>
<key>rules2</key>
<dict>
<key>.*\.dSYM($|/)</key>
<dict>
<key>weight</key>
<real>11</real>
</dict>
<key>^</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^(.*/)?\.DS_Store$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>2000</real>
</dict>
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^.*</key>
<true/>
<key>^.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Info\.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^PkgInfo$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^[^/]+$</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^embedded\.provisionprofile$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^version\.plist$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
</dict>
</dict>
</plist>
@@ -1,54 +0,0 @@
//
// CWStatusBarNotification
// CWNotificationDemo
//
// Created by Cezary Wojcik on 11/15/13.
// Copyright (c) 2013 Cezary Wojcik. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface ScrollLabel : UILabel
- (CGFloat)scrollTime;
@end
@interface CWStatusBarNotification : NSObject
typedef NS_ENUM(NSInteger, CWNotificationStyle) {
CWNotificationStyleStatusBarNotification,
CWNotificationStyleNavigationBarNotification
};
typedef NS_ENUM(NSInteger, CWNotificationAnimationStyle) {
CWNotificationAnimationStyleTop,
CWNotificationAnimationStyleBottom,
CWNotificationAnimationStyleLeft,
CWNotificationAnimationStyleRight
};
typedef NS_ENUM(NSInteger, CWNotificationAnimationType) {
CWNotificationAnimationTypeReplace,
CWNotificationAnimationTypeOverlay
};
@property (strong, nonatomic) ScrollLabel *notificationLabel;
@property (strong, nonatomic) UIColor *notificationLabelBackgroundColor;
@property (strong, nonatomic) UIColor *notificationLabelTextColor;
@property (assign, nonatomic) CGFloat notificationLabelHeight;
@property (assign, nonatomic) BOOL multiline;
@property (strong, nonatomic) UIView *statusBarView;
@property (nonatomic) CWNotificationAnimationStyle notificationStyle;
@property (nonatomic) CWNotificationAnimationStyle notificationAnimationInStyle;
@property (nonatomic) CWNotificationAnimationStyle notificationAnimationOutStyle;
@property (nonatomic) CWNotificationAnimationType notificationAnimationType;
@property (nonatomic) BOOL notificationIsShowing;
@property (strong, nonatomic) UIWindow *notificationWindow;
- (void)displayNotificationWithMessage:(NSString *)message forDuration:(CGFloat)duration;
- (void)displayNotificationWithMessage:(NSString *)message completion:(void (^)(void))completion;
- (void)dismissNotification;
@end
@@ -1,340 +0,0 @@
//
// CWStatusBarNotification.m
// CWNotificationDemo
//
// Created by Cezary Wojcik on 11/15/13.
// Copyright (c) 2013 Cezary Wojcik. All rights reserved.
//
#import <QuartzCore/QuartzCore.h>
#import "CWStatusBarNotification.h"
#define STATUS_BAR_ANIMATION_LENGTH 0.25f
#define FONT_SIZE 12.0f
#define PADDING 10.0f
#define SCROLL_SPEED 40.0f
#define SCROLL_DELAY 1.0f
# pragma mark - ScrollLabel
@implementation ScrollLabel {
UIImageView *textImage;
}
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
textImage = [[UIImageView alloc] init];
[self addSubview:textImage];
}
return self;
}
- (CGFloat)fullWidth {
return [self.text sizeWithAttributes:@{NSFontAttributeName: self.font}].width;
}
- (CGFloat)scrollOffset {
if (self.numberOfLines != 1) return 0;
CGRect insetRect = CGRectInset(self.bounds, PADDING, 0);
return MAX(0, [self fullWidth] - insetRect.size.width);
}
- (CGFloat)scrollTime {
return ([self scrollOffset] > 0) ? [self scrollOffset] / SCROLL_SPEED + SCROLL_DELAY : 0;
}
- (void)drawTextInRect:(CGRect)rect {
if ([self scrollOffset] > 0) {
rect.size.width = [self fullWidth] + PADDING * 2;
UIGraphicsBeginImageContextWithOptions(rect.size, NO, [UIScreen mainScreen].scale);
[super drawTextInRect:rect];
textImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[textImage sizeToFit];
[UIView animateWithDuration:[self scrollTime] - SCROLL_DELAY
delay:SCROLL_DELAY
options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut
animations:^{
textImage.transform = CGAffineTransformMakeTranslation(-[self scrollOffset], 0);
} completion:^(BOOL finished) {
}];
} else {
textImage.image = nil;
[super drawTextInRect:CGRectInset(rect, PADDING, 0)];
}
}
@end
# pragma mark - CWStatusBarNotification
@implementation CWStatusBarNotification
@synthesize notificationLabel, notificationLabelBackgroundColor, notificationLabelTextColor, notificationWindow;
@synthesize statusBarView;
@synthesize notificationStyle, notificationIsShowing;
- (CWStatusBarNotification *)init {
self = [super init];
if (self) {
// set defaults
self.notificationLabelBackgroundColor = [[UIApplication sharedApplication] delegate].window.tintColor;
self.notificationLabelTextColor = [UIColor whiteColor];
self.notificationStyle = CWNotificationStyleStatusBarNotification;
self.notificationAnimationInStyle = CWNotificationAnimationStyleBottom;
self.notificationAnimationOutStyle = CWNotificationAnimationStyleBottom;
self.notificationAnimationType = CWNotificationAnimationTypeReplace;
}
return self;
}
# pragma mark - dimensions
- (CGFloat)getStatusBarHeight {
if (self.notificationLabelHeight > 0) {
return self.notificationLabelHeight;
}
CGFloat statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
if (UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.width;
}
return statusBarHeight > 0 ? statusBarHeight : 20;
}
- (CGFloat)getStatusBarWidth {
if (UIDeviceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation)) {
return [UIScreen mainScreen].bounds.size.width;
}
return [UIScreen mainScreen].bounds.size.height;
}
- (CGRect)getNotificationLabelTopFrame {
return CGRectMake(0, -1*[self getNotificationLabelHeight], [self getStatusBarWidth], [self getNotificationLabelHeight]);
}
- (CGRect)getNotificationLabelLeftFrame {
return CGRectMake(-1*[self getStatusBarWidth], 0, [self getStatusBarWidth], [self getNotificationLabelHeight]);
}
- (CGRect)getNotificationLabelRightFrame {
return CGRectMake([self getStatusBarWidth], 0, [self getStatusBarWidth], [self getNotificationLabelHeight]);
}
- (CGRect)getNotificationLabelBottomFrame {
return CGRectMake(0, [self getNotificationLabelHeight], [self getStatusBarWidth], 0);
}
- (CGRect)getNotificationLabelFrame {
return CGRectMake(0, 0, [self getStatusBarWidth], [self getNotificationLabelHeight]);
}
- (CGFloat)getNavigationBarHeight {
if (UIDeviceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation) ||
UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return 44.0f;
}
return 30.0f;
}
- (CGFloat)getNotificationLabelHeight {
switch (self.notificationStyle) {
case CWNotificationStyleStatusBarNotification:
return [self getStatusBarHeight];
case CWNotificationStyleNavigationBarNotification:
return [self getStatusBarHeight] + [self getNavigationBarHeight];
default:
return [self getStatusBarHeight];
}
}
# pragma mark - screen orientation change
- (void)screenOrientationChanged {
self.notificationLabel.frame = [self getNotificationLabelFrame];
self.statusBarView.hidden = YES;
}
# pragma mark - display helpers
- (void)createNotificationLabelWithMessage:(NSString *)message
{
self.notificationLabel = [ScrollLabel new];
self.notificationLabel.numberOfLines = self.multiline ? 0 : 1;
self.notificationLabel.text = message;
self.notificationLabel.textAlignment = NSTextAlignmentCenter;
self.notificationLabel.adjustsFontSizeToFitWidth = NO;
self.notificationLabel.font = [UIFont systemFontOfSize:FONT_SIZE];
self.notificationLabel.backgroundColor = self.notificationLabelBackgroundColor;
self.notificationLabel.textColor = self.notificationLabelTextColor;
self.notificationLabel.clipsToBounds = YES;
switch (self.notificationAnimationInStyle) {
case CWNotificationAnimationStyleTop:
self.notificationLabel.frame = [self getNotificationLabelTopFrame];
break;
case CWNotificationAnimationStyleBottom:
self.notificationLabel.frame = [self getNotificationLabelBottomFrame];
break;
case CWNotificationAnimationStyleLeft:
self.notificationLabel.frame = [self getNotificationLabelLeftFrame];
break;
case CWNotificationAnimationStyleRight:
self.notificationLabel.frame = [self getNotificationLabelRightFrame];
break;
}
}
- (void)createNotificationWindow
{
self.notificationWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.notificationWindow.backgroundColor = [UIColor clearColor];
self.notificationWindow.userInteractionEnabled = NO;
self.notificationWindow.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.notificationWindow.windowLevel = UIWindowLevelStatusBar;
self.notificationWindow.rootViewController = [UIViewController new];
self.notificationWindow.rootViewController.view.bounds = [self getNotificationLabelFrame];
}
- (void)createStatusBarView
{
self.statusBarView = [[UIView alloc] initWithFrame:[self getNotificationLabelFrame]];
self.statusBarView.clipsToBounds = YES;
if (self.notificationAnimationType == CWNotificationAnimationTypeReplace) {
UIView *statusBarImageView = [[UIScreen mainScreen] snapshotViewAfterScreenUpdates:YES];
[self.statusBarView addSubview:statusBarImageView];
}
[self.notificationWindow.rootViewController.view addSubview:self.statusBarView];
[self.notificationWindow.rootViewController.view sendSubviewToBack:self.statusBarView];
}
# pragma mark - frame changing
- (void)firstFrameChange
{
self.notificationLabel.frame = [self getNotificationLabelFrame];
switch (self.notificationAnimationInStyle) {
case CWNotificationAnimationStyleTop:
self.statusBarView.frame = [self getNotificationLabelBottomFrame];
break;
case CWNotificationAnimationStyleBottom:
self.statusBarView.frame = [self getNotificationLabelTopFrame];
break;
case CWNotificationAnimationStyleLeft:
self.statusBarView.frame = [self getNotificationLabelRightFrame];
break;
case CWNotificationAnimationStyleRight:
self.statusBarView.frame = [self getNotificationLabelLeftFrame];
break;
}
}
- (void)secondFrameChange
{
switch (self.notificationAnimationOutStyle) {
case CWNotificationAnimationStyleTop:
self.statusBarView.frame = [self getNotificationLabelBottomFrame];
break;
case CWNotificationAnimationStyleBottom:
self.statusBarView.frame = [self getNotificationLabelTopFrame];
self.notificationLabel.layer.anchorPoint = CGPointMake(0.5f, 1.0f);
self.notificationLabel.center = CGPointMake(self.notificationLabel.center.x, [self getNotificationLabelHeight]);
break;
case CWNotificationAnimationStyleLeft:
self.statusBarView.frame = [self getNotificationLabelRightFrame];
break;
case CWNotificationAnimationStyleRight:
self.statusBarView.frame = [self getNotificationLabelLeftFrame];
break;
}
}
- (void)thirdFrameChange
{
self.statusBarView.frame = [self getNotificationLabelFrame];
switch (self.notificationAnimationOutStyle) {
case CWNotificationAnimationStyleTop:
self.notificationLabel.frame = [self getNotificationLabelTopFrame];
break;
case CWNotificationAnimationStyleBottom:
self.notificationLabel.transform = CGAffineTransformMakeScale(1.0f, 0.0f);
break;
case CWNotificationAnimationStyleLeft:
self.notificationLabel.frame = [self getNotificationLabelLeftFrame];
break;
case CWNotificationAnimationStyleRight:
self.notificationLabel.frame = [self getNotificationLabelRightFrame];
break;
}
}
# pragma mark - display notification
- (void)displayNotificationWithMessage:(NSString *)message completion:(void (^)(void))completion
{
if (!self.notificationIsShowing) {
self.notificationIsShowing = YES;
// create UIWindow
[self createNotificationWindow];
// create UILabel
[self createNotificationLabelWithMessage:message];
// create status bar view
[self createStatusBarView];
// add label to window
[self.notificationWindow.rootViewController.view addSubview:self.notificationLabel];
[self.notificationWindow.rootViewController.view bringSubviewToFront:self.notificationLabel];
[self.notificationWindow setHidden:NO];
// checking for screen orientation change
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenOrientationChanged) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
// animate
[UIView animateWithDuration:STATUS_BAR_ANIMATION_LENGTH animations:^{
[self firstFrameChange];
} completion:^(BOOL finished) {
double delayInSeconds = [self.notificationLabel scrollTime];
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[completion invoke];
});
}];
}
}
- (void)dismissNotification
{
if (self.notificationIsShowing) {
[self secondFrameChange];
[UIView animateWithDuration:STATUS_BAR_ANIMATION_LENGTH animations:^{
[self thirdFrameChange];
} completion:^(BOOL finished) {
[self.notificationLabel removeFromSuperview];
[self.statusBarView removeFromSuperview];
self.notificationWindow = nil;
self.notificationIsShowing = NO;
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
}];
}
}
- (void)displayNotificationWithMessage:(NSString *)message forDuration:(CGFloat)duration
{
[self displayNotificationWithMessage:message completion:^{
double delayInSeconds = duration;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[self dismissNotification];
});
}];
}
@end
@@ -0,0 +1,299 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
5E9AB6E61B8F7A0E003F349E /* CWStatusBarNotification.h in Headers */ = {isa = PBXBuildFile; fileRef = 5E9AB6E51B8F7A0E003F349E /* CWStatusBarNotification.h */; settings = {ATTRIBUTES = (Public, ); }; };
5E9AB6EF1B8F7AA8003F349E /* CWStatusBarNotification.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E9AB6ED1B8F7AA8003F349E /* CWStatusBarNotification.swift */; };
5E9AB6F01B8F7AA8003F349E /* CWStatusBarNotificationUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E9AB6EE1B8F7AA8003F349E /* CWStatusBarNotificationUtils.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
5E9AB6E21B8F7A0E003F349E /* CWStatusBarNotification.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CWStatusBarNotification.framework; sourceTree = BUILT_PRODUCTS_DIR; };
5E9AB6E51B8F7A0E003F349E /* CWStatusBarNotification.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CWStatusBarNotification.h; sourceTree = "<group>"; };
5E9AB6E71B8F7A0E003F349E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5E9AB6ED1B8F7AA8003F349E /* CWStatusBarNotification.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CWStatusBarNotification.swift; sourceTree = "<group>"; };
5E9AB6EE1B8F7AA8003F349E /* CWStatusBarNotificationUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CWStatusBarNotificationUtils.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
5E9AB6DE1B8F7A0E003F349E /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
5E9AB6D81B8F7A0E003F349E = {
isa = PBXGroup;
children = (
5E9AB6E41B8F7A0E003F349E /* CWStatusBarNotification */,
5E9AB6E31B8F7A0E003F349E /* Products */,
);
sourceTree = "<group>";
};
5E9AB6E31B8F7A0E003F349E /* Products */ = {
isa = PBXGroup;
children = (
5E9AB6E21B8F7A0E003F349E /* CWStatusBarNotification.framework */,
);
name = Products;
sourceTree = "<group>";
};
5E9AB6E41B8F7A0E003F349E /* CWStatusBarNotification */ = {
isa = PBXGroup;
children = (
5E9AB6ED1B8F7AA8003F349E /* CWStatusBarNotification.swift */,
5E9AB6EE1B8F7AA8003F349E /* CWStatusBarNotificationUtils.swift */,
5E9AB6E51B8F7A0E003F349E /* CWStatusBarNotification.h */,
5E9AB6E71B8F7A0E003F349E /* Info.plist */,
);
path = CWStatusBarNotification;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
5E9AB6DF1B8F7A0E003F349E /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
5E9AB6E61B8F7A0E003F349E /* CWStatusBarNotification.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
5E9AB6E11B8F7A0E003F349E /* CWStatusBarNotification */ = {
isa = PBXNativeTarget;
buildConfigurationList = 5E9AB6EA1B8F7A0E003F349E /* Build configuration list for PBXNativeTarget "CWStatusBarNotification" */;
buildPhases = (
5E9AB6DD1B8F7A0E003F349E /* Sources */,
5E9AB6DE1B8F7A0E003F349E /* Frameworks */,
5E9AB6DF1B8F7A0E003F349E /* Headers */,
5E9AB6E01B8F7A0E003F349E /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = CWStatusBarNotification;
productName = CWStatusBarNotification;
productReference = 5E9AB6E21B8F7A0E003F349E /* CWStatusBarNotification.framework */;
productType = "com.apple.product-type.framework";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
5E9AB6D91B8F7A0E003F349E /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = "Cezary Wojcik";
TargetAttributes = {
5E9AB6E11B8F7A0E003F349E = {
CreatedOnToolsVersion = 7.0;
};
};
};
buildConfigurationList = 5E9AB6DC1B8F7A0E003F349E /* Build configuration list for PBXProject "CWStatusBarNotification" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 5E9AB6D81B8F7A0E003F349E;
productRefGroup = 5E9AB6E31B8F7A0E003F349E /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
5E9AB6E11B8F7A0E003F349E /* CWStatusBarNotification */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
5E9AB6E01B8F7A0E003F349E /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
5E9AB6DD1B8F7A0E003F349E /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5E9AB6F01B8F7AA8003F349E /* CWStatusBarNotificationUtils.swift in Sources */,
5E9AB6EF1B8F7AA8003F349E /* CWStatusBarNotification.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
5E9AB6E81B8F7A0E003F349E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
DEFINES_MODULE = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Debug;
};
5E9AB6E91B8F7A0E003F349E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Release;
};
5E9AB6EB1B8F7A0E003F349E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = CWStatusBarNotification/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = CW.CWStatusBarNotification;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
5E9AB6EC1B8F7A0E003F349E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = CWStatusBarNotification/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = CW.CWStatusBarNotification;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
5E9AB6DC1B8F7A0E003F349E /* Build configuration list for PBXProject "CWStatusBarNotification" */ = {
isa = XCConfigurationList;
buildConfigurations = (
5E9AB6E81B8F7A0E003F349E /* Debug */,
5E9AB6E91B8F7A0E003F349E /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
5E9AB6EA1B8F7A0E003F349E /* Build configuration list for PBXNativeTarget "CWStatusBarNotification" */ = {
isa = XCConfigurationList;
buildConfigurations = (
5E9AB6EB1B8F7A0E003F349E /* Debug */,
5E9AB6EC1B8F7A0E003F349E /* Release */,
);
defaultConfigurationIsVisible = 0;
};
/* End XCConfigurationList section */
};
rootObject = 5E9AB6D91B8F7A0E003F349E /* Project object */;
}
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5E9AB6E11B8F7A0E003F349E"
BuildableName = "CWStatusBarNotification.framework"
BlueprintName = "CWStatusBarNotification"
ReferencedContainer = "container:CWStatusBarNotification.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5E9AB6E11B8F7A0E003F349E"
BuildableName = "CWStatusBarNotification.framework"
BlueprintName = "CWStatusBarNotification"
ReferencedContainer = "container:CWStatusBarNotification.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5E9AB6E11B8F7A0E003F349E"
BuildableName = "CWStatusBarNotification.framework"
BlueprintName = "CWStatusBarNotification"
ReferencedContainer = "container:CWStatusBarNotification.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -0,0 +1,19 @@
//
// CWStatusBarNotification.h
// CWStatusBarNotification
//
// Created by Cezary Wojcik on 8/27/15.
// Copyright © 2015 Cezary Wojcik. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for CWStatusBarNotification.
FOUNDATION_EXPORT double CWStatusBarNotificationVersionNumber;
//! Project version string for CWStatusBarNotification.
FOUNDATION_EXPORT const unsigned char CWStatusBarNotificationVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <CWStatusBarNotification/PublicHeader.h>
@@ -0,0 +1,526 @@
//
// CWStatusBarNotification.swift
// CWNotificationDemo
//
// Created by Cezary Wojcik on 7/12/15.
// Copyright © 2015 Cezary Wojcik. All rights reserved.
//
import UIKit
// MARK: - enums
@objc public enum CWNotificationStyle : Int {
case StatusBarNotification
case NavigationBarNotification
}
@objc public enum CWNotificationAnimationStyle : Int {
case Top
case Bottom
case Left
case Right
}
@objc public enum CWNotificationAnimationType : Int {
case Replace
case Overlay
}
// MARK: - CWStatusBarNotification
public class CWStatusBarNotification : NSObject {
// MARK: - properties
private let fontSize : CGFloat = 10.0
private var tapGestureRecognizer : UITapGestureRecognizer!
private var dismissHandle : CWDelayedClosureHandle?
private var isCustomView : Bool
public var notificationLabel : ScrollLabel?
public var statusBarView : UIView?
public var notificationTappedClosure : () -> ()
public var notificationIsShowing = false
public var notificationIsDismissing = false
public var notificationWindow : CWWindowContainer?
public var notificationLabelBackgroundColor : UIColor
public var notificationLabelTextColor : UIColor
public var notificationLabelFont : UIFont
public var notificationLabelHeight : CGFloat
public var customView : UIView?
public var multiline : Bool
public var supportedInterfaceOrientations : UIInterfaceOrientationMask
public var notificationAnimationDuration : NSTimeInterval
public var notificationStyle : CWNotificationStyle
public var notificationAnimationInStyle : CWNotificationAnimationStyle
public var notificationAnimationOutStyle : CWNotificationAnimationStyle
public var notificationAnimationType : CWNotificationAnimationType
public var preferredStatusBarStyle : UIStatusBarStyle
// MARK: - setup
public override init() {
if let tintColor = UIApplication.sharedApplication().delegate?.window??
.tintColor {
self.notificationLabelBackgroundColor = tintColor
} else {
self.notificationLabelBackgroundColor = UIColor.blackColor()
}
self.notificationLabelTextColor = UIColor.whiteColor()
self.notificationLabelFont = UIFont.systemFontOfSize(self.fontSize)
self.notificationLabelHeight = 0.0
self.customView = nil
self.multiline = false
if let supportedInterfaceOrientations = UIApplication
.sharedApplication().keyWindow?.rootViewController?
.supportedInterfaceOrientations() {
self.supportedInterfaceOrientations = supportedInterfaceOrientations
} else {
self.supportedInterfaceOrientations = .All
}
self.notificationAnimationDuration = 0.25
self.notificationStyle = .StatusBarNotification
self.notificationAnimationInStyle = .Bottom
self.notificationAnimationOutStyle = .Bottom
self.notificationAnimationType = .Replace
self.notificationIsDismissing = false
self.isCustomView = false
self.preferredStatusBarStyle = .Default
self.dismissHandle = nil
// make swift happy
self.notificationTappedClosure = {}
super.init()
// create default tap closure
self.notificationTappedClosure = {
if !self.notificationIsDismissing {
self.dismissNotification()
}
}
// create tap recognizer
self.tapGestureRecognizer = UITapGestureRecognizer(target: self,
action: #selector(CWStatusBarNotification.notificationTapped(_:)))
}
// MARK: - dimensions
private func getStatusBarHeight() -> CGFloat {
if self.notificationLabelHeight > 0 {
return self.notificationLabelHeight
}
var statusBarHeight = UIApplication.sharedApplication().statusBarFrame
.size.height
if systemVersionLessThan("8.0.0") && UIInterfaceOrientationIsLandscape(
UIApplication.sharedApplication().statusBarOrientation) {
statusBarHeight = UIApplication.sharedApplication().statusBarFrame
.size.width
}
return statusBarHeight > 0 ? statusBarHeight : 20
}
private func getStatusBarWidth() -> CGFloat {
if systemVersionLessThan("8.0.0") && UIInterfaceOrientationIsLandscape(
UIApplication.sharedApplication().statusBarOrientation) {
return UIScreen.mainScreen().bounds.size.height
}
return UIScreen.mainScreen().bounds.size.width
}
private func getStatusBarOffset() -> CGFloat {
if self.getStatusBarHeight() == 40.0 {
return -20.0
}
return 0.0
}
private func getNavigationBarHeight() -> CGFloat {
if UIInterfaceOrientationIsPortrait(UIApplication.sharedApplication()
.statusBarOrientation) || UI_USER_INTERFACE_IDIOM() == .Pad {
return 44.0
}
return 30.0
}
private func getNotificationLabelHeight() -> CGFloat {
switch self.notificationStyle {
case .NavigationBarNotification:
return self.getStatusBarHeight() + self.getNavigationBarHeight()
case .StatusBarNotification:
fallthrough
default:
return self.getStatusBarHeight()
}
}
private func getNotificationLabelTopFrame() -> CGRect {
return CGRectMake(0, self.getStatusBarOffset() + -1
* self.getNotificationLabelHeight(), self.getStatusBarWidth(),
self.getNotificationLabelHeight())
}
private func getNotificationLabelBottomFrame() -> CGRect {
return CGRectMake(0, self.getStatusBarOffset()
+ self.getNotificationLabelHeight(), self.getStatusBarWidth(), 0)
}
private func getNotificationLabelLeftFrame() -> CGRect {
return CGRectMake(-1 * self.getStatusBarWidth(),
self.getStatusBarOffset(), self.getStatusBarWidth(),
self.getNotificationLabelHeight())
}
private func getNotificationLabelRightFrame() -> CGRect {
return CGRectMake(self.getStatusBarWidth(), self.getStatusBarOffset(),
self.getStatusBarWidth(), self.getNotificationLabelHeight())
}
private func getNotificationLabelFrame() -> CGRect {
return CGRectMake(0, self.getStatusBarOffset(),
self.getStatusBarWidth(), self.getNotificationLabelHeight())
}
// MARK: - screen orientation change
func updateStatusBarFrame() {
if let view = self.isCustomView ? self.customView :
self.notificationLabel {
view.frame = self.getNotificationLabelFrame()
}
if let statusBarView = self.statusBarView {
statusBarView.hidden = true
}
}
// MARK: - on tap
func notificationTapped(recognizer : UITapGestureRecognizer) {
self.notificationTappedClosure()
}
// MARK: - display helpers
private func setupNotificationView(view : UIView) {
view.clipsToBounds = true
view.userInteractionEnabled = true
view.addGestureRecognizer(self.tapGestureRecognizer)
switch self.notificationAnimationInStyle {
case .Top:
view.frame = self.getNotificationLabelTopFrame()
case .Bottom:
view.frame = self.getNotificationLabelBottomFrame()
case .Left:
view.frame = self.getNotificationLabelLeftFrame()
case .Right:
view.frame = self.getNotificationLabelRightFrame()
}
}
private func createNotificationLabelWithMessage(message : String) {
self.notificationLabel = ScrollLabel()
self.notificationLabel?.numberOfLines = self.multiline ? 0 : 1
self.notificationLabel?.text = message
self.notificationLabel?.textAlignment = .Center
self.notificationLabel?.adjustsFontSizeToFitWidth = false
self.notificationLabel?.font = self.notificationLabelFont
self.notificationLabel?.backgroundColor =
self.notificationLabelBackgroundColor
self.notificationLabel?.textColor = self.notificationLabelTextColor
if self.notificationLabel != nil {
self.setupNotificationView(self.notificationLabel!)
}
}
private func createNotificationWithCustomView(view : UIView) {
self.customView = UIView()
// no autoresizing masks so that we can create constraints manually
view.translatesAutoresizingMaskIntoConstraints = false
self.customView?.addSubview(view)
// setup auto layout constraints so that the custom view that is added
// is constrained to be the same size as its superview, whose frame will
// be altered
self.customView?.addConstraint(NSLayoutConstraint(item: view,
attribute: .Trailing, relatedBy: .Equal, toItem: self.customView,
attribute: .Trailing, multiplier: 1.0, constant: 0.0))
self.customView?.addConstraint(NSLayoutConstraint(item: view,
attribute: .Leading, relatedBy: .Equal, toItem: self.customView,
attribute: .Leading, multiplier: 1.0, constant: 0.0))
self.customView?.addConstraint(NSLayoutConstraint(item: view,
attribute: .Top, relatedBy: .Equal, toItem: self.customView,
attribute: .Top, multiplier: 1.0, constant: 0.0))
self.customView?.addConstraint(NSLayoutConstraint(item: view,
attribute: .Bottom, relatedBy: .Equal, toItem: self.customView,
attribute: .Bottom, multiplier: 1.0, constant: 0.0))
if self.customView != nil {
self.setupNotificationView(self.customView!)
}
}
private func createNotificationWindow() {
self.notificationWindow = CWWindowContainer(
frame: UIScreen.mainScreen().bounds)
self.notificationWindow?.backgroundColor = UIColor.clearColor()
self.notificationWindow?.userInteractionEnabled = true
self.notificationWindow?.autoresizingMask = UIViewAutoresizing(
arrayLiteral: .FlexibleWidth, .FlexibleHeight)
self.notificationWindow?.windowLevel = UIWindowLevelStatusBar
let rootViewController = CWViewController()
rootViewController.localSupportedInterfaceOrientations =
self.supportedInterfaceOrientations
rootViewController.localPreferredStatusBarStyle =
self.preferredStatusBarStyle
self.notificationWindow?.rootViewController = rootViewController
self.notificationWindow?.notificationHeight =
self.getNotificationLabelHeight()
}
private func createStatusBarView() {
self.statusBarView = UIView(frame: self.getNotificationLabelFrame())
self.statusBarView?.clipsToBounds = true
if self.notificationAnimationType == .Replace {
let statusBarImageView = UIScreen.mainScreen()
.snapshotViewAfterScreenUpdates(true)
self.statusBarView?.addSubview(statusBarImageView)
}
if self.statusBarView != nil {
self.notificationWindow?.rootViewController?.view
.addSubview(self.statusBarView!)
self.notificationWindow?.rootViewController?.view
.sendSubviewToBack(self.statusBarView!)
}
}
// MARK: - frame changing
private func firstFrameChange() {
guard let view = self.isCustomView ? self.customView :
self.notificationLabel where self.statusBarView != nil else {
return
}
view.frame = self.getNotificationLabelFrame()
switch self.notificationAnimationInStyle {
case .Top:
self.statusBarView!.frame = self.getNotificationLabelBottomFrame()
case .Bottom:
self.statusBarView!.frame = self.getNotificationLabelTopFrame()
case .Left:
self.statusBarView!.frame = self.getNotificationLabelRightFrame()
case .Right:
self.statusBarView!.frame = self.getNotificationLabelLeftFrame()
}
}
private func secondFrameChange() {
guard let view = self.isCustomView ? self.customView :
self.notificationLabel where self.statusBarView != nil else {
return
}
switch self.notificationAnimationOutStyle {
case .Top:
self.statusBarView!.frame = self.getNotificationLabelBottomFrame()
case .Bottom:
self.statusBarView!.frame = self.getNotificationLabelTopFrame()
view.layer.anchorPoint = CGPointMake(0.5, 1.0)
view.center = CGPointMake(view.center.x, self.getStatusBarOffset()
+ self.getNotificationLabelHeight())
case .Left:
self.statusBarView!.frame = self.getNotificationLabelRightFrame()
case .Right:
self.statusBarView!.frame = self.getNotificationLabelLeftFrame()
}
}
private func thirdFrameChange() {
guard let view = self.isCustomView ? self.customView :
self.notificationLabel where self.statusBarView != nil else {
return
}
self.statusBarView!.frame = self.getNotificationLabelFrame()
switch self.notificationAnimationOutStyle {
case .Top:
view.frame = self.getNotificationLabelTopFrame()
case .Bottom:
view.transform = CGAffineTransformMakeScale(1.0, 0.01)
case .Left:
view.frame = self.getNotificationLabelLeftFrame()
case .Right:
view.frame = self.getNotificationLabelRightFrame()
}
}
// MARK: - display notification
public func displayNotificationWithMessage(message : String,
completion : () -> ()) {
guard !self.notificationIsShowing else {
return
}
self.isCustomView = false
self.notificationIsShowing = true
// create window
self.createNotificationWindow()
// create label
self.createNotificationLabelWithMessage(message)
// create status bar view
self.createStatusBarView()
// add label to window
guard let label = self.notificationLabel else {
return
}
self.notificationWindow?.rootViewController?.view.addSubview(label)
self.notificationWindow?.rootViewController?.view.bringSubviewToFront(
label)
self.notificationWindow?.hidden = false
// checking for screen orientation change
NSNotificationCenter.defaultCenter().addObserver(self,
selector: #selector(CWStatusBarNotification.updateStatusBarFrame),
name: UIApplicationDidChangeStatusBarFrameNotification,
object: nil)
// checking for status bar change
NSNotificationCenter.defaultCenter().addObserver(self,
selector: #selector(CWStatusBarNotification.updateStatusBarFrame),
name: UIApplicationWillChangeStatusBarFrameNotification,
object: nil)
// animate
UIView.animateWithDuration(self.notificationAnimationDuration,
animations: { () -> () in
self.firstFrameChange()
}) { (finished) -> () in
if let delayInSeconds = self.notificationLabel?.scrollTime() {
performClosureAfterDelay(Double(delayInSeconds), closure: {
() -> () in
completion()
})
}
}
}
public func displayNotificationWithMessage(message : String,
forDuration duration : NSTimeInterval) {
self.displayNotificationWithMessage(message) { () -> () in
self.dismissHandle = performClosureAfterDelay(duration, closure: {
() -> () in
self.dismissNotification()
})
}
}
public func displayNotificationWithAttributedString(
attributedString : NSAttributedString, completion : () -> ()) {
self.displayNotificationWithMessage(attributedString.string,
completion: completion)
self.notificationLabel?.attributedText = attributedString
}
public func displayNotificationWithAttributedString(
attributedString : NSAttributedString,
forDuration duration : NSTimeInterval) {
self.displayNotificationWithMessage(attributedString.string,
forDuration: duration)
self.notificationLabel?.attributedText = attributedString
}
public func displayNotificationWithView(view : UIView, completion : () -> ()) {
guard !self.notificationIsShowing else {
return
}
self.isCustomView = true
self.notificationIsShowing = true
// create window
self.createNotificationWindow()
// setup custom view
self.createNotificationWithCustomView(view)
// create status bar view
self.createStatusBarView()
// add view to window
if let rootView = self.notificationWindow?.rootViewController?.view,
let customView = self.customView {
rootView.addSubview(customView)
rootView.bringSubviewToFront(customView)
self.notificationWindow!.hidden = false
}
// checking for screen orientation change
NSNotificationCenter.defaultCenter().addObserver(self,
selector: #selector(CWStatusBarNotification.updateStatusBarFrame),
name: UIApplicationDidChangeStatusBarFrameNotification,
object: nil)
// checking for status bar change
NSNotificationCenter.defaultCenter().addObserver(self,
selector: #selector(CWStatusBarNotification.updateStatusBarFrame),
name: UIApplicationWillChangeStatusBarFrameNotification,
object: nil)
// animate
UIView.animateWithDuration(self.notificationAnimationDuration,
animations: { () -> () in
self.firstFrameChange()
}) { (finished) -> () in
completion()
}
}
public func displayNotificationWithView(view : UIView,
forDuration duration : NSTimeInterval) {
self.displayNotificationWithView(view) { () -> () in
self.dismissHandle = performClosureAfterDelay(duration, closure: { () -> Void in
self.dismissNotification()
})
}
}
public func dismissNotificationWithCompletion(completion : (() -> ())?) {
cancelDelayedClosure(self.dismissHandle)
self.notificationIsDismissing = true
self.secondFrameChange()
UIView.animateWithDuration(self.notificationAnimationDuration,
animations: { () -> () in
self.thirdFrameChange()
}) { (finished) -> () in
guard let view = self.isCustomView ? self.customView :
self.notificationLabel else {
return
}
view.removeFromSuperview()
self.statusBarView?.removeFromSuperview()
self.notificationWindow?.hidden = true
self.notificationWindow = nil
self.customView = nil
self.notificationLabel = nil
self.notificationIsShowing = false
self.notificationIsDismissing = false
NSNotificationCenter.defaultCenter().removeObserver(self,
name: UIApplicationDidChangeStatusBarFrameNotification,
object: nil)
NSNotificationCenter.defaultCenter().removeObserver(self,
name: UIApplicationWillChangeStatusBarFrameNotification,
object: nil)
if completion != nil {
completion!()
}
}
}
public func dismissNotification() {
self.dismissNotificationWithCompletion(nil)
}
}
@@ -0,0 +1,178 @@
//
// CWStatusBarNotificationUtils.swift
// CWNotificationDemo
//
// Created by Cezary Wojcik on 7/11/15.
// Copyright © 2015 Cezary Wojcik. All rights reserved.
//
import UIKit
// MARK: - helper functions
func systemVersionLessThan(value : String) -> Bool {
return UIDevice.currentDevice().systemVersion.compare(value,
options: NSStringCompareOptions.NumericSearch) == .OrderedAscending
}
// MARK: - ScrollLabel
public class ScrollLabel : UILabel {
// MARK: - properties
private let padding : CGFloat = 10.0
private let scrollSpeed : CGFloat = 40.0
private let scrollDelay : CGFloat = 1.0
private var textImage : UIImageView?
// MARK: - setup
override init(frame: CGRect) {
super.init(frame: frame)
self.textImage = UIImageView()
self.addSubview(self.textImage!)
}
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override public func drawTextInRect(rect: CGRect) {
guard self.scrollOffset() > 0 else {
self.textImage = nil
super.drawTextInRect(CGRectInset(rect, padding, 0))
return
}
guard let textImage = self.textImage else {
return
}
var frame = rect // because rect is immutable
frame.size.width = self.fullWidth() + padding * 2
UIGraphicsBeginImageContextWithOptions(frame.size, false,
UIScreen.mainScreen().scale)
super.drawTextInRect(frame)
textImage.image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
textImage.sizeToFit()
UIView.animateWithDuration(NSTimeInterval(self.scrollTime()
- scrollDelay),
delay: NSTimeInterval(scrollDelay),
options: UIViewAnimationOptions(arrayLiteral:
UIViewAnimationOptions.BeginFromCurrentState,
UIViewAnimationOptions.CurveEaseInOut),
animations: { () -> () in
textImage.transform = CGAffineTransformMakeTranslation(-1
* self.scrollOffset(), 0)
}, completion: nil)
}
// MARK - methods
private func fullWidth() -> CGFloat {
guard let content = self.text else {
return 0.0
}
let size = NSString(string: content).sizeWithAttributes(
[NSFontAttributeName: self.font])
return size.width
}
private func scrollOffset() -> CGFloat {
guard self.numberOfLines == 1 else {
return 0.0
}
let insetRect = CGRectInset(self.bounds, padding, 0.0)
return max(0, self.fullWidth() - insetRect.size.width)
}
func scrollTime() -> CGFloat {
return self.scrollOffset() > 0 ? self.scrollOffset() / scrollSpeed
+ scrollDelay : 0
}
}
// MARK: - CWWindowContainer
public class CWWindowContainer : UIWindow {
var notificationHeight : CGFloat = 0.0
override public func hitTest(pt: CGPoint, withEvent event: UIEvent?) -> UIView? {
var height : CGFloat = 0.0
if systemVersionLessThan("8.0.0") && UIInterfaceOrientationIsLandscape(
UIApplication.sharedApplication().statusBarOrientation) {
height = UIApplication.sharedApplication().statusBarFrame.size.width
} else {
height = UIApplication.sharedApplication().statusBarFrame.size
.height
}
if pt.y > 0 && pt.y < (self.notificationHeight != 0.0 ?
self.notificationHeight : height) {
return super.hitTest(pt, withEvent: event)
}
return nil
}
}
// MARK: - CWViewController
class CWViewController : UIViewController {
var localPreferredStatusBarStyle : UIStatusBarStyle = .Default
var localSupportedInterfaceOrientations : UIInterfaceOrientationMask = []
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return self.localPreferredStatusBarStyle
}
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return self.localSupportedInterfaceOrientations
}
override func prefersStatusBarHidden() -> Bool {
let statusBarHeight = UIApplication.sharedApplication().statusBarFrame
.size.height
return !(statusBarHeight > 0)
}
}
// MARK: - delayed closure handle
typealias CWDelayedClosureHandle = (Bool) -> ()
func performClosureAfterDelay(seconds : Double, closure: dispatch_block_t?) -> CWDelayedClosureHandle? {
guard closure != nil else {
return nil
}
var closureToExecute : dispatch_block_t! = closure // copy?
var delayHandleCopy : CWDelayedClosureHandle! = nil
let delayHandle : CWDelayedClosureHandle = {
(cancel : Bool) -> () in
if !cancel && closureToExecute != nil {
dispatch_async(dispatch_get_main_queue(), closureToExecute)
}
closureToExecute = nil
delayHandleCopy = nil
}
delayHandleCopy = delayHandle
let delay = Int64(Double(seconds) * Double(NSEC_PER_SEC))
let after = dispatch_time(DISPATCH_TIME_NOW, delay)
dispatch_after(after, dispatch_get_main_queue()) {
if delayHandleCopy != nil {
delayHandleCopy(false)
}
}
return delayHandleCopy
}
func cancelDelayedClosure(delayedHandle : CWDelayedClosureHandle!) {
guard delayedHandle != nil else {
return
}
delayedHandle(true)
}
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
+1 -1
View File
@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2013 Cezary Wojcik <http://www.cezarywojcik.com>
Copyright (c) 2014 Cezary Wojcik <http://www.cezarywojcik.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+54 -35
View File
@@ -1,4 +1,6 @@
# CWStatusBarNotification
# CWStatusBarNotification - Swift Branch
[![Build Status](https://travis-ci.org/cezarywojcik/CWStatusBarNotification.png?branch=master)](https://travis-ci.org/cezarywojcik/CWStatusBarNotification)
`CWStatusBarNotification` is a library that allows you to easily create text-based notifications that appear on the status bar.
@@ -6,48 +8,59 @@
## Requirements
`CWStatusBarNotification` uses ARC and requires iOS 7.0+.
`CWStatusBarNotification` uses Swift 2.0 and requires iOS 7.0+.
Works for iPhone and iPad.
## Installation
### CocoaPods
### Copy Files
`pod 'CWStatusBarNotification', '~> 2.1.1'`
### Manual
Copy the folder `CWStatusBarNotification` to your project.
Copy the two `*.swift` files from `CWStatusBarNotification/CWStatusBarNotification/` into your project.
## Usage
***Note:** The previous version of this library implemented the notifications using a category. This version uses an object instead.*
Firstly, you need the following import statement:
You need to create a `CWStatusBarNotification` object. It is recommended that you do so by attaching it as a property to a view controller.
```
#import "CWStatusBarNotification.h"
let notification = CWStatusBarNotification()
```
Now, you need to create a `CWStatusBarNotification` object. It is recommended that you do so by attaching it as a property to a `UIViewController`.
After you have a `CWStatusBarNotification` object, you can simply call the `displayNotificationMessage(message: String, duration: NSTimeInterval)` method:
```
CWStatusBarNotification *notification = [CWStatusBarNotification new];
```
After you have a `CWStatusBarNotification` object, you can simply call the `displayNotificationMessage:forDuration:` method:
```
[self.notification displayNotificationWithMessage:@"Hello, World!"
forDuration:1.0f];
self.notification.displayNotificationWithMessage("Hello, World!", duration: 1.0)
```
If you prefer to manually choose when to display and dismiss the notification, you can do so as well:
```
[self.notification displayNotificationWithMessage:@"Hello" completion:nil];
self.notification.displayNotificationWithMessage("Hello", completion: nil)
// wait until you need to dismiss
[self.notification dismissNotification];
self.notification.dismissNotification()
```
### Behavior on Tap
The default behavior when the notification is tapped is to dismiss it. However, you can override this behavior by setting the `notificationTappedClosure` closure to something different.
For example:
```
self.notification.notificationTappedClosure = {
println("notification tapped")
// more code here
}
```
Note that overriding this closure means that the notification will no longer be dismissed when tapped. If you want the notification to still dismiss when tapped, make sure to implement the following when overriding the closure:
```
self.notification.notificationTappedClosure = {
if !self.notificationIsDismissing {
self.dismissNotification()
}
// more code here
}
```
## Customizing Appearance
@@ -57,36 +70,42 @@ First of all, you can customize the background color and text color using the fo
Example:
```
notification.notificationLabelBackgroundColor = [UIColor blackColor];
notification.notificationLabelTextColor = [UIColor greenColor];
self.notification.notificationLabelBackgroundColor = UIColor.blackColor()
self.notification.notificationLabelTextColor = UIColor.greenColor()
```
![custom colors](screenshots/ss1.gif)
The default value of `notificationLabelBackgroundColor` is `[[UIApplication sharedApplication] delegate].window.tintColor`.
The default value of `notificationLabelBackgroundColor` is `UIColor.blackColor()`.
The default value of `notification.notificationLabelTextColor` is `[UIColor whiteColor]`.
The default value of `notification.notificationLabelTextColor` is `UIColor.whiteColor()`.
Finally, you can also choose from two styles - a notification the size of the status bar, or a notification the size of the status bar and a navigation bar. Simply change the `notificationStyle` property of the `CWStatusBarNotification` object to either `CWNotificationStyleStatusBarNotification` or `CWNotificationStyleNavigationBarNotification`.
Finally, you can also choose from two styles - a notification the size of the status bar, or a notification the size of the status bar and a navigation bar. Simply change the `notificationStyle` property of the `CWStatusBarNotification` object to either `CWNotificationStyle.StatusBarNotification` or `CWNotificationStyle.NavigationBarNotification`.
Example:
```
self.notification.notificationStyle = .NavigationBarNotification
```
![custom style](screenshots/ss2.gif)
The default value of `notificationStyle` is `CWNotificationStyleStatusBarNotification`.
The default value of `notificationStyle` is `CWNotificationStyle.StatusBarNotification`.
## Customizing Animation
There are two properties that determine the animation style of the notification: `notificationAnimationInStyle` and `notificationAnimationOutStyle`. Each can take on one of four values:
* `CWNotificationAnimationStyleTop`
* `CWNotificationAnimationStyleBottom`
* `CWNotificationAnimationStyleLeft`
* `CWNotificationAnimationStyleRight`
* `CWNotificationAnimationStyle.Top`
* `CWNotificationAnimationStyle.Bottom`
* `CWNotificationAnimationStyle.Left`
* `CWNotificationAnimationStyle.Right`
The `notificationAnimationInStyle` describes where the notification comes from, whereas the `notificationAnimationOutStyle` describes where the notification will go.
The default value for `notificationAnimationInStyle` is `CWNotificationAnimationStyleTop`.
The default value for `notificationAnimationInStyle` is `CWNotificationAnimationStyle.Bottom`.
The default value for `notificationAnimationOutStyle` is `CWNotificationAnimationStyleTop`.
The default value for `notificationAnimationOutStyle` is `CWNotificationAnimationStyle.Bottom`.
### Additional Remarks
@@ -96,7 +115,7 @@ The notifications will work in both screen orientations, however, screen rotatio
The MIT License (MIT)
Copyright (c) 2013 Cezary Wojcik <http://www.cezarywojcik.com>
Copyright (c) 2015 Cezary Wojcik <http://www.cezarywojcik.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1016 KiB

After

Width:  |  Height:  |  Size: 4.6 MiB