Code Monkey home page Code Monkey logo

aphorizontalmenu's Introduction

APHorizontalMenu

Version Platform

Usage

To run the example project; clone the repo, and run pod install from the Example directory first.

Installation

APHorizontalMenu is available through CocoaPods, to install it simply add the following line to your Podfile:

pod "APHorizontalMenu"

Example

iPhone

Usage

Using APHorizontalMenu is really easy, there is an Example project that you can check, but here are the basics.

You can add APHorizontalMenu programmatically or using Storyboards.

Programmatically

Just init the APHorizontalMenu, fill it with values and add it to an existing view.

APHorizontalMenu *horizontalMenu = [[APHorizontalMenu alloc] initWithFrame:CGRectMake(0, 200, 320, 40)];
horizontalMenu.delegate = self;
horizontalMenu.values = @[@"Item 1", @"Item 2", @"Item 3", @"Item 4", @"Item 5", @"Item 6", @"Item 7", @"Item 8", @"Item 9", @"Item 10"];
[self.view addSubview:horizontalMenu];

Storyboards

In this case, create a new UIView using the Storyboards UI designer and set the position, size and layout restrictions as desired. Then, go to the Utilities -> Identity inspector -> Custom class -> Class and write down "APHorizontalMenu".

Then, create an outlet as follows in your Controller.

@property (weak, nonatomic) IBOutlet APHorizontalMenu *horizontalMenu;

And in the implementation file of your controller add at least this.

self.horizontalMenu.delegate = self;

Delegate

Do not forget to add implement the APHorizontalMenuDelegate as follows. First add the Delegate in the header file of your controller, for example:

@interface ViewController : UIViewController <APHorizontalMenuSelectDelegate>

And conform the protocol by creating the method in the implementation file of your controller so you can receive messages:

- (void)horizontalMenu:(id)horizontalMenu didSelectPosition:(NSInteger)index {
    NSLog(@"APHorizontalMenu selection: %d", index);
    // Do whatever
}

Customization

You can customize some of the properties of APHorizontalMenu like this:

self.horizontalMenu.cellBackgroundColor = [UIColor brownColor];
self.horizontalMenu.cellSelectedColor = [UIColor greenColor];
self.horizontalMenu.textColor = [UIColor blackColor];
self.horizontalMenu.textSelectedColor = [UIColor blueColor];
self.horizontalMenu.selectedIndex = 2;
self.horizontalMenu.visibleItems = 3;

Contact

Abel Pascual

License

APHorizontalMenu is available under the MIT license. See the LICENSE file for more info.

aphorizontalmenu's People

Contributors

apascual avatar tevghenii 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.