Giter Club home page Giter Club logo

smiconlabel's Introduction

SMIconLabel

Version License Platform ![](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 )

smiconlabel's People

Contributors

anatoliyv avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.