MaxHasADHD / UIButton-ImageAndTitlePositioning

A Swift-based UIButton extension to enable a button title positioning with respect to the button image

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UIButton-ImageAndTitlePositioning


Copyright (c) 2018 mervynokm. All rights reserved.

A Swift-based UIButton extension to enable a button title positioning with respect to the button image.

image

How to Use it


It simple! All you have to do is to copy the "ButtonWithImageAndTitleExtension.swift" into your project.


In a Swift project no further import is required (but I'm sure you alreay know that!). Simply initialize your button and use the following instance method:
set(image: UIImage?, title: String, titlePosition: Position, additionalSpacing: CGFloat, state: UIControlState)

or for attributed strings,

set(image: UIImage?, attributedTitle title: NSAttributedString, at position: Position, width spacing: CGFloat, state: UIControlState)

In an Objective-C project, all you have to do is add the file into your project and let XCode generate the necessary Swift files! Then,
#import "ProductModuleName-Swift.h"

and

[button setWithImage:(UIImage *) title:(NSString *) titlePosition:(Position) additionalSpacing:(CGFloat) state:(UIControlState)]

Ta-dah!!!!

About

A Swift-based UIButton extension to enable a button title positioning with respect to the button image

License:MIT License


Languages

Language:Swift 100.0%