Giter Site home page Giter Site logo

pisces / orangelabel Goto Github PK

View Code? Open in Web Editor NEW
20.0 1.0 3.0 254 KB

OrangeLabel is extensions of UILabel linkable, available line background and placeholder text

License: MIT License

Swift 93.10% Ruby 4.92% Objective-C 1.98%
carthage placeholder-text cocoapods xcode uilabel-linkable mention url-link-view hashtag activelabel attributedtext

orangelabel's Introduction

OrangeLabel

Swift CI Status Version License Platform Carthage Compatible

  • OrangeLabel is extensions of UILabel linkable, available line background and placeholder text

Features

  • Link for mention, hashtag, url and custom
  • Placeholder text and color
  • Line background

Import

import OrangeLabel

Example

let numbers = UILabelLinkType.custom(pattern: "[0-9]+")
let label = OrangeLabel()
label.adjustsFontSizeToFitWidth = true
label.enabledLinkTypes = [.mention, .hashtag, .url, numbers]
label.isUserInteractionEnabled = true
label.font = UIFont(name: "AvenirNext-Bold", size: 60)
label.minimumScaleFactor = 0.2
label.lineBackgroundColor = .black
label.lineBackgroundInset = UIEdgeInsets(top: -5, left: 5, bottom: -5, right: 5)
label.numberOfLines = 0
label.text = "@steve Your selfie overed 1000 views @steve Your selfie overed 1000 views @steve Your selfie overed 1000 views @steve #hahaha http://retrica.co Your selfie overed 1000 views @steve Your selfie overed 1000 views @steve Your selfie overed 1000 views www.retrica.co @steve Your selfie overed 1000 views @steve Your selfie overed 1000 views @steve #hahaha Your selfie overed 1000 views @steve Your selfie overed 1000 views"
label.textAlignment = .center
label.textColor = .white

label.setHighlightedLinkColor(UIColor.white.withAlphaComponent(0.5), type: .mention)
    .setHighlightedLinkColor(UIColor.white.withAlphaComponent(0.5), type: .hashtag)
    .setHighlightedLinkColor(UIColor.white.withAlphaComponent(0.5), type: .url)
    .setHighlightedLinkColor(UIColor.white.withAlphaComponent(0.5), type: numbers)
    .setAttributes([NSUnderlineStyleAttributeName: NSUnderlineStyle.styleSingle.rawValue,
                    NSForegroundColorAttributeName: UIColor(red: 1, green: 185/255, blue: 0, alpha: 1)], type: .mention)
    .setAttributes([NSForegroundColorAttributeName: UIColor(red: 225/255, green: 66/255, blue: 16/255, alpha: 1)], type: .hashtag)
    .setAttributes([NSForegroundColorAttributeName: UIColor(red: 0, green: 204/255, blue: 238/255, alpha: 1)], type: .url)
    .setAttributes([NSForegroundColorAttributeName: UIColor(red: 1, green: 85/255, blue: 0, alpha: 1)], type: numbers)

label.linkTapped { (link) in
    print(link)
}

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.1.0+ is required to build OrangeLabel 0.1.0+.

To integrate OrangeLabel into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'

target '<Your Target Name>' do
    pod 'OrangeLabel', '~> 0.2.0'
end

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Alamofire into your Xcode project using Carthage, specify it in your Cartfile:

github "pisces/OrangeLabel" ~> 0.2.0

Run carthage update to build the framework and drag the built OrangeLabel.framework into your Xcode project.

Requirements

iOS Deployment Target 9.0 higher

Author

Steve Kim, [email protected]

License

OrangeLabel is available under the MIT license. See the LICENSE file for more info.

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.