Compare commits

...

30 Commits

Author SHA1 Message Date
Cezary Wojcik 8b0884b278 2.1.3 2014-09-19 10:34:28 -07:00
Cezary Wojcik fce4537adf Merge pull request #33 from adomanico/issue/hittest
Fixes issue window hitTest on iOS 7
2014-09-18 20:21:04 -07:00
adomanico 0e03636df6 Fixes issue window hitTest on iOS 7
The landscape window coordinate changes broke the CWWindowContainer
hitTest function. This now handles iOS 7/8 gracefully.
2014-09-18 20:19:05 -07:00
Cezary Wojcik 3b27bd914b 2.1.2 2014-09-10 14:31:54 -07:00
Cezary Wojcik 234ebf1d4c Merge pull request #29 from DocuSignDev/feature/ios8-status-bar-size
Fix iOS 8 status bar width
2014-09-05 07:50:51 -05:00
Stephen Parish 8eda4da7c0 Add ios 7 compatibility to fix for ios 8 status bar widths 2014-09-05 00:47:45 -07:00
Stephen Parish 2a60603b7f enable ios 8 compatibility by being able to trust status bar dimensions
In iOS 8 status bar height and width are actually correct no matter the orientation now. Same for all UIWindows as well.

Fixes #28
2014-09-05 00:34:02 -07:00
Cezary Wojcik bd6b6522a8 Merge pull request #26 from ddwang/master
renamed CompletionBlock to CWCompletionBlock to prevent typedef conflicts
2014-07-30 22:08:43 -05:00
Daniel Wang 7b8fd4cc5c renamed CompletionBlock to CWCompletionBlock to prevent typedef conflicts 2014-07-30 14:26:50 -07:00
Cezary Wojcik 281d12eb46 in call status bar offset 2014-07-08 06:55:09 -05:00
Cezary Wojcik 7a05a62c16 added note about swift version to read me 2014-06-08 14:25:41 -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
Cezary Wojcik 9704c4a593 2.1.1 2014-03-15 15:09:34 -07:00
Cezary Wojcik 2504969cdf fixed from bottom animation 2014-03-15 12:39:30 -07:00
Cezary Wojcik 34574e0309 Merge pull request #11 from mstrchrstphr/master
Update README.md
2014-02-17 17:50:04 -08:00
Christopher Constable 3a0e5081b4 Update README.md 2014-02-17 19:49:00 -05:00
Cezary Wojcik d68d5acaa0 Merge pull request #8 from dannybabiy/master
Allow for longer text, and appearance options for when you don't have a visible status bar.
2013-12-26 22:31:18 -08:00
Danny Babiy 04c750b19f allow for multiline 2013-12-26 21:57:19 -05:00
Danny Babiy 7169617a68 allow to set a custom label height 2013-12-26 14:22:05 -05:00
Danny Babiy e6cee95c7d allow for overlay type of animation 2013-12-26 14:19:53 -05:00
Danny Babiy 2431285d57 scroll long text 2013-12-26 12:40:30 -05:00
Cezary Wojcik d64336e03e cocoapod 2013-11-17 10:27:20 -08:00
Cezary Wojcik e2d2826e6c 2.1.0
added custom display/dismiss methods
2013-11-17 10:11:56 -08:00
Cezary Wojcik 8bd01ad27c Updated screenshot 2013-11-17 00:57:43 -08:00
Cezary Wojcik 2c9bc8677c Updated README and screenshots 2013-11-17 00:56:20 -08:00
13 changed files with 421 additions and 119 deletions
+1
View File
@@ -0,0 +1 @@
language: objective-c
+9 -5
View File
@@ -20,6 +20,7 @@
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 */; };
5E7E40DA19C0F9CF00A0E3E0 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5E7E40D919C0F9CF00A0E3E0 /* LaunchScreen.xib */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -51,6 +52,7 @@
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>"; };
5E7E40D919C0F9CF00A0E3E0 /* LaunchScreen.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LaunchScreen.xib; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -122,6 +124,7 @@
5E2FFB5D18367C01003333F8 /* Supporting Files */ = {
isa = PBXGroup;
children = (
5E7E40D919C0F9CF00A0E3E0 /* LaunchScreen.xib */,
5E2FFB5E18367C01003333F8 /* CWNotificationDemo-Info.plist */,
5E2FFB5F18367C01003333F8 /* InfoPlist.strings */,
5E2FFB6218367C01003333F8 /* main.m */,
@@ -202,7 +205,7 @@
5E2FFB4B18367C01003333F8 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0500;
LastUpgradeCheck = 0510;
ORGANIZATIONNAME = "Cezary Wojcik";
TargetAttributes = {
5E2FFB5218367C01003333F8 = {
@@ -236,6 +239,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5E7E40DA19C0F9CF00A0E3E0 /* LaunchScreen.xib in Resources */,
5E2FFB6118367C01003333F8 /* InfoPlist.strings in Resources */,
5E2FFB8F18367CA3003333F8 /* MainViewController.xib in Resources */,
5E2FFB6918367C01003333F8 /* Images.xcassets in Resources */,
@@ -296,7 +300,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
@@ -336,7 +339,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
@@ -376,8 +378,10 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "CWNotificationDemo/CWNotificationDemo-Prefix.pch";
INFOPLIST_FILE = "CWNotificationDemo/CWNotificationDemo-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
TARGETED_DEVICE_FAMILY = "1,2";
WRAPPER_EXTENSION = app;
};
name = Debug;
@@ -392,8 +396,10 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "CWNotificationDemo/CWNotificationDemo-Prefix.pch";
INFOPLIST_FILE = "CWNotificationDemo/CWNotificationDemo-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
TARGETED_DEVICE_FAMILY = "1,2";
WRAPPER_EXTENSION = app;
};
name = Release;
@@ -401,7 +407,6 @@
5E2FFB8318367C01003333F8 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/CWNotificationDemo.app/CWNotificationDemo";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
@@ -424,7 +429,6 @@
5E2FFB8418367C01003333F8 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/CWNotificationDemo.app/CWNotificationDemo";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
@@ -24,6 +24,8 @@
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
+28
View File
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6245" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment defaultVersion="2048" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/>
</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>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="CWStatusBarNotification" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PyY-2A-t44">
<rect key="frame" x="204.5" y="289" width="192.5" height="21.5"/>
<fontDescription key="fontDescription" name="HelveticaNeue-Light" family="Helvetica Neue" pointSize="18"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="centerY" secondItem="PyY-2A-t44" secondAttribute="centerY" constant="0.5" id="SYW-09-Sb1"/>
<constraint firstAttribute="centerX" secondItem="PyY-2A-t44" secondAttribute="centerX" id="xfo-fo-hOg"/>
</constraints>
</view>
</objects>
</document>
+4
View File
@@ -36,8 +36,12 @@
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];
// set default blue color (since iOS 7.1, default window tintColor is black)
self.notification.notificationLabelBackgroundColor = [UIColor colorWithRed:0.0 green:122.0/255.0 blue:1.0 alpha:1.0];
}
- (void)didReceiveMemoryWarning
+41 -40
View File
@@ -1,7 +1,8 @@
<?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">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6245" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3747"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/>
<capability name="Alignment constraints to the first baseline" minToolsVersion="6.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MainViewController">
@@ -16,12 +17,11 @@
</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"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
<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"/>
<rect key="frame" x="147" y="257" width="121" height="30"/>
<state key="normal" title="Show Notification">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
@@ -30,36 +30,32 @@
</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"/>
<rect key="frame" x="18" y="150" width="378" height="31"/>
<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"/>
<rect key="frame" x="20" y="189" width="75" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="75" id="Bek-Lg-K7h"/>
<constraint firstAttribute="height" constant="21" id="M5r-vA-0qr"/>
<constraint firstAttribute="width" constant="75" id="PQ4-ZU-uu9"/>
</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"/>
<rect key="frame" x="103" y="189" width="291" height="21"/>
<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"/>
<rect key="frame" x="20" y="217" width="374" height="30"/>
<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"/>
<rect key="frame" x="20" y="114" width="374" height="29"/>
<segments>
<segment title="To Top"/>
<segment title="To Bottom"/>
@@ -68,8 +64,7 @@
</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"/>
<rect key="frame" x="20" y="78" width="374" height="29"/>
<segments>
<segment title="From Top"/>
<segment title="From Bottom"/>
@@ -80,28 +75,34 @@
</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"/>
<constraint firstItem="lnj-T4-sfz" firstAttribute="leading" secondItem="nHX-St-Osi" secondAttribute="leading" id="7da-li-6Kn"/>
<constraint firstItem="vWx-wx-d32" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" id="8hY-Bj-MI2"/>
<constraint firstItem="oAK-DR-B27" firstAttribute="leading" secondItem="nHX-St-Osi" secondAttribute="trailing" constant="8" symbolic="YES" id="9ki-g4-vZj"/>
<constraint firstItem="oAK-DR-B27" firstAttribute="trailing" secondItem="lnj-T4-sfz" secondAttribute="trailing" id="DF9-5s-ORR"/>
<constraint firstItem="nHX-St-Osi" firstAttribute="firstBaseline" secondItem="oAK-DR-B27" secondAttribute="firstBaseline" id="ELp-HE-4nH"/>
<constraint firstItem="VqG-wR-oYI" firstAttribute="top" secondItem="nHX-St-Osi" secondAttribute="bottom" constant="7" id="I7c-GM-lko"/>
<constraint firstItem="vWx-wx-d32" firstAttribute="top" secondItem="1" secondAttribute="top" constant="78" id="UEb-Dv-gVI"/>
<constraint firstItem="DId-6z-9ak" firstAttribute="centerX" secondItem="VqG-wR-oYI" secondAttribute="centerX" id="UR8-ES-cIh"/>
<constraint firstItem="DId-6z-9ak" firstAttribute="top" secondItem="VqG-wR-oYI" secondAttribute="bottom" constant="10" id="ZgW-j6-ji5"/>
<constraint firstItem="VqG-wR-oYI" firstAttribute="trailing" secondItem="oAK-DR-B27" secondAttribute="trailing" id="ca3-UN-5wh"/>
<constraint firstItem="vWx-wx-d32" firstAttribute="trailing" secondItem="Bza-7R-910" secondAttribute="trailing" id="exg-le-qML"/>
<constraint firstItem="Bza-7R-910" firstAttribute="leading" secondItem="vWx-wx-d32" secondAttribute="leading" id="iGR-gp-5UT"/>
<constraint firstItem="lnj-T4-sfz" firstAttribute="top" secondItem="Bza-7R-910" secondAttribute="bottom" constant="8" symbolic="YES" id="iOO-Sk-CU0"/>
<constraint firstItem="Bza-7R-910" firstAttribute="trailing" secondItem="lnj-T4-sfz" secondAttribute="trailing" id="pZ0-3h-ZuL"/>
<constraint firstItem="VqG-wR-oYI" firstAttribute="leading" secondItem="nHX-St-Osi" secondAttribute="leading" id="qTt-Y1-xfG"/>
<constraint firstItem="lnj-T4-sfz" firstAttribute="leading" secondItem="Bza-7R-910" secondAttribute="leading" id="tXW-Jb-JXr"/>
<constraint firstItem="vWx-wx-d32" firstAttribute="centerX" secondItem="1" secondAttribute="centerX" id="ulj-gO-yBc"/>
<constraint firstItem="nHX-St-Osi" firstAttribute="top" secondItem="lnj-T4-sfz" secondAttribute="bottom" constant="9" id="w3P-gu-lkL"/>
<constraint firstItem="nHX-St-Osi" firstAttribute="baseline" secondItem="oAK-DR-B27" secondAttribute="baseline" id="xJd-gb-3E0"/>
<constraint firstItem="Bza-7R-910" firstAttribute="top" secondItem="vWx-wx-d32" secondAttribute="bottom" constant="8" symbolic="YES" id="yyp-bu-hx4"/>
</constraints>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
</view>
</objects>
</document>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>
+2 -2
View File
@@ -1,9 +1,9 @@
Pod::Spec.new do |s|
s.name = "CWStatusBarNotification"
s.version = "2.0.0"
s.version = "2.1.3"
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"
s.homepage = "https://github.com/cezarywojcik/CWStatusBarNotification"
s.screenshots = "https://raw.github.com/cezarywojcik/CWStatusBarNotification/master/screenshots/screenshot.png"
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { "Cezary Wojcik" => "me@cezarywojcik.com" }
@@ -8,33 +8,55 @@
#import <Foundation/Foundation.h>
typedef void(^CWCompletionBlock)(void);
@interface ScrollLabel : UILabel
- (CGFloat)scrollTime;
@end
@interface CWWindowContainer : UIWindow
@end
@interface CWStatusBarNotification : NSObject
enum {
typedef NS_ENUM(NSInteger, CWNotificationStyle) {
CWNotificationStyleStatusBarNotification,
CWNotificationStyleNavigationBarNotification
};
enum {
typedef NS_ENUM(NSInteger, CWNotificationAnimationStyle) {
CWNotificationAnimationStyleTop,
CWNotificationAnimationStyleBottom,
CWNotificationAnimationStyleLeft,
CWNotificationAnimationStyleRight
};
@property (strong, nonatomic) UILabel *notificationLabel;
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) NSInteger notificationStyle;
@property (nonatomic) NSInteger notificationAnimationInStyle;
@property (nonatomic) NSInteger notificationAnimationOutStyle;
@property (nonatomic) BOOL notificationIsShowing;
@property (copy, nonatomic) CWCompletionBlock notificationTappedBlock;
@property (strong, nonatomic) UIWindow *notificationWindow;
@property (nonatomic) CWNotificationAnimationStyle notificationStyle;
@property (nonatomic) CWNotificationAnimationStyle notificationAnimationInStyle;
@property (nonatomic) CWNotificationAnimationStyle notificationAnimationOutStyle;
@property (nonatomic) CWNotificationAnimationType notificationAnimationType;
@property (nonatomic) BOOL notificationIsShowing;
@property (nonatomic) BOOL notificationIsDismissing;
@property (strong, nonatomic) CWWindowContainer *notificationWindow;
- (void)displayNotificationWithMessage:(NSString *)message forDuration:(CGFloat)duration;
- (void)displayNotificationWithMessage:(NSString *)message completion:(void (^)(void))completion;
- (void)dismissNotification;
@end
+261 -57
View File
@@ -7,11 +7,147 @@
//
#import <QuartzCore/QuartzCore.h>
#import "CWStatusBarNotification.h"
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#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
@implementation CWWindowContainer
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
CGFloat height;
if (SYSTEM_VERSION_LESS_THAN(@"8.0") && UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
height = [UIApplication sharedApplication].statusBarFrame.size.width;
}
else {
height = [UIApplication sharedApplication].statusBarFrame.size.height;
}
if (point.y > 0 && point.y < height) {
return [super hitTest:point withEvent:event];
}
return nil;
}
@end
# pragma mark - dispatch after with cancellation
// adapted from: https://github.com/Spaceman-Labs/Dispatch-Cancel
typedef void(^CWDelayedBlockHandle)(BOOL cancel);
static CWDelayedBlockHandle perform_block_after_delay(CGFloat seconds, dispatch_block_t block)
{
if (block == nil) {
return nil;
}
__block dispatch_block_t blockToExecute = [block copy];
__block CWDelayedBlockHandle delayHandleCopy = nil;
CWDelayedBlockHandle delayHandle = ^(BOOL cancel){
if (NO == cancel && nil != blockToExecute) {
dispatch_async(dispatch_get_main_queue(), blockToExecute);
}
blockToExecute = nil;
delayHandleCopy = nil;
};
delayHandleCopy = [delayHandle copy];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, seconds * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
if (nil != delayHandleCopy) {
delayHandleCopy(NO);
}
});
return delayHandleCopy;
};
static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
{
if (delayedHandle == nil) {
return;
}
delayedHandle(YES);
}
# 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
@interface CWStatusBarNotification()
@property (strong, nonatomic) UITapGestureRecognizer *tapGestureRecognizer;
@property (strong, nonatomic) CWDelayedBlockHandle dismissHandle;
@end
@implementation CWStatusBarNotification
@@ -21,7 +157,8 @@
@synthesize notificationStyle, notificationIsShowing;
- (CWStatusBarNotification *)init {
- (CWStatusBarNotification *)init
{
self = [super init];
if (self) {
// set defaults
@@ -30,48 +167,81 @@
self.notificationStyle = CWNotificationStyleStatusBarNotification;
self.notificationAnimationInStyle = CWNotificationAnimationStyleBottom;
self.notificationAnimationOutStyle = CWNotificationAnimationStyleBottom;
self.notificationAnimationType = CWNotificationAnimationTypeReplace;
self.notificationIsDismissing = NO;
// create tap recognizer
self.tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(notificationTapped:)];
self.tapGestureRecognizer.numberOfTapsRequired = 1;
// create default tap block
__weak typeof(self) weakSelf = self;
self.notificationTappedBlock = ^(void) {
if (!weakSelf.notificationIsDismissing) {
[weakSelf dismissNotification];
}
};
}
return self;
}
# pragma mark - dimensions
- (CGFloat)getStatusBarHeight {
- (CGFloat)getStatusBarHeight
{
if (self.notificationLabelHeight > 0) {
return self.notificationLabelHeight;
}
CGFloat statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
if (UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
if (SYSTEM_VERSION_LESS_THAN(@"8.0") && UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.width;
}
return statusBarHeight;
return statusBarHeight > 0 ? statusBarHeight : 20;
}
- (CGFloat)getStatusBarWidth {
if (UIDeviceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation)) {
return [UIScreen mainScreen].bounds.size.width;
- (CGFloat)getStatusBarWidth
{
if (SYSTEM_VERSION_LESS_THAN(@"8.0") && UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
return [UIScreen mainScreen].bounds.size.height;
}
return [UIScreen mainScreen].bounds.size.height;
return [UIScreen mainScreen].bounds.size.width;
}
- (CGRect)getNotificationLabelTopFrame {
return CGRectMake(0, -1*[self getNotificationLabelHeight], [self getStatusBarWidth], [self getNotificationLabelHeight]);
- (CGFloat)getStatusBarOffset
{
if ([self getStatusBarHeight] == 40.0f) {
return -20.0f;
}
return 0.0f;
}
- (CGRect)getNotificationLabelLeftFrame {
return CGRectMake(-1*[self getStatusBarWidth], 0, [self getStatusBarWidth], [self getNotificationLabelHeight]);
- (CGRect)getNotificationLabelTopFrame
{
return CGRectMake(0, [self getStatusBarOffset] + -1*[self getNotificationLabelHeight], [self getStatusBarWidth], [self getNotificationLabelHeight]);
}
- (CGRect)getNotificationLabelRightFrame {
return CGRectMake([self getStatusBarWidth], 0, [self getStatusBarWidth], [self getNotificationLabelHeight]);
- (CGRect)getNotificationLabelLeftFrame
{
return CGRectMake(-1*[self getStatusBarWidth], [self getStatusBarOffset], [self getStatusBarWidth], [self getNotificationLabelHeight]);
}
- (CGRect)getNotificationLabelBottomFrame {
return CGRectMake(0, [self getNotificationLabelHeight], [self getStatusBarWidth], 0);
- (CGRect)getNotificationLabelRightFrame
{
return CGRectMake([self getStatusBarWidth], [self getStatusBarOffset], [self getStatusBarWidth], [self getNotificationLabelHeight]);
}
- (CGRect)getNotificationLabelFrame {
return CGRectMake(0, 0, [self getStatusBarWidth], [self getNotificationLabelHeight]);
- (CGRect)getNotificationLabelBottomFrame
{
return CGRectMake(0, [self getStatusBarOffset] + [self getNotificationLabelHeight], [self getStatusBarWidth], 0);
}
- (CGFloat)getNavigationBarHeight {
- (CGRect)getNotificationLabelFrame
{
return CGRectMake(0, [self getStatusBarOffset], [self getStatusBarWidth], [self getNotificationLabelHeight]);
}
- (CGFloat)getNavigationBarHeight
{
if (UIDeviceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation) ||
UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return 44.0f;
@@ -79,7 +249,8 @@
return 30.0f;
}
- (CGFloat)getNotificationLabelHeight {
- (CGFloat)getNotificationLabelHeight
{
switch (self.notificationStyle) {
case CWNotificationStyleStatusBarNotification:
return [self getStatusBarHeight];
@@ -92,22 +263,34 @@
# pragma mark - screen orientation change
- (void)screenOrientationChanged {
- (void)updateStatusBarFrame
{
self.notificationLabel.frame = [self getNotificationLabelFrame];
self.statusBarView.hidden = YES;
}
# pragma mark - on tap
- (void)notificationTapped:(UITapGestureRecognizer*)recognizer
{
[self.notificationTappedBlock invoke];
}
# pragma mark - display helpers
- (void)createNotificationLabelWithMessage:(NSString *)message
{
self.notificationLabel = [UILabel new];
self.notificationLabel = [ScrollLabel new];
self.notificationLabel.numberOfLines = self.multiline ? 0 : 1;
self.notificationLabel.text = message;
self.notificationLabel.textAlignment = NSTextAlignmentCenter;
self.notificationLabel.adjustsFontSizeToFitWidth = YES;
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;
self.notificationLabel.userInteractionEnabled = YES;
[self.notificationLabel addGestureRecognizer:self.tapGestureRecognizer];
switch (self.notificationAnimationInStyle) {
case CWNotificationAnimationStyleTop:
self.notificationLabel.frame = [self getNotificationLabelTopFrame];
@@ -121,27 +304,27 @@
case CWNotificationAnimationStyleRight:
self.notificationLabel.frame = [self getNotificationLabelRightFrame];
break;
}
}
- (void)createNotificationWindow
{
self.notificationWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.notificationWindow = [[CWWindowContainer alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.notificationWindow.backgroundColor = [UIColor clearColor];
self.notificationWindow.userInteractionEnabled = NO;
self.notificationWindow.userInteractionEnabled = YES;
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;
UIView *statusBarImageView = [[UIScreen mainScreen] snapshotViewAfterScreenUpdates:YES];
[self.statusBarView addSubview:statusBarImageView];
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];
}
@@ -176,7 +359,7 @@
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]);
self.notificationLabel.center = CGPointMake(self.notificationLabel.center.x, [self getStatusBarOffset] + [self getNotificationLabelHeight]);
break;
case CWNotificationAnimationStyleLeft:
self.statusBarView.frame = [self getNotificationLabelRightFrame];
@@ -195,7 +378,7 @@
self.notificationLabel.frame = [self getNotificationLabelTopFrame];
break;
case CWNotificationAnimationStyleBottom:
self.notificationLabel.transform = CGAffineTransformMakeScale(1.0f, 0.0f);
self.notificationLabel.transform = CGAffineTransformMakeScale(1.0f, 0.01f);
break;
case CWNotificationAnimationStyleLeft:
self.notificationLabel.frame = [self getNotificationLabelLeftFrame];
@@ -208,51 +391,72 @@
# pragma mark - display notification
- (void)displayNotificationWithMessage:(NSString *)message forDuration:(CGFloat)duration
- (void)displayNotificationWithMessage:(NSString *)message completion:(void (^)(void))completion
{
if (!self.notificationIsShowing) {
self.notificationIsShowing = YES;
// create UIWindow
[self createNotificationWindow];
// create UILabel
// create ScrollLabel
[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];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateStatusBarFrame) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
// checking for status bar change
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateStatusBarFrame) name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
// animate
[UIView animateWithDuration:STATUS_BAR_ANIMATION_LENGTH animations:^{
[self firstFrameChange];
} completion:^(BOOL finished) {
[UIView animateWithDuration:duration - 2*STATUS_BAR_ANIMATION_LENGTH animations:^{
// potential animations while notification is showing
} completion:^(BOOL finished) {
[self secondFrameChange];
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(duration * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[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];
}];
});
}];
double delayInSeconds = [self.notificationLabel scrollTime];
perform_block_after_delay(delayInSeconds, ^{
[completion invoke];
});
}];
}
}
- (void)dismissNotification
{
if (self.notificationIsShowing) {
cancel_delayed_block(self.dismissHandle);
self.notificationIsDismissing = YES;
[self secondFrameChange];
[UIView animateWithDuration:STATUS_BAR_ANIMATION_LENGTH animations:^{
[self thirdFrameChange];
} completion:^(BOOL finished) {
[self.notificationLabel removeFromSuperview];
[self.statusBarView removeFromSuperview];
[self.notificationWindow setHidden:YES];
self.notificationWindow = nil;
self.notificationLabel = nil;
self.notificationIsShowing = NO;
self.notificationIsDismissing = NO;
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
}];
}
}
- (void)displayNotificationWithMessage:(NSString *)message forDuration:(CGFloat)duration
{
[self displayNotificationWithMessage:message completion:^{
self.dismissHandle = perform_block_after_delay(duration, ^{
[self dismissNotification];
});
}];
}
@end
+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
+42 -6
View File
@@ -1,5 +1,9 @@
# CWStatusBarNotification
[![Build Status](https://travis-ci.org/cezarywojcik/CWStatusBarNotification.png?branch=master)](https://travis-ci.org/cezarywojcik/CWStatusBarNotification)
**NOTE:** You can find a `Swift` implementation of this library [in the swift branch of this repo](https://github.com/cezarywojcik/CWStatusBarNotification/tree/swift).
`CWStatusBarNotification` is a library that allows you to easily create text-based notifications that appear on the status bar.
![demo](screenshots/demo.gif)
@@ -14,7 +18,7 @@ Works for iPhone and iPad.
### CocoaPods
`pod 'CWStatusBarNotification', '~> 2.0.0'`
`pod 'CWStatusBarNotification', '~> 2.1.3'`
### Manual
@@ -42,6 +46,40 @@ After you have a `CWStatusBarNotification` object, you can simply call the `disp
forDuration:1.0f];
```
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];
// wait until you need to dismiss
[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 `onTapNotification` block to something different.
For example:
```
self.notification.notificationTappedBlock = ^(void) {
NSLog(@"notification tapped");
// more code here
};
```
Note that overriding this block 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 block:
```
__weak typeof(self) weakSelf = self;
self.notification.notificationTappedBlock = ^(void) {
if (!weakSelf.notificationIsDismissing) {
[weakSelf dismissNotification];
// more code here
}
};
```
## Customizing Appearance
First of all, you can customize the background color and text color using the following properties: `notificationLabelBackgroundColor` and `notificationLabelTextColor`.
@@ -49,8 +87,8 @@ First of all, you can customize the background color and text color using the fo
Example:
```
notification.notificationLabelBackgroundColor = [UIColor redColor];
notification.notificationLabelTextColor = [UIColor yellowColor];
notification.notificationLabelBackgroundColor = [UIColor blackColor];
notification.notificationLabelTextColor = [UIColor greenColor];
```
![custom colors](screenshots/ss1.gif)
@@ -88,7 +126,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) 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
@@ -107,5 +145,3 @@ The notifications will work in both screen orientations, however, screen rotatio
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 237 KiB