/MiddleAlignedButton

An UIButton category for middle aligning imageView and titleLabel

Primary LanguageObjective-CMIT LicenseMIT

MiddleAlignedButton

![CI Status](http://img.shields.io/travis/Barry Lee/MiddleAlignedButton.svg?style=flat) Version License Platform

MiddleAlignedButton Demo

Usage

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

Objective-C Example

  UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  UIImage  *image = [UIImage imageNamed:@"YOUR_IMAGE_NAME"];
  NSString *title = @"YOUR_TITLE";
  CGFloat  spacing = 2.0f;

  [button setImage:image forState:UIControlStateNormal];
  [button setTitle:title forState:UIControlStateNormal];
  [button middleAlignButtonWithSpacing:spacing];

Swift Example

  let button = UIButton(type:.Custom)
  let image = UIImage(named: "YOUR_IMAGE_NAME")
  let title = "YOUR_TITLE"
  let spacing : CGFloat = 2.0

  button.setImage(image, forState: .Normal)
  button.setTitle(title, forState: .Normal)
  button.middleAlignButtonWithSpacing(spacing)

Requirements

  • Xcode Minimum Supported Version: Xcode 5.0
  • iOS Minimum Deployment Target: iOS 6.0
  • Language Support: Swift (any version), Objective-C

Installation

Using CocoaPods

  1. Add the pod UIButton+MiddleAligning to your Podfile.
pod "UIButton+MiddleAligning"
  1. Run pod install from Terminal, then open your app's .xcworkspace file to launch Xcode.
  2. Import the UIButton+MiddleAligning header.
  • Swift project: import UIButton+MiddleAligning
  • Objective-C project: import "UIButton+MiddleAligning.h"

Manually from GitHub

  1. Download the source files in the Pod/Classes/UIButton+MiddleAligning subdirectory.
  2. Add the source files to your Xcode project.
  3. Import the UIButton+MiddleAligning header.
  • Swift project: import UIButton+MiddleAligning
  • Objective-C project: import "UIButton+MiddleAligning.h"

Author

Barry Lee, hcbarry@gmail.com

License

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