GithubHelp home page GithubHelp logo

lzm470445107 / eetoolbarcenterbutton Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yoichitgy/eetoolbarcenterbutton

0.0 2.0 0.0 449 KB

UI component to add a featured button to the center of UIToolbar.

Home Page: http://fotovidia.com/2012/02/how-to-add-a-featured-center-button-to-uitoolbar-like-fotovidia/

License: MIT License

eetoolbarcenterbutton's Introduction

EEToolbarCenterButton

EEToolbarCenterButton is a component to add a featured button to the center of UIToolbar. It handles button alignment, and helps you use button images whose height is larger than UIToolbar height.

Screenshot

Supported Environment

iOS 5 or later.

Installation

EEToolbarCenterButton can be installed by CocoaPods with your Podfile containing the following line.

pod 'EEToolbarCenterButton'

Or, just copy files in the Classes directory to your project. In this case, you have to add the -fobjc-arc compiler flag to the EEToolbarCenterButton source (.m) files if your project doesn't use ARC.

Usage

The usage of the center button feature is quite similar to that of UIToolbar with UIBarButtonItem. First, import "UIToolbar+EEToolbarCenterButton.h" and turn on the center button feature:

#import "UIToolbar+EEToolbarCenterButton.h"

...

self.toolbar.centerButtonFeatureEnabled = YES;

Then create an EEToolbarCenterButtonItem with custom images and an action selector:

UIImage *centerButtonImage = [UIImage imageNamed:@"ButtonImage"];
UIImage *centerButtonImageHighlighted = [UIImage imageNamed:@"HighlightedButtonImage"];
UIImage *centerButtonImageDisabled = [UIImage imageNamed:@"DisabledButtonImage"];
EEToolbarCenterButtonItem *centerButtonItem = [[EEToolbarCenterButtonItem alloc] 
                                                initWithImage:centerButtonImage
                                                highlightedImage:centerButtonImageHighlighted
                                                disabledImage:centerButtonImageDisabled
                                                target:self
                                                action:@selector(didTapCenterButton:)];

At last apply the button to centerButtonOverlay property of UIToolbar added by EEToolbarCenterButton category:

self.toolbar.centerButtonOverlay.buttonItem = centerButtonItem;

Now you find a cool button at the center of UIToolbar. You can enable/disable the center button like a UIBarButtonItem:

centerButtonItem.enabled = NO;

Demo Project

Open EEToolbarCenterButton.xcodeproj and run.

Customization

Creating your own button images makes your app unique. The following website lists a number of tutorials to make cool buttons with Photoshop:

http://naldzgraphics.net/tutorials/40-best-photoshop-tutorials-for-creating-buttons-and-badges/

Credits

Feel free to send pull requests or create new issues if you have feature suggestions or bug reports. If you're going to use EEToolbarCenterButton in your project, proper attribution would be nice.

eetoolbarcenterbutton's People

Contributors

yoichitgy avatar

Watchers

 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.