Compare commits

...

33 Commits

Author SHA1 Message Date
Cezary Wojcik 7eb79da4f0 2.3.3 2015-08-27 09:54:57 -07:00
Cezary Wojcik 0c103128dd actually fixed conflict 2015-08-25 12:36:24 -07:00
Cezary Wojcik fac5c91daa fixed conflict 2015-08-25 12:34:49 -07:00
Cezary Wojcik 5c949092f5 2.3.2 2015-08-25 12:32:49 -07:00
Cezary Wojcik cdc51f3243 Update README.md 2015-08-08 18:45:36 -07:00
Cezary Wojcik 7d1890f7c5 fixed typo in README 2015-07-12 19:15:12 -07:00
Cezary Wojcik 26d6eda4f5 updated README 2015-07-12 19:14:42 -07:00
Cezary Wojcik 9dfcc29703 2015 2015-07-11 23:13:16 -07:00
Cezary Wojcik 6d00f770ef supported interface orientations 2015-07-11 14:53:09 -07:00
Cezary Wojcik 23a64f768d 2.3.1
custom notification animation duration
2015-07-11 14:49:01 -07:00
Cezary Wojcik e3fd1677b1 CGFloat -> NSTimeInterval 2015-07-11 14:44:27 -07:00
Cezary Wojcik dfbb1ed5f6 no need for this because of PCH 2015-07-11 14:42:07 -07:00
Cezary Wojcik 71aec53e1d updated read 2015-07-11 14:38:22 -07:00
Cezary Wojcik a24706854d added one more doc comment 2015-07-11 14:35:51 -07:00
Cezary Wojcik 9dd9bcecb2 2.3.0 2015-07-11 14:27:26 -07:00
Cezary Wojcik c5875f1311 Merge pull request #56 from benguild/master
Quick fix for lack of NSAttributedString support. Could be improved.
2015-07-11 02:04:52 -07:00
Ben Guild 6d2a139fa0 Changing function and variable names to match UILabel's. 2015-06-14 15:41:36 +09:00
Ben Guild 1a1d1c5d38 Quick fix for lack of NSAttributedString support. Could be improved. 2015-06-14 15:33:04 +09:00
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
11 changed files with 476 additions and 239 deletions
@@ -311,6 +311,7 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
@@ -350,6 +351,7 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
+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"/>
+1 -2
View File
@@ -16,12 +16,11 @@
@property (weak, nonatomic) IBOutlet UITextField *txtNotificationMessage;
@property (weak, nonatomic) IBOutlet UISegmentedControl *segFromStyle;
@property (weak, nonatomic) IBOutlet UISegmentedControl *segToStyle;
@property (weak, nonatomic) IBOutlet UILabel *notificationStyleLabel;
@property (weak, nonatomic) IBOutlet UISegmentedControl *notificationStyle;
@property (strong, nonatomic) CWStatusBarNotification *notification;
- (IBAction)sliderDurationChanged:(UISlider *)sender;
- (IBAction)notificationStyleChanged:(UISwitch *)sender;
- (IBAction)btnShowNotificationPressed:(UIButton *)sender;
- (IBAction)btnShowCustomNotificationPressed:(UIButton *)sender;
+9 -9
View File
@@ -60,24 +60,24 @@
[self updateDurationLabel];
}
- (IBAction)notificationStyleChanged:(UISwitch *)sender
{
self.notificationStyleLabel.text = sender.on ? @"Status Bar" : @"Navigation Bar";
self.notification.notificationStyle = sender.on ? CWNotificationStyleStatusBarNotification : CWNotificationStyleNavigationBarNotification;
}
# 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.notification.notificationAnimationInStyle = self.segFromStyle.selectedSegmentIndex;
self.notification.notificationAnimationOutStyle = self.segToStyle.selectedSegmentIndex;
[self setupNotification];
UIView *view = [[NSBundle mainBundle] loadNibNamed:@"CustomView" owner:nil options:nil][0];
[self.notification displayNotificationWithView:view forDuration:self.sliderDuration.value];
}
+42 -65
View File
@@ -1,14 +1,13 @@
<?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">
<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="notificationStyleLabel" destination="vCP-z3-d8I" id="w8D-aD-anT"/>
<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"/>
@@ -22,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>
@@ -31,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>
@@ -73,9 +68,16 @@
<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="117" y="297" width="180" height="30"/>
<state key="normal" title="Show Custom Notification">
<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>
@@ -83,59 +85,34 @@
<action selector="btnShowNotificationPressed:" destination="-1" eventType="touchUpInside" id="jNW-Ie-NPn"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jdx-ge-BUc">
<rect key="frame" x="110" y="332" width="195" height="45"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Status Bar" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vCP-z3-d8I">
<rect key="frame" x="2" y="12" width="81" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="kMg-IK-wId">
<rect key="frame" x="129" y="7" width="51" height="31"/>
<connections>
<action selector="notificationStyleChanged:" destination="-1" eventType="valueChanged" id="l5q-T2-kkR"/>
</connections>
</switch>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="vCP-z3-d8I" firstAttribute="centerY" secondItem="kMg-IK-wId" secondAttribute="centerY" id="3SI-Am-gjr"/>
<constraint firstItem="vCP-z3-d8I" firstAttribute="leading" secondItem="jdx-ge-BUc" secondAttribute="leading" constant="2" id="JX1-pS-6MA"/>
<constraint firstAttribute="width" constant="195" id="ULf-xN-mdP"/>
<constraint firstAttribute="trailing" secondItem="kMg-IK-wId" secondAttribute="trailing" constant="17" id="UMt-vg-87u"/>
<constraint firstAttribute="centerY" secondItem="vCP-z3-d8I" secondAttribute="centerY" id="VC6-YO-6GP"/>
<constraint firstAttribute="height" constant="45" id="x6g-OL-a8r"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="E8G-aN-rjr" firstAttribute="top" secondItem="DId-6z-9ak" secondAttribute="bottom" constant="10" id="65O-jS-huU"/>
<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="jdx-ge-BUc" firstAttribute="centerX" secondItem="E8G-aN-rjr" secondAttribute="centerX" id="CSN-1b-hyf"/>
<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="jdx-ge-BUc" firstAttribute="top" secondItem="E8G-aN-rjr" secondAttribute="bottom" constant="5" id="PQJ-pr-K5R"/>
<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="E8G-aN-rjr" firstAttribute="centerX" secondItem="DId-6z-9ak" secondAttribute="centerX" id="qrX-mR-Hox"/>
<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.2.2"
s.version = "2.3.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 = "https://github.com/cezarywojcik/CWStatusBarNotification"
+226 -23
View File
@@ -3,67 +3,270 @@
// CWNotificationDemo
//
// Created by Cezary Wojcik on 11/15/13.
// Copyright (c) 2013 Cezary Wojcik. All rights reserved.
// Copyright (c) 2015 Cezary Wojcik. All rights reserved.
//
#import <Foundation/Foundation.h>
/**
* @brief A simple completion used for handling tapping the notification.
*/
typedef void(^CWCompletionBlock)(void);
# pragma mark - ScrollLabel
/**
* A subclass of @c UILabel that scrolls the text if it is too long for the
* label.
*/
@interface ScrollLabel : UILabel
/**
* Used to find the amount of time that the label will spend scrolling.
* @return The amount of time that will be spent scrolling.
*/
- (CGFloat)scrollTime;
@end
# pragma mark - CWWindowContainer
/**
* A subclass of @c UIWindow that overrides the @c hitTest method in order to
* allow tap events to pass through the window.
*/
@interface CWWindowContainer : UIWindow
/// The height of the notification that is being displayed in the window.
@property (assign, nonatomic) CGFloat notificationHeight;
@end
# pragma mark - CWViewController
/**
* A subclass of @c UIViewController that allows handing over
* @c supportedInterfaceOrientations if needed.
*/
@interface CWViewController : UIViewController
/// Indicates the preferred status bar style.
@property (nonatomic) UIStatusBarStyle preferredStatusBarStyle;
/// Indicats the supported interface orientations.
@property (nonatomic, setter=setSupportedInterfaceOrientations:)
UIInterfaceOrientationMask supportedInterfaceOrientations;
@end
# pragma mark - CWStatusBarNotification
/**
* A subclass of @c NSObject that is responsible for managing status bar
* notifications.
*/
@interface CWStatusBarNotification : NSObject
# pragma mark - enums
/**
* @typedef CWNotificationStyle
* @brief Determines the notification style.
*/
typedef NS_ENUM(NSInteger, CWNotificationStyle) {
/// Covers the status bar portion of the screen.
CWNotificationStyleStatusBarNotification,
/// Covers the status bar and navigation bar portions of the screen.
CWNotificationStyleNavigationBarNotification
};
/**
* @typedef CWNotificationAnimationStyle
* @brief Determines the direction of animation for the notification.
*/
typedef NS_ENUM(NSInteger, CWNotificationAnimationStyle) {
/// Animate in from the top or animate out to the top.
CWNotificationAnimationStyleTop,
/// Animate in from the bottom or animate out to the bottom.
CWNotificationAnimationStyleBottom,
/// Animate in from the left or animate out to the left.
CWNotificationAnimationStyleLeft,
/// Animate in from the right or animate out to the right.
CWNotificationAnimationStyleRight
};
/**
* @typedef CWNotificationAnimationType
* @brief Determines whether the notification moves the existing content out of
* the way or simply overlays it.
*/
typedef NS_ENUM(NSInteger, CWNotificationAnimationType) {
/// Moves existing content out of the way.
CWNotificationAnimationTypeReplace,
/// Overlays existing content.
CWNotificationAnimationTypeOverlay
};
# pragma mark - properties
/// The label that holds the notification text.
@property (strong, nonatomic) ScrollLabel *notificationLabel;
@property (strong, nonatomic) UIColor *notificationLabelBackgroundColor;
@property (strong, nonatomic) UIColor *notificationLabelTextColor;
@property (assign, nonatomic) CGFloat notificationLabelHeight;
@property (strong, nonatomic) UIView *customView;
@property (assign, nonatomic) BOOL multiline;
/// The @c UIView that holds a screenshot of the status bar view.
@property (strong, nonatomic) UIView *statusBarView;
/// The block that gets triggered when the notification is tapped.
@property (copy, nonatomic) CWCompletionBlock notificationTappedBlock;
@property (nonatomic) CWNotificationStyle notificationStyle;
@property (nonatomic) CWNotificationAnimationStyle notificationAnimationInStyle;
@property (nonatomic) CWNotificationAnimationStyle notificationAnimationOutStyle;
@property (nonatomic) CWNotificationAnimationType notificationAnimationType;
/// Indicates whether the notification is currently being shown.
@property (nonatomic) BOOL notificationIsShowing;
/// Indicates whether the notification is currently dismissing.
@property (nonatomic) BOOL notificationIsDismissing;
/// The window that holds the notification.
@property (strong, nonatomic) CWWindowContainer *notificationWindow;
- (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;
/**
* The background color of the notification label. Default value is the tint
* color of the application's main window.
*/
@property (strong, nonatomic) UIColor *notificationLabelBackgroundColor;
/**
* The text color of the notification label. Default value is white.
*/
@property (strong, nonatomic) UIColor *notificationLabelTextColor;
/**
* The font of the notification label. Default value is system font.
*/
@property (strong, nonatomic) UIFont *notificationLabelFont;
/**
* Allows setting a custom height for the notification label. If this value is
* 0, the height will be determined by the @c notificationStyle. Default value
* is 0.
*/
@property (assign, nonatomic) CGFloat notificationLabelHeight;
/**
* The custom view to present if using @c displayNotificationWithView. Default
* value is @c nil.
*/
@property (strong, nonatomic) UIView *customView;
/**
* Determines whether the notification text has multiple lines. Default value is
* @c NO.
*/
@property (assign, nonatomic) BOOL multiline;
/**
* The supported interface orientations. Default value is the
* @c supportedInterfaceOrientations value of the root view controller of the
* application.
*/
@property (nonatomic) UIInterfaceOrientationMask supportedInterfaceOrientations;
/**
* The amount of time that it takes to animate the notification in or out.
* Default value is 0.25.
*/
@property (nonatomic) NSTimeInterval notificationAnimationDuration;
/**
* Determines whether the notification covers the status bar or both the status
* bar and the navigation bar. Default value is
* @c CWNotificationStyleStatusBarNotification.
*/
@property (nonatomic) CWNotificationStyle notificationStyle;
/**
* Determines the direction from which the notification animates in. Default
* value is @c CWNotificationAnimationStyleBottom.
*/
@property (nonatomic) CWNotificationAnimationStyle notificationAnimationInStyle;
/**
* Determines the direction from which the notification animates out. Default
* value is @c CWNotificationAnimationStyleBottom.
*/
@property (nonatomic) CWNotificationAnimationStyle
notificationAnimationOutStyle;
/**
* Determines whether the the notification's animation replaces the existing
* content or overlays it. Default value is
* @c CWNotificationAnimationTypeReplace.
*/
@property (nonatomic) CWNotificationAnimationType notificationAnimationType;
/**
* The preferred status bar style. Default value is @c UIStatusBarStyleDefault.
*/
@property (nonatomic) UIStatusBarStyle preferredStatusBarStyle;
#pragma mark - methods
/**
* Displays a notification with the indicated message and then performs the
* completion block once the notification animates in.
* @param message
* The content of the message to be displayed.
* @param completion
* The block to be invoked once the notification is displayed.
*/
- (void)displayNotificationWithMessage:(NSString *)message
completion:(void (^)(void))completion;
/**
* Displays a notification with the indicated message for the indicated
* duration.
* @param message
* The content of the message to be displayed.
* @param duration
* The amount of seconds for which the notification should be displayed,
* not including the animate in and out times.
*/
- (void)displayNotificationWithMessage:(NSString *)message
forDuration:(NSTimeInterval)duration;
/**
* Displays a notification with the indicated attributed string and then
* performs the completion block once the notification animates in.
* @param attributedString
* The content of the message to be displayed.
* @param completion
* The block to be invoked once the notification is displayed.
*/
- (void)displayNotificationWithAttributedString:(NSAttributedString *)
attributedString
completion:(void (^)(void))completion;
/**
* Displays a notification with the indicated message for the indicated
* duration.
* @param attributedString
* The content of the message to be displayed.
* @param duration
* The amount of seconds for which the notification should be displayed,
* not including the animate in and out times.
*/
- (void)displayNotificationWithAttributedString:(NSAttributedString *)
attributedString
forDuration:(NSTimeInterval)duration;
/**
* Displays a notification with the indicated custom view and then performs the
* completion block once the notification animates in.
* @param view
* The custom @c UIView that you wish to present.
* @param completion
* The block to be invoked once the notification is displayed.
*/
- (void)displayNotificationWithView:(UIView *)view
completion:(void (^)(void))completion;
/**
* Displays a notification with the indicated custom view for the indicated
* duration.
* @param view
* The custom @c UIView that you wish to present.
* @param duration
* The amount of seconds for which the notification should be displayed,
* not including the animate in and out times.
*/
- (void)displayNotificationWithView:(UIView *)view
forDuration:(NSTimeInterval)duration;
/**
* Dismisses the currently presented notification and then performs the
* completion block.
* @param completion
* The block to be invoked after the notification is dismissed.
*/
- (void)dismissNotificationWithCompletion:(void(^)(void))completion;
/**
* Dismisses the currently presented notification.
*/
- (void)dismissNotification;
@end
+183 -127
View File
@@ -3,7 +3,7 @@
// CWNotificationDemo
//
// Created by Cezary Wojcik on 11/15/13.
// Copyright (c) 2013 Cezary Wojcik. All rights reserved.
// Copyright (c) 2015 Cezary Wojcik. All rights reserved.
//
#import <QuartzCore/QuartzCore.h>
@@ -11,76 +11,11 @@
#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 < (self.notificationHeight != 0.0 ? self.notificationHeight : 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
@@ -106,7 +41,7 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
- (CGFloat)scrollOffset
{
if (self.numberOfLines != 1) return 0;
CGRect insetRect = CGRectInset(self.bounds, PADDING, 0);
return MAX(0, [self fullWidth] - insetRect.size.width);
}
@@ -140,6 +75,102 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
@end
# pragma mark - CWWindowContainer
@implementation CWWindowContainer
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
CGFloat height;
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 < (self.notificationHeight != 0.0 ? self.notificationHeight : height)) {
return [super hitTest:point withEvent:event];
}
return nil;
}
@end
# pragma mark - CWViewController
@interface CWViewController()
@property (nonatomic, assign) NSInteger _cwViewControllerSupportedInterfaceOrientation;
@end
@implementation CWViewController
- (UIStatusBarStyle)preferredStatusBarStyle
{
return _preferredStatusBarStyle;
}
- (void)setSupportedInterfaceOrientations:(UIInterfaceOrientationMask)supportedInterfaceOrientations
{
self._cwViewControllerSupportedInterfaceOrientation = supportedInterfaceOrientations;
}
- (UIInterfaceOrientationMask)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
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 - CWStatusBarNotification
@interface CWStatusBarNotification()
@@ -152,7 +183,7 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
@implementation CWStatusBarNotification
@synthesize notificationLabel, notificationLabelBackgroundColor, notificationLabelTextColor, notificationWindow, customView;
@synthesize notificationLabel, notificationLabelBackgroundColor, notificationLabelTextColor, notificationLabelFont, notificationWindow, customView;
@synthesize statusBarView;
@@ -162,15 +193,26 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
{
self = [super init];
if (self) {
// set defaults
self.notificationLabelBackgroundColor = [[UIApplication sharedApplication] delegate].window.tintColor;
// set default
if ([[[UIApplication sharedApplication] delegate] respondsToSelector:@selector(window)]) {
self.notificationLabelBackgroundColor = [[UIApplication sharedApplication] delegate].window.tintColor;
} else {
self.notificationLabelBackgroundColor = [UIColor blackColor];
}
self.notificationLabelTextColor = [UIColor whiteColor];
self.notificationLabelFont = [UIFont systemFontOfSize:FONT_SIZE];
self.notificationLabelHeight = 0.0;
self.customView = nil;
self.multiline = NO;
self.supportedInterfaceOrientations = [UIApplication sharedApplication].keyWindow.rootViewController.supportedInterfaceOrientations;
self.notificationAnimationDuration = 0.25;
self.notificationStyle = CWNotificationStyleStatusBarNotification;
self.notificationAnimationInStyle = CWNotificationAnimationStyleBottom;
self.notificationAnimationOutStyle = CWNotificationAnimationStyleBottom;
self.notificationAnimationType = CWNotificationAnimationTypeReplace;
self.notificationIsDismissing = NO;
self.isCustomView = NO;
self.preferredStatusBarStyle = UIStatusBarStyleDefault;
// create tap recognizer
self.tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(notificationTapped:)];
@@ -195,7 +237,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;
@@ -203,7 +245,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;
@@ -217,6 +259,27 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
return 0.0f;
}
- (CGFloat)getNavigationBarHeight
{
if (UIInterfaceOrientationIsPortrait([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];
}
}
- (CGRect)getNotificationLabelTopFrame
{
return CGRectMake(0, [self getStatusBarOffset] + -1*[self getNotificationLabelHeight], [self getStatusBarWidth], [self getNotificationLabelHeight]);
@@ -242,27 +305,6 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
return CGRectMake(0, [self getStatusBarOffset], [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)updateStatusBarFrame
@@ -309,7 +351,7 @@ 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 setupNotificationView:self.notificationLabel];
@@ -321,14 +363,14 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
// 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
// Setup Auto Layout constaints so that the custom view that is added is consrtained 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];
}
@@ -339,7 +381,10 @@ 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];
}
@@ -442,12 +487,12 @@ 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];
// animate
[UIView animateWithDuration:STATUS_BAR_ANIMATION_LENGTH animations:^{
[UIView animateWithDuration:self.notificationAnimationDuration animations:^{
[self firstFrameChange];
} completion:^(BOOL finished) {
double delayInSeconds = [self.notificationLabel scrollTime];
@@ -458,18 +503,39 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
}
}
- (void)displayNotificationWithMessage:(NSString *)message forDuration:(NSTimeInterval)duration
{
[self displayNotificationWithMessage:message completion:^{
self.dismissHandle = perform_block_after_delay(duration, ^{
[self dismissNotification];
});
}];
}
- (void)displayNotificationWithAttributedString:(NSAttributedString *)attributedString completion:(void (^)(void))completion
{
[self displayNotificationWithMessage:[attributedString string] completion:completion];
[[self notificationLabel] setAttributedText:attributedString];
}
- (void)displayNotificationWithAttributedString:(NSAttributedString *)attributedString forDuration:(NSTimeInterval)duration
{
[self displayNotificationWithMessage:[attributedString string] forDuration:duration];
[[self notificationLabel] setAttributedText:attributedString];
}
- (void)displayNotificationWithView:(UIView *)view completion:(void (^)(void))completion
{
if (!self.notificationIsShowing) {
self.isCustomView = YES;
self.notificationIsShowing = YES;
// create UIWindow
// create window
[self createNotificationWindow];
// setup view
[self createNotificationCustomView:view];
// create status bar view
[self createStatusBarView];
@@ -478,15 +544,15 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
[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:^{
[UIView animateWithDuration:self.notificationAnimationDuration animations:^{
[self firstFrameChange];
} completion:^(BOOL finished) {
[completion invoke];
@@ -494,9 +560,13 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
}
}
- (void)dismissNotification
- (void)displayNotificationWithView:(UIView *)view forDuration:(NSTimeInterval)duration
{
[self dismissNotificationWithCompletion:nil];
[self displayNotificationWithView:view completion:^{
self.dismissHandle = perform_block_after_delay(duration, ^{
[self dismissNotification];
});
}];
}
- (void)dismissNotificationWithCompletion:(void (^)(void))completion
@@ -505,7 +575,7 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
cancel_delayed_block(self.dismissHandle);
self.notificationIsDismissing = YES;
[self secondFrameChange];
[UIView animateWithDuration:STATUS_BAR_ANIMATION_LENGTH animations:^{
[UIView animateWithDuration:self.notificationAnimationDuration animations:^{
[self thirdFrameChange];
} completion:^(BOOL finished) {
UIView *view = self.isCustomView ? self.customView : self.notificationLabel;
@@ -529,22 +599,8 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
}
}
- (void)displayNotificationWithMessage:(NSString *)message forDuration:(CGFloat)duration
- (void)dismissNotification
{
[self displayNotificationWithMessage:message completion:^{
self.dismissHandle = perform_block_after_delay(duration, ^{
[self dismissNotification];
});
}];
[self dismissNotificationWithCompletion:nil];
}
- (void)displayNotificationWithView:(UIView *)view forDuration:(CGFloat)duration
{
[self displayNotificationWithView:view 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) 2014 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
+9 -8
View File
@@ -2,10 +2,12 @@
[![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).
**NOTE:** You can find a **Swift 2.0** 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.
You can find the documentation [here](http://cocoadocs.org/docsets/CWStatusBarNotification/).
![demo](screenshots/demo.gif)
## Requirements
@@ -18,7 +20,7 @@ Works for iPhone and iPad.
### CocoaPods
`pod 'CWStatusBarNotification', '~> 2.2.2'`
`pod 'CWStatusBarNotification', '~> 2.3.3'`
### Manual
@@ -26,8 +28,6 @@ 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
@@ -142,17 +142,18 @@ The notifications will work in both screen orientations, however, screen rotatio
## 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!
If you would like for your app to be featured here, [contact me](http://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)
* [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)
* [Social Dummy](https://itunes.apple.com/gb/app/social-dummy-create-fake-social/id610088272)
## License
The MIT License (MIT)
Copyright (c) 2014 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