Compare commits

...

36 Commits

Author SHA1 Message Date
Cezary Wojcik b87af9f288 2.2.6 2015-05-12 12:17:28 -07:00
Cezary Wojcik 975ca58291 2.2.5 2015-05-04 07:08:59 -07:00
Cezary Wojcik d9d8c1d342 Merge pull request #50 from somethingkindawierd/master
Fix calculation of navbar height
2015-05-01 15:39:11 -07:00
Jon Beebe e700d781cc Fix calculation of navbar height 2015-04-30 11:41:45 -05:00
Cezary Wojcik 6882883e21 2.2.4 2015-04-15 12:16:12 -07:00
Cezary Wojcik 00136b9d3c 2.2.3 2015-04-15 12:07:04 -07:00
Cezary Wojcik 437e5c5860 Merge pull request #49 from basecom/master
Added the ability to hand over supportededInterfaceOrientations
2015-04-13 14:23:57 -07:00
Marius Landwehr eef9cc818c Added the ability to hand over supportededInterfaceOrientations for CWStatusBarNotification. This is optional and the standard value is to support all masks. 2015-04-13 14:07:49 +02:00
Cezary Wojcik e9ba7bdeda Merge pull request #48 from adamtootle/preferred-status-bar-style
preferredStatusBarStyle
2015-04-10 20:16:30 -07:00
Adam Tootle c70f81e35b Adding a new CWViewController class and a new preferredStatusBarStyle property to CWStatusBarNotification for controlling the color of the status bar text in the overlay CWWindowContainer. 2015-04-09 08:32:11 -04:00
Cezary Wojcik 7bae7b4ddc Merge pull request #43 from avgx/master
Allow user to set the font for notificationLabel
2014-11-05 08:16:56 -08:00
avgx bca16517c3 Allow user to set the font for notificationLabel 2014-11-05 12:23:26 +03:00
Cezary Wojcik f4432a86c7 removed some whitespace 2014-10-21 22:20:40 -07:00
Cezary Wojcik fa848141eb updated demo gif 2014-10-21 20:59:21 -07:00
Cezary Wojcik d1b09abe48 updated demo app 2014-10-21 20:47:35 -07:00
Cezary Wojcik 36e5ea38b6 2.2.2 2014-10-21 19:57:35 -07:00
Cezary Wojcik c6fcfa1d2a Merge pull request #42 from drumnkyle/master
Fixing the fix to the hitTest
2014-10-21 19:44:36 -07:00
Kyle Sherman 70e603a058 Fixing the fix to the hitTest
Missing parenthesis made the check pass for the whole screen. Fixed
this issue.
2014-10-21 14:12:50 -07:00
Cezary Wojcik e488b4c76b Merge pull request #41 from drumnkyle/master
Fixing issue #40
2014-10-21 13:13:42 -07:00
Kyle Sherman f1d9606940 Fixing issue #40
Fixing issue #40 where a tap in the notification frame when it is in
the style of NavigationBar would not be detected for the notification
window.
2014-10-21 11:41:50 -07:00
Cezary Wojcik 93750ca9a2 cocoapods lied to me 2014-10-18 11:09:11 -07:00
Cezary Wojcik 34c81e7e93 2.2.1 2014-10-18 11:06:05 -07:00
Cezary Wojcik 9a9dfa63f1 Merge pull request #39 from drumnkyle/master
Adding dismissNotificationWithCompletion method
2014-10-17 16:47:13 -07:00
Kyle Sherman d01eb06cfb Adding dismissNotificationWithCompletion method
Added dismissNotificationWithCompletion method. Left the old method
without completion intact for backwards compatibility.
2014-10-17 16:42:22 -07:00
Cezary Wojcik 9e4e2c7ccb Merge pull request #38 from drumnkyle/master
Added Switch to Demo App and Fixed Custom View Rotation Bug
2014-10-17 16:32:36 -07:00
Kyle Sherman bbe0a06a1e Fixed Auto Layout bug that didn't resize custom view version properly on rotation 2014-10-17 16:27:15 -07:00
Kyle Sherman ff693f7381 Added a switch to the demo project to switch between status bar and notification bar styles to demonstrate the capability clearly. 2014-10-17 11:38:28 -07:00
Cezary Wojcik 4c1e52ca88 ready update 2014-10-16 17:12:27 -07:00
Cezary Wojcik af4ded6872 2.2.0 2014-10-16 17:06:40 -07:00
Cezary Wojcik 81a87fa06d Merge pull request #37 from drumnkyle/master
Added the notion of a custom view in the notification
2014-10-16 16:50:23 -07:00
Kyle Sherman 1514f1a366 Adding the concept of a custom view
Added methods to be able to display a custom view in the notification
and added an example to the demo project.
2014-10-16 16:39:50 -07:00
Kyle Sherman c5d8f86bc6 Merge pull request #1 from cezarywojcik/master
Pulling in latest code
2014-10-16 13:10:22 -07:00
Cezary Wojcik db643d42c7 updated readme 2014-10-09 22:28:57 -07:00
Cezary Wojcik c4feb7c040 2.1.4 2014-10-09 16:28:38 -07:00
Cezary Wojcik 900e0367dd Merge pull request #35 from drumnkyle/patch-1
Fixed the notificationStyle type.
2014-10-09 14:57:24 -07:00
Kyle Sherman 82d36ffbf2 Fixed the notificationStyle type.
The notificationStyle property is of the wrong type, so it is unusable.
2014-10-09 14:51:59 -07:00
12 changed files with 325 additions and 88 deletions
@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
370883CE19F08756000E79D6 /* CustomView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 370883CD19F08756000E79D6 /* CustomView.xib */; };
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 */; };
@@ -34,6 +35,7 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
370883CD19F08756000E79D6 /* CustomView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CustomView.xib; sourceTree = "<group>"; };
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; };
@@ -114,6 +116,7 @@
children = (
5E2FFB6518367C01003333F8 /* AppDelegate.h */,
5E2FFB6618367C01003333F8 /* AppDelegate.m */,
370883CD19F08756000E79D6 /* CustomView.xib */,
5E2FFB8918367C75003333F8 /* View Controllers */,
5E2FFB6818367C01003333F8 /* Images.xcassets */,
5E2FFB5D18367C01003333F8 /* Supporting Files */,
@@ -240,6 +243,7 @@
buildActionMask = 2147483647;
files = (
5E7E40DA19C0F9CF00A0E3E0 /* LaunchScreen.xib in Resources */,
370883CE19F08756000E79D6 /* CustomView.xib in Resources */,
5E2FFB6118367C01003333F8 /* InfoPlist.strings in Resources */,
5E2FFB8F18367CA3003333F8 /* MainViewController.xib in Resources */,
5E2FFB6918367C01003333F8 /* Images.xcassets in Resources */,
+32
View File
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6245" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<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>
<activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" animating="YES" style="white" translatesAutoresizingMaskIntoConstraints="NO" id="r93-cW-Ts4">
<rect key="frame" x="10" y="291" width="20" height="20"/>
</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="z9l-SY-8er">
<rect key="frame" x="218" y="290" width="165" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="0.098039224743843079" green="0.58039218187332153" blue="0.9803922176361084" alpha="1" colorSpace="deviceRGB"/>
<constraints>
<constraint firstAttribute="centerX" secondItem="z9l-SY-8er" secondAttribute="centerX" id="64P-Uw-ajT"/>
<constraint firstItem="r93-cW-Ts4" firstAttribute="centerY" secondItem="z9l-SY-8er" secondAttribute="centerY" id="Qc1-1z-FyY"/>
<constraint firstItem="r93-cW-Ts4" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="10" id="R3u-Kd-l55"/>
<constraint firstAttribute="centerY" secondItem="z9l-SY-8er" secondAttribute="centerY" id="pzf-Hi-YQD"/>
</constraints>
</view>
</objects>
</document>
@@ -15,6 +15,11 @@
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "29x29",
+2 -3
View File
@@ -1,8 +1,7 @@
<?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">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6250" systemVersion="14A388a" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment defaultVersion="2048" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
+2
View File
@@ -16,10 +16,12 @@
@property (weak, nonatomic) IBOutlet UITextField *txtNotificationMessage;
@property (weak, nonatomic) IBOutlet UISegmentedControl *segFromStyle;
@property (weak, nonatomic) IBOutlet UISegmentedControl *segToStyle;
@property (weak, nonatomic) IBOutlet UISegmentedControl *notificationStyle;
@property (strong, nonatomic) CWStatusBarNotification *notification;
- (IBAction)sliderDurationChanged:(UISlider *)sender;
- (IBAction)btnShowNotificationPressed:(UIButton *)sender;
- (IBAction)btnShowCustomNotificationPressed:(UIButton *)sender;
@end
+14 -1
View File
@@ -62,11 +62,24 @@
# pragma mark - show notification
- (IBAction)btnShowNotificationPressed:(UIButton *)sender
- (void)setupNotification
{
self.notification.notificationAnimationInStyle = self.segFromStyle.selectedSegmentIndex;
self.notification.notificationAnimationOutStyle = self.segToStyle.selectedSegmentIndex;
self.notification.notificationStyle = self.notificationStyle.selectedSegmentIndex == 0 ?
CWNotificationStyleStatusBarNotification : CWNotificationStyleNavigationBarNotification;
}
- (IBAction)btnShowNotificationPressed:(UIButton *)sender
{
[self setupNotification];
[self.notification displayNotificationWithMessage:self.txtNotificationMessage.text forDuration:self.sliderDuration.value];
}
- (IBAction)btnShowCustomNotificationPressed:(UIButton *)sender {
[self setupNotification];
UIView *view = [[NSBundle mainBundle] loadNibNamed:@"CustomView" owner:nil options:nil][0];
[self.notification displayNotificationWithView:view forDuration:self.sliderDuration.value];
}
@end
+50 -32
View File
@@ -1,13 +1,13 @@
<?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">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6250" systemVersion="14A388a" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/>
<capability name="Alignment constraints to the first baseline" minToolsVersion="6.0"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
</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="notificationStyle" destination="fcn-wc-llO" id="6cr-5b-6JN"/>
<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"/>
@@ -21,7 +21,7 @@
<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="147" y="257" width="121" height="30"/>
<rect key="frame" x="147" y="293" width="121" height="30"/>
<state key="normal" title="Show Notification">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
@@ -30,27 +30,23 @@
</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="150" width="378" height="31"/>
<rect key="frame" x="18" y="186" 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="189" width="75" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="M5r-vA-0qr"/>
<constraint firstAttribute="width" constant="75" id="PQ4-ZU-uu9"/>
</constraints>
<rect key="frame" x="20" y="225" width="75" height="20.5"/>
<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="189" width="291" height="21"/>
<rect key="frame" x="103" y="225" width="291" height="20.5"/>
<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="217" width="374" height="30"/>
<rect key="frame" x="20" y="253" width="374" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
@@ -72,29 +68,51 @@
<segment title="From Right"/>
</segments>
</segmentedControl>
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="fcn-wc-llO">
<rect key="frame" x="20" y="150" width="374" height="29"/>
<segments>
<segment title="Status Bar"/>
<segment title="Navigation Bar"/>
</segments>
</segmentedControl>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="E8G-aN-rjr">
<rect key="frame" x="99" y="331" width="216" height="30"/>
<state key="normal" title="Show Custom View Notification">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="btnShowCustomNotificationPressed:" destination="-1" eventType="touchUpInside" id="LIQ-4P-I0D"/>
<action selector="btnShowNotificationPressed:" destination="-1" eventType="touchUpInside" id="jNW-Ie-NPn"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<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"/>
<constraint firstItem="vWx-wx-d32" firstAttribute="top" secondItem="1" secondAttribute="top" constant="78" id="1oB-rT-mPo"/>
<constraint firstAttribute="centerX" secondItem="fcn-wc-llO" secondAttribute="centerX" id="2Vh-Y9-bR5"/>
<constraint firstItem="oAK-DR-B27" firstAttribute="top" secondItem="lnj-T4-sfz" secondAttribute="bottom" constant="9" id="6zC-Vn-47H"/>
<constraint firstAttribute="centerX" secondItem="E8G-aN-rjr" secondAttribute="centerX" id="9d1-PR-JUW"/>
<constraint firstItem="fcn-wc-llO" firstAttribute="top" secondItem="Bza-7R-910" secondAttribute="bottom" constant="8" id="CXZ-Xq-PaS"/>
<constraint firstAttribute="centerX" secondItem="VqG-wR-oYI" secondAttribute="centerX" id="EZF-ae-sk0"/>
<constraint firstItem="DId-6z-9ak" firstAttribute="top" secondItem="VqG-wR-oYI" secondAttribute="bottom" constant="10" id="Koz-Hg-zs6"/>
<constraint firstItem="oAK-DR-B27" firstAttribute="leading" secondItem="nHX-St-Osi" secondAttribute="trailing" constant="8" id="Rv3-LK-x94"/>
<constraint firstItem="vWx-wx-d32" firstAttribute="width" secondItem="Bza-7R-910" secondAttribute="width" id="TLh-rn-5OJ"/>
<constraint firstItem="VqG-wR-oYI" firstAttribute="width" secondItem="fcn-wc-llO" secondAttribute="width" id="VN0-NS-cxS"/>
<constraint firstItem="fcn-wc-llO" firstAttribute="width" secondItem="lnj-T4-sfz" secondAttribute="width" id="VaZ-W0-jE9"/>
<constraint firstItem="nHX-St-Osi" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" id="am1-tr-889"/>
<constraint firstItem="fcn-wc-llO" firstAttribute="width" secondItem="Bza-7R-910" secondAttribute="width" id="e4t-sE-dFP"/>
<constraint firstAttribute="centerX" secondItem="DId-6z-9ak" secondAttribute="centerX" constant="-0.5" id="eaF-Ou-aly"/>
<constraint firstAttribute="trailing" secondItem="vWx-wx-d32" secondAttribute="trailing" constant="20" id="fax-Hs-B09"/>
<constraint firstItem="fcn-wc-llO" firstAttribute="width" secondItem="oAK-DR-B27" secondAttribute="width" constant="83" id="gJx-JQ-AKj"/>
<constraint firstItem="Bza-7R-910" firstAttribute="top" secondItem="vWx-wx-d32" secondAttribute="bottom" constant="8" id="iKn-wI-ama"/>
<constraint firstAttribute="centerX" secondItem="lnj-T4-sfz" secondAttribute="centerX" id="mud-VX-xYt"/>
<constraint firstItem="nHX-St-Osi" firstAttribute="top" secondItem="lnj-T4-sfz" secondAttribute="bottom" constant="9" id="oWk-lv-8CY"/>
<constraint firstItem="VqG-wR-oYI" firstAttribute="top" secondItem="nHX-St-Osi" secondAttribute="bottom" constant="7.5" id="pMI-GA-jIb"/>
<constraint firstItem="vWx-wx-d32" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" id="qul-l9-Wcv"/>
<constraint firstItem="lnj-T4-sfz" firstAttribute="top" secondItem="fcn-wc-llO" secondAttribute="bottom" constant="8" id="rcX-0a-RzU"/>
<constraint firstAttribute="centerX" secondItem="Bza-7R-910" secondAttribute="centerX" id="wU3-cB-7dO"/>
<constraint firstItem="E8G-aN-rjr" firstAttribute="top" secondItem="DId-6z-9ak" secondAttribute="bottom" constant="8" id="xGQ-39-pOh"/>
<constraint firstAttribute="centerX" secondItem="vWx-wx-d32" secondAttribute="centerX" id="z6v-r5-zad"/>
</constraints>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "CWStatusBarNotification"
s.version = "2.1.3"
s.version = "2.2.6"
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 = "https://github.com/cezarywojcik/CWStatusBarNotification"
@@ -15,6 +15,14 @@ typedef void(^CWCompletionBlock)(void);
@end
@interface CWWindowContainer : UIWindow
@property (assign, nonatomic) CGFloat notificationHeight;
@end
@interface CWViewController : UIViewController
@property (nonatomic) UIStatusBarStyle preferredStatusBarStyle;
@property (nonatomic, setter=setSupportedInterfaceOrientations:) NSInteger supportedInterfaceOrientations;
@end
@interface CWStatusBarNotification : NSObject
@@ -39,14 +47,17 @@ typedef NS_ENUM(NSInteger, CWNotificationAnimationType) {
@property (strong, nonatomic) ScrollLabel *notificationLabel;
@property (strong, nonatomic) UIColor *notificationLabelBackgroundColor;
@property (strong, nonatomic) UIColor *notificationLabelTextColor;
@property (strong, nonatomic) UIFont *notificationLabelFont;
@property (assign, nonatomic) CGFloat notificationLabelHeight;
@property (strong, nonatomic) UIView *customView;
@property (assign, nonatomic) BOOL multiline;
@property (strong, nonatomic) UIView *statusBarView;
@property (copy, nonatomic) CWCompletionBlock notificationTappedBlock;
@property (nonatomic) CWNotificationAnimationStyle notificationStyle;
@property (nonatomic) CWNotificationStyle notificationStyle;
@property (nonatomic) NSInteger supportedInterfaceOrientations;
@property (nonatomic) CWNotificationAnimationStyle notificationAnimationInStyle;
@property (nonatomic) CWNotificationAnimationStyle notificationAnimationOutStyle;
@property (nonatomic) CWNotificationAnimationType notificationAnimationType;
@@ -54,9 +65,13 @@ typedef NS_ENUM(NSInteger, CWNotificationAnimationType) {
@property (nonatomic) BOOL notificationIsDismissing;
@property (strong, nonatomic) CWWindowContainer *notificationWindow;
@property (nonatomic) UIStatusBarStyle preferredStatusBarStyle;
- (void)displayNotificationWithMessage:(NSString *)message forDuration:(CGFloat)duration;
- (void)displayNotificationWithMessage:(NSString *)message completion:(void (^)(void))completion;
- (void)displayNotificationWithView:(UIView *)view forDuration:(CGFloat)duration;
- (void)displayNotificationWithView:(UIView *)view completion:(void (^)(void))completion;
- (void)dismissNotification;
- (void)dismissNotificationWithCompletion:(void(^)(void))completion;
@end
+164 -39
View File
@@ -22,22 +22,53 @@
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
CGFloat height;
if (SYSTEM_VERSION_LESS_THAN(@"8.0") && UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
if (SYSTEM_VERSION_LESS_THAN(@"8.0") && UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
height = [UIApplication sharedApplication].statusBarFrame.size.width;
}
else {
height = [UIApplication sharedApplication].statusBarFrame.size.height;
}
if (point.y > 0 && point.y < height) {
if (point.y > 0 && point.y < (self.notificationHeight != 0.0 ? self.notificationHeight : height)) {
return [super hitTest:point withEvent:event];
}
return nil;
}
@end
@interface CWViewController()
@property (nonatomic, assign) NSInteger _cwViewControllerSupportedInterfaceOrientation;
@end
@implementation CWViewController
- (UIStatusBarStyle)preferredStatusBarStyle
{
return _preferredStatusBarStyle;
}
- (void)setSupportedInterfaceOrientations:(NSInteger)supportedInterfaceOrientations
{
self._cwViewControllerSupportedInterfaceOrientation = supportedInterfaceOrientations;
}
- (NSInteger)supportedInterfaceOrientations
{
return self._cwViewControllerSupportedInterfaceOrientation;
}
- (BOOL)prefersStatusBarHidden
{
CGFloat statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
return !(statusBarHeight > 0);
}
@end
# pragma mark - dispatch after with cancellation
// adapted from: https://github.com/Spaceman-Labs/Dispatch-Cancel
@@ -56,7 +87,7 @@ static CWDelayedBlockHandle perform_block_after_delay(CGFloat seconds, dispatch_
if (NO == cancel && nil != blockToExecute) {
dispatch_async(dispatch_get_main_queue(), blockToExecute);
}
blockToExecute = nil;
delayHandleCopy = nil;
};
@@ -146,12 +177,13 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
@property (strong, nonatomic) UITapGestureRecognizer *tapGestureRecognizer;
@property (strong, nonatomic) CWDelayedBlockHandle dismissHandle;
@property (assign, nonatomic) BOOL isCustomView;
@end
@implementation CWStatusBarNotification
@synthesize notificationLabel, notificationLabelBackgroundColor, notificationLabelTextColor, notificationWindow;
@synthesize notificationLabel, notificationLabelBackgroundColor, notificationLabelTextColor, notificationLabelFont, notificationWindow, customView;
@synthesize statusBarView;
@@ -164,11 +196,15 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
// set defaults
self.notificationLabelBackgroundColor = [[UIApplication sharedApplication] delegate].window.tintColor;
self.notificationLabelTextColor = [UIColor whiteColor];
self.notificationLabelFont = [UIFont systemFontOfSize:FONT_SIZE];
self.notificationStyle = CWNotificationStyleStatusBarNotification;
self.notificationAnimationInStyle = CWNotificationAnimationStyleBottom;
self.notificationAnimationOutStyle = CWNotificationAnimationStyleBottom;
self.notificationAnimationType = CWNotificationAnimationTypeReplace;
self.notificationIsDismissing = NO;
self.isCustomView = NO;
self.preferredStatusBarStyle = UIStatusBarStyleDefault;
self.supportedInterfaceOrientations = UIInterfaceOrientationMaskAll;
// create tap recognizer
self.tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(notificationTapped:)];
@@ -193,7 +229,7 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
return self.notificationLabelHeight;
}
CGFloat statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
if (SYSTEM_VERSION_LESS_THAN(@"8.0") && UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
if (SYSTEM_VERSION_LESS_THAN(@"8.0") && UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.width;
}
return statusBarHeight > 0 ? statusBarHeight : 20;
@@ -201,7 +237,7 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
- (CGFloat)getStatusBarWidth
{
if (SYSTEM_VERSION_LESS_THAN(@"8.0") && UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
if (SYSTEM_VERSION_LESS_THAN(@"8.0") && UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
return [UIScreen mainScreen].bounds.size.height;
}
return [UIScreen mainScreen].bounds.size.width;
@@ -242,7 +278,7 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
- (CGFloat)getNavigationBarHeight
{
if (UIDeviceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation) ||
if (UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation) ||
UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return 44.0f;
}
@@ -265,7 +301,8 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
- (void)updateStatusBarFrame
{
self.notificationLabel.frame = [self getNotificationLabelFrame];
UIView *view = self.isCustomView ? self.customView : self.notificationLabel;
view.frame = [self getNotificationLabelFrame];
self.statusBarView.hidden = YES;
}
@@ -278,6 +315,27 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
# pragma mark - display helpers
- (void)setupNotificationView:(UIView *)view
{
view.clipsToBounds = YES;
view.userInteractionEnabled = YES;
[view addGestureRecognizer:self.tapGestureRecognizer];
switch (self.notificationAnimationInStyle) {
case CWNotificationAnimationStyleTop:
view.frame = [self getNotificationLabelTopFrame];
break;
case CWNotificationAnimationStyleBottom:
view.frame = [self getNotificationLabelBottomFrame];
break;
case CWNotificationAnimationStyleLeft:
view.frame = [self getNotificationLabelLeftFrame];
break;
case CWNotificationAnimationStyleRight:
view.frame = [self getNotificationLabelRightFrame];
break;
}
}
- (void)createNotificationLabelWithMessage:(NSString *)message
{
self.notificationLabel = [ScrollLabel new];
@@ -285,26 +343,27 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
self.notificationLabel.text = message;
self.notificationLabel.textAlignment = NSTextAlignmentCenter;
self.notificationLabel.adjustsFontSizeToFitWidth = NO;
self.notificationLabel.font = [UIFont systemFontOfSize:FONT_SIZE];
self.notificationLabel.font = self.notificationLabelFont;
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];
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;
}
[self setupNotificationView:self.notificationLabel];
}
- (void)createNotificationCustomView:(UIView *)view
{
self.customView = [[UIView alloc] init];
// Doesn't use autoresizing masks so that we can create constraints below manually
[view setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.customView addSubview:view];
// Setup Auto Layout constaints so that the custom view that is added is constained to be the same
// size as its superview, whose frame will be altered
[self.customView addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.customView attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:0.0]];
[self.customView addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.customView attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0.0]];
[self.customView addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.customView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0]];
[self.customView addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.customView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0]];
[self setupNotificationView:self.customView];
}
- (void)createNotificationWindow
@@ -314,7 +373,11 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
self.notificationWindow.userInteractionEnabled = YES;
self.notificationWindow.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.notificationWindow.windowLevel = UIWindowLevelStatusBar;
self.notificationWindow.rootViewController = [UIViewController new];
CWViewController *rootViewController = [[CWViewController alloc] init];
[rootViewController setSupportedInterfaceOrientations:self.supportedInterfaceOrientations];
rootViewController.preferredStatusBarStyle = self.preferredStatusBarStyle;
self.notificationWindow.rootViewController = rootViewController;
self.notificationWindow.notificationHeight = [self getNotificationLabelHeight];
}
- (void)createStatusBarView
@@ -333,7 +396,8 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
- (void)firstFrameChange
{
self.notificationLabel.frame = [self getNotificationLabelFrame];
UIView *view = self.isCustomView ? self.customView : self.notificationLabel;
view.frame = [self getNotificationLabelFrame];
switch (self.notificationAnimationInStyle) {
case CWNotificationAnimationStyleTop:
self.statusBarView.frame = [self getNotificationLabelBottomFrame];
@@ -352,14 +416,15 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
- (void)secondFrameChange
{
UIView *view = self.isCustomView ? self.customView : self.notificationLabel;
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 getStatusBarOffset] + [self getNotificationLabelHeight]);
view.layer.anchorPoint = CGPointMake(0.5f, 1.0f);
view.center = CGPointMake(view.center.x, [self getStatusBarOffset] + [self getNotificationLabelHeight]);
break;
case CWNotificationAnimationStyleLeft:
self.statusBarView.frame = [self getNotificationLabelRightFrame];
@@ -372,19 +437,20 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
- (void)thirdFrameChange
{
UIView *view = self.isCustomView ? self.customView : self.notificationLabel;
self.statusBarView.frame = [self getNotificationLabelFrame];
switch (self.notificationAnimationOutStyle) {
case CWNotificationAnimationStyleTop:
self.notificationLabel.frame = [self getNotificationLabelTopFrame];
view.frame = [self getNotificationLabelTopFrame];
break;
case CWNotificationAnimationStyleBottom:
self.notificationLabel.transform = CGAffineTransformMakeScale(1.0f, 0.01f);
view.transform = CGAffineTransformMakeScale(1.0f, 0.01f);
break;
case CWNotificationAnimationStyleLeft:
self.notificationLabel.frame = [self getNotificationLabelLeftFrame];
view.frame = [self getNotificationLabelLeftFrame];
break;
case CWNotificationAnimationStyleRight:
self.notificationLabel.frame = [self getNotificationLabelRightFrame];
view.frame = [self getNotificationLabelRightFrame];
break;
}
}
@@ -394,6 +460,7 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
- (void)displayNotificationWithMessage:(NSString *)message completion:(void (^)(void))completion
{
if (!self.notificationIsShowing) {
self.isCustomView = NO;
self.notificationIsShowing = YES;
// create UIWindow
@@ -412,7 +479,7 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
// checking for screen orientation change
[[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];
@@ -428,7 +495,48 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
}
}
- (void)displayNotificationWithView:(UIView *)view completion:(void (^)(void))completion
{
if (!self.notificationIsShowing) {
self.isCustomView = YES;
self.notificationIsShowing = YES;
// create UIWindow
[self createNotificationWindow];
// setup view
[self createNotificationCustomView:view];
// create status bar view
[self createStatusBarView];
// add view to window
UIView *rootView = self.notificationWindow.rootViewController.view;
[rootView addSubview:self.customView];
[rootView bringSubviewToFront:self.customView];
[self.notificationWindow setHidden:NO];
// checking for screen orientation change
[[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) {
[completion invoke];
}];
}
}
- (void)dismissNotification
{
[self dismissNotificationWithCompletion:nil];
}
- (void)dismissNotificationWithCompletion:(void (^)(void))completion
{
if (self.notificationIsShowing) {
cancel_delayed_block(self.dismissHandle);
@@ -437,16 +545,24 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
[UIView animateWithDuration:STATUS_BAR_ANIMATION_LENGTH animations:^{
[self thirdFrameChange];
} completion:^(BOOL finished) {
[self.notificationLabel removeFromSuperview];
UIView *view = self.isCustomView ? self.customView : self.notificationLabel;
[view removeFromSuperview];
[self.statusBarView removeFromSuperview];
[self.notificationWindow setHidden:YES];
self.notificationWindow = nil;
self.notificationLabel = nil;
view = nil;
self.notificationIsShowing = NO;
self.notificationIsDismissing = NO;
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
if (completion) {
completion();
}
}];
} else {
if (completion) {
completion();
}
}
}
@@ -459,4 +575,13 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
}];
}
- (void)displayNotificationWithView:(UIView *)view forDuration:(CGFloat)duration
{
[self displayNotificationWithView:view completion:^{
self.dismissHandle = perform_block_after_delay(duration, ^{
[self dismissNotification];
});
}];
}
@end
+35 -11
View File
@@ -18,7 +18,7 @@ Works for iPhone and iPad.
### CocoaPods
`pod 'CWStatusBarNotification', '~> 2.1.3'`
`pod 'CWStatusBarNotification', '~> 2.2.6'`
### Manual
@@ -26,29 +26,28 @@ Copy the folder `CWStatusBarNotification` to 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:
```
```objc
#import "CWStatusBarNotification.h"
```
Now, you need to create a `CWStatusBarNotification` object. It is recommended that you do so by attaching it as a property to a `UIViewController`.
```
```objc
CWStatusBarNotification *notification = [CWStatusBarNotification new];
```
After you have a `CWStatusBarNotification` object, you can simply call the `displayNotificationMessage:forDuration:` method:
```
```objc
[self.notification displayNotificationWithMessage:@"Hello, World!"
forDuration:1.0f];
```
If you prefer to manually choose when to display and dismiss the notification, you can do so as well:
```
```objc
[self.notification displayNotificationWithMessage:@"Hello" completion:nil];
// wait until you need to dismiss
[self.notification dismissNotification];
@@ -60,17 +59,16 @@ The default behavior when the notification is tapped is to dismiss it. However,
For example:
```
```objc
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:
```
```objc
__weak typeof(self) weakSelf = self;
self.notification.notificationTappedBlock = ^(void) {
if (!weakSelf.notificationIsDismissing) {
@@ -86,7 +84,7 @@ First of all, you can customize the background color and text color using the fo
Example:
```
```objc
notification.notificationLabelBackgroundColor = [UIColor blackColor];
notification.notificationLabelTextColor = [UIColor greenColor];
```
@@ -118,10 +116,36 @@ The default value for `notificationAnimationInStyle` is `CWNotificationAnimation
The default value for `notificationAnimationOutStyle` is `CWNotificationAnimationStyleTop`.
## Presenting a Custom View
As of version `2.2.0`, you can choose to present a custom view in lieu of presenting a simple message. The demo project shows a simple way in which you can make a custom NIB file and present it as the notification view using the `displayNotificationWithView:forDuration:` method:
```objc
UIView *view = [[NSBundle mainBundle] loadNibNamed:@"CustomView" owner:nil options:nil][0];
[self.notification displayNotificationWithView:view forDuration:self.sliderDuration.value];
```
You can also display the notification and choose when to dismiss it as usual:
```objc
[self.notification displayNotificationWithView:view completion:nil];
// wait until you need to dismiss
[self.notification dismissNotification];
```
### Additional Remarks
The notifications will work in both screen orientations, however, screen rotation while a notification is displayed is not yet fully supported.
## Apps Using This Library
If you would like for your app to be featured here, [contact me](cezarywojcik.com/contact) and I would love to hear about your app!
* [SlideShare Presentations](https://itunes.apple.com/app/id917418728)
* [Pong Ping](https://itunes.apple.com/us/app/pong-ping-social-addictive/id822887888)
* [NextMovies](https://itunes.apple.com/us/app/nextmovies-smart-movie-recommendation/id680850329)
## License
The MIT License (MIT)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1016 KiB

After

Width:  |  Height:  |  Size: 4.6 MiB