Coder Social home page Coder Social logo

yippeeapp / wzdraggableswitchheaderview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wongzigii/wzdraggableswitchheaderview

0.0 2.0 0.0 2.07 MB

A header view shows status for switching between viewControllers

License: MIT License

Ruby 2.11% Objective-C 97.89%

wzdraggableswitchheaderview's Introduction

WZDraggableSwitchHeaderView

Build Status Version

How far your thumb can reach on the iPhone 6 Plus ?

Or, being bored with tapping the button or navigation Item to switch between viewControllers ?

Quick Look

About

This project is inspired by Nike's awesome official App Making of Making Powered by NIKE MSI.

Installation

# For latest release in CocoaPods
pod 'WZDraggableSwitchHeaderView'

Or

# Feeling adventurous? Get the latest on develop
pod 'WZDraggableSwitchHeaderView', :git => 'https://github.com/wongzigii/WZDraggableSwitchHeaderView.git', :branch => 'master'

Getting Start

#import "WZDraggableSwitchHeaderView.h"

Create an instance of WZDraggableSwitchHeaderView:

self.headerView = [[WZDraggableSwitchHeaderView alloc] initWithDelegate:self
                                                                  frame:CGRectMake(0,0,self.view.bounds.size.width,50)
                                                      normalStateHeight:20.0f
                                                 heightCanTriggerSwitch:70.0f];
[self.view addSubView:self.headerView];           

Implement the delegate method that will be invoked:

#pragma mark - WZDraggableSwitchHeaderViewDelegate

- (void)WZDraggableSwitchHeaderViewDidTriggerDeepDragging;
{
    [self.navigationController.view.layer addAnimation:[WZAnimatingTransition backwardTransition] forKey:@"transition"];
    [self.navigationController popToRootViewControllerAnimated:NO];
}

Hook on the UIScrollViewDelegate:

#pragma mark - UIScrollViewDelegate

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    [self.headerView WZDraggableSwitchHeaderViewDidScroll:scrollView];
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    [self.headerView WZDraggableSwitchHeaderViewDidEndDragging:scrollView];
}

Done!

Customization

/// The y contentOffset range between normal state and shallow dragging state. If end dragging on this range, `- WZDraggableSwitchHeaderViewDidTriggerShallowDragging` will be invoked.
/// Default is 20.0f.
@property (nonatomic, assign) CGFloat normalStateHeight;

/// The total height of this header view will trace down with. End up dragging on the y contentOffset if less than `heightCanTriggerSwitch`, `- WZDraggableSwitchHeaderViewDidTriggerDeepDragging` will be invoked properly.
/// Default is 70.0f.
@property (nonatomic, assign) CGFloat heightCanTriggerSwitch;

/// The status label shows the text of state.
@property (nonatomic, strong) UILabel *statusLabel;

/// The button can be tapped to return to menu.
@property (nonatomic, strong) UIButton *backButton;

/// The layer of arrow Image.
@property (nonatomic, strong) CALayer *arrowImage;

/// The state of this headerView.
@property (nonatomic, assign) WZDraggableSwitchState state;

/// The text will show in normal state. Default is `ABOUT`.
@property (nonatomic, strong) NSString *normalStateText;

/// The text will show on shallow dragging state. Default is `PULL TO RETURN TO MENU.`
@property (nonatomic, strong) NSString *shallowStateText;

/// The text will show on deep dragging state. Default is `RELEASE TO RETURN TO MENU.`
@property (nonatomic, strong) NSString *deepStateText; 

Contact

  • If you have some advice, open an issue or PR
  • Email me

Credits

Logo :

Font :

  • Fundamental Brigade Schwer Copyright (c) 2012 by Peter Wiegel.

License

WZDraggableSwitchHeaderView is available under the MIT license, see the LICENCE file for more info.

wzdraggableswitchheaderview's People

Watchers

Chew Chit Siang avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.