Skip to content

SymphonyOSF/MNFloatingActionButton

Repository files navigation

MNFloatingActionButton

A little iOS experiment, a Floating Action Button.

button gif

###Installation

As Cocoapod https://cocoapods.org

pod 'MNFloatingActionButton', '~> 2,0'

Alternatively, add the images and .h &.m files to your project.

###General Usage Just like a normal button, you instantiate with a frame and add as a subview.

 MNFloatingActionButton *button = [[MNFloatingActionButton alloc] initWithFrame:CGRectMake(0,0,50,50)];
 [self.view addSubview:button];

As it is a subclass of UIControl, you can add a target to listen to touch events. The touch events that are sent are:

  • UIControlEventTouchUpInside

  • UIControlEventTouchCancel

      [button addTarget:self action:@selector(createButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    

You can also use MNFloatingActionButton in Storyboards and xibs by creating a UIView object and changing it's custom class to MNFloatingActionButton.

###Customisation

There are currently 6 properties that you can modify to customise your button. They are:

  • centerImage - Set to nil if you don't want an image
  • backgroundColor - Defaults to some kinda blue
  • shadowColor - Defaults to the background color.
  • shadowOpacity - Default is 0.6f
  • shadowRadius - Default is 1.5f
  • animationScale - Set's the end size of button when pressed. Defaults to 0.85f
  • animationDuration - Defaults to 0.05f

###Thanks

I did this because I thought it might be fun for people to play around with. If you like, or you don't like it, then help make it better with a PR!

Packages

No packages published