Skip to content

Commit

Permalink
Adds methods for setting fade amount and fade tint
Browse files Browse the repository at this point in the history
  • Loading branch information
zackslash committed Nov 22, 2014
1 parent 96c97b4 commit 57a0598
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
Binary file not shown.
18 changes: 3 additions & 15 deletions DropdownMenu-Example/DropdownMenuDemo/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5053" systemVersion="12F45" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="2">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6245" systemVersion="14A379a" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="2">
<dependencies>
<deployment version="1536" defaultVersion="1792" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
<deployment version="1536" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/>
</dependencies>
<scenes>
<!--My Dropdown Menu Controller-->
Expand All @@ -19,19 +19,16 @@
<subviews>
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ODu-xW-Dlh">
<rect key="frame" x="0.0" y="70" width="320" height="498"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<connections>
<segue destination="xXX-v0-qZJ" kind="embed" id="ghU-4k-QtD"/>
</connections>
</containerView>
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="JJ1-ok-V49" userLabel="Menu">
<rect key="frame" x="0.0" y="-80" width="320" height="150"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="eNL-qn-pBt" userLabel="Button - Home">
<rect key="frame" x="0.0" y="0.0" width="320" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<color key="backgroundColor" red="0.039215687659999998" green="0.2823529541" blue="0.41960787770000002" alpha="1" colorSpace="deviceRGB"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="qBx-82-gyh"/>
Expand All @@ -51,7 +48,6 @@
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="QmM-XD-9ls" userLabel="Button - Profile">
<rect key="frame" x="0.0" y="50" width="320" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.231372565" green="0.52549022440000004" blue="0.52549022440000004" alpha="1" colorSpace="deviceRGB"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="vMO-KG-BK4"/>
Expand All @@ -70,7 +66,6 @@
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="FSe-ud-eyb" userLabel="Button - Photos">
<rect key="frame" x="0.0" y="100" width="320" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<color key="backgroundColor" red="0.47450983520000001" green="0.74117648599999997" blue="0.60392159219999997" alpha="1" colorSpace="deviceRGB"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="QUe-XN-7ei"/>
Expand Down Expand Up @@ -104,11 +99,9 @@
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="x6w-yK-z8E" userLabel="Menu Bar">
<rect key="frame" x="0.0" y="0.0" width="320" height="70"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NvP-Dd-5Jb">
<rect key="frame" x="251" y="19" width="69" height="51"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<constraints>
<constraint firstAttribute="height" constant="51" id="XLI-Xu-8Gi"/>
<constraint firstAttribute="width" constant="69" id="aMX-8j-P3m"/>
Expand All @@ -124,7 +117,6 @@
</button>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QfA-pj-j3e">
<rect key="frame" x="111" y="34" width="98" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="3tG-sQ-MKw"/>
<constraint firstAttribute="width" constant="98" id="SMx-mx-Ckt"/>
Expand Down Expand Up @@ -162,7 +154,6 @@
<outletCollection property="gestureRecognizers" destination="3Pw-r5-tx8" appends="YES" id="mIg-hS-KSg"/>
</connections>
</view>
<size key="freeformSize" width="1024" height="768"/>
<connections>
<outlet property="container" destination="ODu-xW-Dlh" id="H3S-cg-gcf"/>
<outlet property="menu" destination="JJ1-ok-V49" id="Vvs-VC-jAy"/>
Expand Down Expand Up @@ -201,7 +192,6 @@
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Home" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zYT-wH-Lko">
<rect key="frame" x="138" y="237" width="46" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.90196079019999997" green="0.90196079019999997" blue="0.90196079019999997" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
Expand Down Expand Up @@ -235,7 +225,6 @@
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Profile" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZYz-7e-9dJ">
<rect key="frame" x="136" y="272" width="49" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.90196079019999997" green="0.90196079019999997" blue="0.90196079019999997" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
Expand Down Expand Up @@ -269,7 +258,6 @@
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Photos" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oYB-sK-LtD">
<rect key="frame" x="133" y="272" width="55" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.90196079015731812" green="0.90196079015731812" blue="0.90196079015731812" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ -(void) customizeMenu {
//Uncomment to stop drop 'Triangle' from appearing
//[self dropShapeShouldShowWhenOpen:NO];

//Uncomment to fade to white instead of default (black)
//[self setFadeTintWithColor:[UIColor whiteColor]];

//Uncomment for increased fade effect (default is 0.5f)
//[self setFadeAmountWithAlpha:0.2f];

// Style menu buttons with IonIcons.
for (UIButton *button in self.buttons) {
if ([button.titleLabel.text isEqual: @"Profile"]) {
Expand Down
2 changes: 2 additions & 0 deletions DropdownMenu/DropdownMenuController.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
- (IBAction) menuButtonAction: (UIButton *) sender;
- (IBAction) listButtonAction: (UIButton *) sender;

- (void) setFadeAmountWithAlpha:(float) alphaVal;
- (void) setFadeTintWithColor:(UIColor *) color;
- (void) dropShapeShouldShowWhenOpen:(BOOL)shouldShow;
- (void) setMenubarTitle:(NSString *) menubarTitle;
- (void) setMenubarBackground:(UIColor *) color;
Expand Down
14 changes: 13 additions & 1 deletion DropdownMenu/DropdownMenuController.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ - (void)iOS6_hideMenuCompleted;

@implementation DropdownMenuController {
bool shouldDisplayDropShape;
float fadeAlpha;
}

CAShapeLayer *openMenuShape;
Expand All @@ -41,6 +42,7 @@ @implementation DropdownMenuController {
- (void)viewDidLoad {
[super viewDidLoad];
shouldDisplayDropShape = YES;
fadeAlpha = 0.5f;
}

- (void) viewDidAppear:(BOOL)animated {
Expand All @@ -59,6 +61,16 @@ - (void) dropShapeShouldShowWhenOpen:(BOOL)shouldShow {
shouldDisplayDropShape = shouldShow;
}

//Sets the color that background content will fade to when the menu is open
- (void) setFadeTintWithColor:(UIColor *) color {
self.view.backgroundColor = color;
}

//Sets the amount of fade that should be applied to background content when menu is open
- (void) setFadeAmountWithAlpha:(float) alphaVal {
fadeAlpha = alphaVal;
}

- (void) setMenubarTitle:(NSString *) menubarTitle {
self.titleLabel.text = menubarTitle;
}
Expand Down Expand Up @@ -98,7 +110,7 @@ - (void) showMenu {
menuFrame.origin.y = self.menubar.frame.size.height;

// Set new alpha of Container View (to get fade effect)
float containerAlpha = 0.5f;
float containerAlpha = fadeAlpha;

if (SYSTEM_VERSION_LESS_THAN(@"7.0")) {
[UIView beginAnimations:nil context:nil];
Expand Down

0 comments on commit 57a0598

Please sign in to comment.