Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions Example/AFSwipeToHide.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; };
6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5B8195388D20070C39A /* InfoPlist.strings */; };
6003F5BC195388D20070C39A /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5BB195388D20070C39A /* Tests.m */; };
7DDF9C801A1B1B2E00FF236C /* AFRootTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DDF9C7F1A1B1B2E00FF236C /* AFRootTableViewController.m */; };
7DDF9C831A1B1DA600FF236C /* ControllerNameItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DDF9C821A1B1DA600FF236C /* ControllerNameItem.m */; };
A3793E1B418B251CF9E9D323 /* libPods-AFSwipeToHide.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2BC87DD27DA7BB70B8EEEF35 /* libPods-AFSwipeToHide.a */; };
DA8EB0F30EA401214E37EBE7 /* libPods-Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 330B05E7436C539DC56B70F8 /* libPods-Tests.a */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -62,6 +64,10 @@
6003F5B9195388D20070C39A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
6003F5BB195388D20070C39A /* Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = "<group>"; };
606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Tests-Prefix.pch"; sourceTree = "<group>"; };
7DDF9C7E1A1B1B2E00FF236C /* AFRootTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFRootTableViewController.h; sourceTree = "<group>"; };
7DDF9C7F1A1B1B2E00FF236C /* AFRootTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFRootTableViewController.m; sourceTree = "<group>"; };
7DDF9C811A1B1DA600FF236C /* ControllerNameItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ControllerNameItem.h; sourceTree = "<group>"; };
7DDF9C821A1B1DA600FF236C /* ControllerNameItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ControllerNameItem.m; sourceTree = "<group>"; };
8F62D1C4AC0681D0E23FE8A1 /* Pods-AFSwipeToHide.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AFSwipeToHide.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AFSwipeToHide/Pods-AFSwipeToHide.debug.xcconfig"; sourceTree = "<group>"; };
E42E6FCAC9046D95FBFC5D69 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
FB807404A9E3A47C20E6D937 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
Expand Down Expand Up @@ -132,8 +138,8 @@
children = (
2D15B2971A02CE6000DE511E /* AppDelegate.h */,
2D15B2981A02CE6000DE511E /* AppDelegate.m */,
2D15B2991A02CE6000DE511E /* ViewController.h */,
2D15B29A1A02CE6000DE511E /* ViewController.m */,
7DDF9C841A1B1E1800FF236C /* UIModel */,
7DDF9C851A1B1E2200FF236C /* Controllers */,
2D15B29D1A02CEA600DE511E /* Main.storyboard */,
6003F5A8195388D20070C39A /* Images.xcassets */,
6003F594195388D20070C39A /* Supporting Files */,
Expand Down Expand Up @@ -192,6 +198,26 @@
name = Pods;
sourceTree = "<group>";
};
7DDF9C841A1B1E1800FF236C /* UIModel */ = {
isa = PBXGroup;
children = (
7DDF9C811A1B1DA600FF236C /* ControllerNameItem.h */,
7DDF9C821A1B1DA600FF236C /* ControllerNameItem.m */,
);
name = UIModel;
sourceTree = "<group>";
};
7DDF9C851A1B1E2200FF236C /* Controllers */ = {
isa = PBXGroup;
children = (
7DDF9C7E1A1B1B2E00FF236C /* AFRootTableViewController.h */,
7DDF9C7F1A1B1B2E00FF236C /* AFRootTableViewController.m */,
2D15B2991A02CE6000DE511E /* ViewController.h */,
2D15B29A1A02CE6000DE511E /* ViewController.m */,
);
name = Controllers;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -357,9 +383,11 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7DDF9C801A1B1B2E00FF236C /* AFRootTableViewController.m in Sources */,
2D15B29B1A02CE6000DE511E /* AppDelegate.m in Sources */,
6003F59A195388D20070C39A /* main.m in Sources */,
2D15B29C1A02CE6000DE511E /* ViewController.m in Sources */,
7DDF9C831A1B1DA600FF236C /* ControllerNameItem.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -482,7 +510,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "AFSwipeToHide/AFSwipeToHide-Prefix.pch";
INFOPLIST_FILE = "AFSwipeToHide/AFSwipeToHide-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand All @@ -497,7 +525,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "AFSwipeToHide/AFSwipeToHide-Prefix.pch";
INFOPLIST_FILE = "AFSwipeToHide/AFSwipeToHide-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand Down
13 changes: 13 additions & 0 deletions Example/AFSwipeToHide/AFRootTableViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// AFRootTableViewController.h
// AFSwipeToHide
//
// Created by dw_iOS iOS软件工程师 曾宪华 QQ:543413507 on 14-11-18.
// Copyright (c) 2014年 Oz. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface AFRootTableViewController : UITableViewController

@end
64 changes: 64 additions & 0 deletions Example/AFSwipeToHide/AFRootTableViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// AFRootTableViewController.m
// AFSwipeToHide
//
// Created by dw_iOS iOS软件工程师 曾宪华 QQ:543413507 on 14-11-18.
// Copyright (c) 2014年 Oz. All rights reserved.
//

#import "AFRootTableViewController.h"
#import "ViewController.h"
#import "ControllerNameItem.h"

@interface AFRootTableViewController ()

@property (nonatomic, strong) NSMutableArray *dataSource;

@end

@implementation AFRootTableViewController

- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"AFSwipeToHide";

self.dataSource = [[ControllerNameItem newDataSource] mutableCopy];
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return self.dataSource.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CellIdentifier" forIndexPath:indexPath];

// Configure the cell...
ControllerNameItem *item = self.dataSource[indexPath.row];
cell.textLabel.text = item.title;

return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
ViewController *viewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"DetailViewController"];
if (viewController) {
viewController.item = self.dataSource[indexPath.row];
[self.navigationController pushViewController:viewController animated:YES];
}
}

@end
23 changes: 23 additions & 0 deletions Example/AFSwipeToHide/ControllerNameItem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// ControllerNameItem.h
// AFSwipeToHide
//
// Created by dw_iOS iOS软件工程师 曾宪华 QQ:543413507 on 14-11-18.
// Copyright (c) 2014年 Oz. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface ControllerNameItem : NSObject

@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *className;

// Default is no
@property (nonatomic, assign) BOOL hasNavigationBar;

- (instancetype)initWithTitle:(NSString *)title;

+ (NSArray *)newDataSource;

@end
34 changes: 34 additions & 0 deletions Example/AFSwipeToHide/ControllerNameItem.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// ControllerNameItem.m
// AFSwipeToHide
//
// Created by dw_iOS iOS软件工程师 曾宪华 QQ:543413507 on 14-11-18.
// Copyright (c) 2014年 Oz. All rights reserved.
//

#import "ControllerNameItem.h"

@implementation ControllerNameItem

- (instancetype)initWithTitle:(NSString *)title {
self = [super init];
if (self) {
self.title = title;
}
return self;
}

+ (NSArray *)newDataSource {
NSMutableArray *newDataSource = [[NSMutableArray alloc] init];

ControllerNameItem *item = [[ControllerNameItem alloc] initWithTitle:@"No Navigation Bar"];
[newDataSource addObject:item];

item = [[ControllerNameItem alloc] initWithTitle:@"Has Navigation Bar"];
item.hasNavigationBar = YES;
[newDataSource addObject:item];

return newDataSource;
}

@end
60 changes: 56 additions & 4 deletions Example/AFSwipeToHide/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6250" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6245" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="SV5-RQ-dLS">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
<deployment defaultVersion="1792" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6238"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController id="vXZ-lx-hvc" customClass="ViewController" sceneMemberID="viewController">
<viewController storyboardIdentifier="DetailViewController" id="vXZ-lx-hvc" customClass="ViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
Expand Down Expand Up @@ -45,6 +46,12 @@
<rect key="frame" x="0.0" y="524" width="320" height="44"/>
<items>
<barButtonItem style="plain" systemItem="add" id="Efl-C7-Q73"/>
<barButtonItem style="plain" systemItem="flexibleSpace" id="55D-ZT-arr"/>
<barButtonItem title="Back" style="plain" id="2jn-61-Huu">
<connections>
<action selector="af_popToViewController:" destination="vXZ-lx-hvc" id="fAs-MA-hf5"/>
</connections>
</barButtonItem>
</items>
</toolbar>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="List of items" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7BP-in-PZI">
Expand Down Expand Up @@ -83,7 +90,52 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="74.666666666666671" y="129.69333333333333"/>
<point key="canvasLocation" x="742" y="651"/>
</scene>
<!--Root Table View Controller-->
<scene sceneID="vFR-qg-Czi">
<objects>
<tableViewController id="vJb-gx-10o" customClass="AFRootTableViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="Rov-1G-58F">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="CellIdentifier" id="awi-v1-AAn">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="awi-v1-AAn" id="lqS-pt-9C9">
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="vJb-gx-10o" id="mU5-J5-H2j"/>
<outlet property="delegate" destination="vJb-gx-10o" id="VGJ-ZW-LPN"/>
</connections>
</tableView>
<navigationItem key="navigationItem" id="a2e-vK-Pir"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="R05-bh-Isf" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="172" y="214"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="dhK-A9-ahc">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="SV5-RQ-dLS" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="vs5-4V-ngX">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="vJb-gx-10o" kind="relationship" relationship="rootViewController" id="dNk-zM-ExT"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="0oE-vp-kD7" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-360" y="214"/>
</scene>
</scenes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
Expand Down
4 changes: 4 additions & 0 deletions Example/AFSwipeToHide/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@

#import <UIKit/UIKit.h>

@class ControllerNameItem;

@interface ViewController : UIViewController

@property (nonatomic, strong) ControllerNameItem *item;

@end

31 changes: 29 additions & 2 deletions Example/AFSwipeToHide/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#import "ViewController.h"
#import <AFSwipeToHide/AFSwipeToHide.h>
#import "ControllerNameItem.h"

@interface ViewController ()<UITableViewDataSource, AFSwipeToHideDelegate>
{
Expand All @@ -37,9 +38,33 @@ @interface ViewController ()<UITableViewDataSource, AFSwipeToHideDelegate>

@implementation ViewController

#pragma mark - Action

- (IBAction)af_popToViewController:(UIBarButtonItem *)sender {
[self.navigationController popViewControllerAnimated:YES];
}

#pragma nark - Life Cycle

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if (!self.item.hasNavigationBar) {
self.navigationController.navigationBarHidden = YES;
}
}

- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
if (self.item.hasNavigationBar) {
self.navigationController.navigationBarHidden = NO;
}
}

- (void)viewDidLoad {
[super viewDidLoad];

self.edgesForExtendedLayout = UIRectEdgeNone;

_headerHeight = self.titleHeight.constant;

_swipeToHide = [[AFSwipeToHide alloc] init];
Expand All @@ -56,6 +81,8 @@ - (void)viewDidLoad {
self.tableView.delegate = (id<UITableViewDelegate>)_swipeToHide;

[self updateElements];


}

- (void)updateElements {
Expand All @@ -70,7 +97,7 @@ - (void)updateElements {
#pragma mark - Sizing utils

- (CGFloat)statusBarHeight {
return [[UIApplication sharedApplication] statusBarFrame].size.height;
return (self.item.hasNavigationBar ? 0 : [[UIApplication sharedApplication] statusBarFrame].size.height);
}

#pragma mark - AFUSwipeToHide delegate
Expand All @@ -79,7 +106,7 @@ - (void)swipeToHide:(AFSwipeToHide *)swipeToHide didUpdatePercentHiddenInteracti
[self updateElements];

if (!interactive) {
[UIView animateWithDuration:0.5 delay:0.0 usingSpringWithDamping:0.45 initialSpringVelocity:0.0 options:0 animations:^{
[UIView animateWithDuration:0.5 delay:0.0 usingSpringWithDamping:0.65 initialSpringVelocity:0.0 options:0 animations:^{
[self.view setNeedsLayout];
[self.view layoutIfNeeded];
} completion:nil];
Expand Down