Compare commits

...

10 Commits

Author SHA1 Message Date
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
9 changed files with 110 additions and 98 deletions
+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.2.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"
@@ -20,6 +20,11 @@ typedef void(^CWCompletionBlock)(void);
@end
@interface CWViewController : UIViewController
@property (nonatomic) UIStatusBarStyle preferredStatusBarStyle;
@property (nonatomic, setter=setSupportedInterfaceOrientations:) NSInteger supportedInterfaceOrientations;
@end
@interface CWStatusBarNotification : NSObject
typedef NS_ENUM(NSInteger, CWNotificationStyle) {
@@ -42,6 +47,7 @@ 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;
@@ -51,6 +57,7 @@ typedef NS_ENUM(NSInteger, CWNotificationAnimationType) {
@property (copy, nonatomic) CWCompletionBlock notificationTappedBlock;
@property (nonatomic) CWNotificationStyle notificationStyle;
@property (nonatomic) NSInteger supportedInterfaceOrientations;
@property (nonatomic) CWNotificationAnimationStyle notificationAnimationInStyle;
@property (nonatomic) CWNotificationAnimationStyle notificationAnimationOutStyle;
@property (nonatomic) CWNotificationAnimationType notificationAnimationType;
@@ -58,6 +65,7 @@ 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;
@@ -28,16 +28,41 @@
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
@interface CWViewController()
@property (nonatomic, assign) NSInteger _cwViewControllerSupportedInterfaceOrientation;
@end
@implementation CWViewController
- (UIStatusBarStyle)preferredStatusBarStyle
{
return _preferredStatusBarStyle;
}
- (void)setSupportedInterfaceOrientations:(NSInteger)supportedInterfaceOrientations
{
self._cwViewControllerSupportedInterfaceOrientation = supportedInterfaceOrientations;
}
- (NSUInteger)supportedInterfaceOrientations
{
return self._cwViewControllerSupportedInterfaceOrientation;
}
@end
# pragma mark - dispatch after with cancellation
// adapted from: https://github.com/Spaceman-Labs/Dispatch-Cancel
@@ -56,7 +81,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;
};
@@ -152,7 +177,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;
@@ -165,12 +190,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:)];
@@ -309,7 +337,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 +349,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
// 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 +367,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,7 +473,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];
@@ -463,13 +494,13 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
if (!self.notificationIsShowing) {
self.isCustomView = YES;
self.notificationIsShowing = YES;
// create UIWindow
[self createNotificationWindow];
// setup view
[self createNotificationCustomView:view];
// create status bar view
[self createStatusBarView];
@@ -478,13 +509,13 @@ 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:^{
[self firstFrameChange];
+1 -3
View File
@@ -18,7 +18,7 @@ Works for iPhone and iPad.
### CocoaPods
`pod 'CWStatusBarNotification', '~> 2.2.2'`
`pod 'CWStatusBarNotification', '~> 2.2.3'`
### Manual
@@ -26,8 +26,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
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1016 KiB

After

Width:  |  Height:  |  Size: 4.6 MiB