TextImageButton
Image spacing and side selection for UIButton
Install / Use
/learn @timbodeit/TextImageButtonREADME
TextImageButton
Image spacing and side selection for UIButton. Fully auto-layout compatible.

Usage
Setting text and image on TextImageButton works like it does on a vanilla UIButton:
let button = TextImageButton()
button.setTitle("I'm a TextImageButton", forState: .Normal)
button.setImage(UIImage(named: "beachball"), forState: .Normal)
<img src="./ReadmeImages/usage_initial.png" height=40>
Spacing
It allows specifying the spacing between title and image:
button.spacing = 20
<img src="./ReadmeImages/usage_spacing.png" height=40>
Image position
To choose the side the image is set on, specify imagePosition.
There is also boolean @IBInspectable imageOnRight attribute that you can set inside the storyboard
button.imagePosition = .Right
<img src="./ReadmeImages/usage_right_side.png" height=40>
Swift Version
While TextImageButton can be used in Objective-C code, it is written completely in Swift.
Version 0.2 is compatible with Swift 3. For Swift 2 use Version 0.1.1.
Example Project
To run the example project, clone the repo, and run pod install from the Example directory first.
Installation
TextImageButton is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "TextImageButton"
Author
Tim Bodeit, tim@bodeit.com
Inspired by this stackoverflow answer by jasongregori.
License
TextImageButton is available under the MIT license. See the LICENSE file for more info.
Related Skills
node-connect
343.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
92.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
