Giter Site home page Giter Site logo

engmsaleh / ios----bubblebuttonview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bennyguitar/ios----bubblebuttonview

0.0 0.0 0.0 60 KB

Dynamically fill a UIView with rounded-corner UIButtons based off of an array of strings. This class also sequentially animates the adding and removing of buttons for a nice UI touch.

License: MIT License

ios----bubblebuttonview's Introduction

BubbleButtonView

Dynamically fill a subclassed UIView with rounded-corner UIButtons based off of an array of strings. This class also sequentially animates the adding and removing of buttons for a nice UI touch.

ScreenShot

Installation

Drag the included BBView.m, BBView.h files into your project. Then, include the following frameworks under Link Binary With Libraries:

  • QuartzCore.framework

Using BBView

Make sure to #import BBView.h into whatever ViewController you want to use the BubbleButtonView in.

BBView works by taking an array of NSStrings and creating a UIButton for each one. The buttons are systematically added to the View such that they will fit on the line next to the last one, or if it won't fit, added on a new line. Because BBView's animations work via subviews (each UIButton is a subview of BBView), you should make BBView the lowest level possible - don't add more UI elements to BBView. Keep it simple.

Begin by making a new UIView in your ViewController.xib, and changing its class to BBView (through the identity inspector in the right bar). Drag this over to your ViewController.h to connect it up. In your .h

@interface ViewController : UIViewController <BBDelegate> {
  __weak IBOutlet BBView *bubbleView;
}

Notice we added the BBDelegate to your ViewController, and make sure you set bubbleView's delegate to self inside ViewDidLoad or wherever you instantiate your BBView.

Now, to fill the BBView with your buttons, first create an NSArray of NSStrings. Ideally, this would tie into data you wish to manipulate - this part is entierly dependent on your project and what you wish to do. BBView also has arguments for the background color, text color and font-size for each button. This is for UI and again, entirely up to you. This is the function you should call inside your ViewController:

[bubbleView fillBubbleViewWithButtons:NSArray bgColor:UIColor textColor:UIColor fontSize:float];

Each UIButton is given a tag based on the index of the array you pass in. Use the -(void)didClickBubbleButton:(UIButton *)bubble; method from the BBDelegate to manipulate your data. Use bubble.tag to do so.

Reap What I Sow!

This project is distributed under the standard MIT License. Please use this and twist it in whatever fashion you wish - and recommend any cool changes to help the code.

ios----bubblebuttonview's People

Contributors

bennyguitar 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.