
To run the example project, clone the repo, and run pod install from the Example directory first.
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]; 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)- Xcode Minimum Supported Version: Xcode 5.0
- iOS Minimum Deployment Target: iOS 6.0
- Language Support: Swift (any version), Objective-C
Using CocoaPods
- Add the pod
UIButton+MiddleAligningto your Podfile.
pod "UIButton+MiddleAligning"- Run
pod installfrom Terminal, then open your app's.xcworkspacefile to launch Xcode. - Import the
UIButton+MiddleAligningheader.
- Swift project:
import UIButton_MiddleAligning - Objective-C project:
import "UIButton+MiddleAligning.h"
Manually from GitHub
- Download the source files in the Pod/Classes/UIButton+MiddleAligning subdirectory.
- Add the source files to your Xcode project.
- Import the
UIButton+MiddleAligningheader.
- Swift project:
import UIButton_MiddleAligning - Objective-C project:
import "UIButton+MiddleAligning.h"
Barry Lee, hcbarry@gmail.com
MiddleAlignedButton is available under the MIT license. See the LICENSE file for more info.
