Latest 2.0.0
Homepage https://github.com/mattnydam/MNFloatingActionButton
License MIT
Platforms ios 8.0
Authors

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

    ;

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!

Latest podspec

{
    "name": "MNFloatingActionButton",
    "summary": "A F.A.B for iOS. Such fabulous.",
    "version": "2.0.0",
    "description": ""A customisable FAB (Floating Action Button)"",
    "homepage": "https://github.com/mattnydam/MNFloatingActionButton",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Matt Nydam": "[email protected]"
    },
    "source": {
        "git": "https://github.com/mattnydam/MNFloatingActionButton.git",
        "tag": "2.0.0"
    },
    "social_media_url": "https://twitter.com/mattnydam",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "MNFloatingActionButton/Classes/**/*",
    "resource_bundles": {
        "MNFloatingActionButton": [
            "MNFloatingActionButton/Assets/*.png"
        ]
    }
}

Pin It on Pinterest

Share This