Latest 0.4.0
Homepage https://github.com/anatoliyv/SMIconLabel
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit
Authors

Version
License
Platform
SMIconLabel
![](https://img.shields.io/badge/Swift 3-compatible-4BC51D.svg?style=flat)

UILabel with possibility to place small icon on the left or on the right side. Take a look at preview image or build sample app to see how it works.

Preview

Installation

Manually

This repo has an example project, but if you want to include SMIconLabel you need only one file SMIconLabel.swift.

CocoaPods

Alternatively you can use CocoaPods to install:

pod 'SMIconLabel'

Usage

Usage is as simple as possible. Here is an Swift 2.0 example:

let labelLeft = SMIconLabel(frame: CGRectMake(10, 10, view.frame.size.width - 20, 20))
labelLeft.text = "Icon on the left, text on the left"

// Here is the magic
labelLeft.icon = UIImage(named: "Bell")    // Set icon image
labelLeft.iconPadding = 5                  // Set padding between icon and label
labelLeft.numberOfLines = 0                // Required
labelLeft.iconPosition = ( .Left, .Top )   // Icon position
view.addSubview(labelLeft)

Icon Position

Icon position should be customized via iconPosition property. It’s defined next way:

typealias SMIconPosition = (horizontal: SMIconHorizontalPosition, vertical: SMIconVerticalPosition)

In this case if you want to make icon to be placed in top-left do:

labelLeft.iconPosition = ( .Left, .Top )

Latest podspec

{
    "name": "SMIconLabel",
    "version": "0.4.0",
    "summary": "UILabel with image placed on the left or right side",
    "description": "UILabel with possibility to place small icon on the left or on the right side.nTake a look at preview image or build smaple app to see how it works.",
    "homepage": "https://github.com/anatoliyv/SMIconLabel",
    "license": "MIT",
    "authors": {
        "Anatoliy Voropay": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/anatoliyv/SMIconLabel.git",
        "tag": "v.0.4.0"
    },
    "source_files": "SMIconLabel/*",
    "frameworks": "UIKit",
    "requires_arc": true
}

Pin It on Pinterest

Share This