Coder Social home page Coder Social logo

fltextview's Introduction

FLTextView: UITextView + Placeholder in Swift

Version License

FLTextView adds a placeholder to UITextView just like UITextField natively provides. Compared to other similar libraries we allow the ability to grow (in height or content size) the area of UITextView depending on the size of the placeholder.

Requirements

  • iOS 7.0+
  • Xcode 6.1

How To Get Started

Download FLTextView and try out the iPhone example app.

Communication

  • If you need help, open an issue.
  • If you find a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Installation with CocoaPods

CocoaPods is a dependency manager for Swift and Objective-C projects. You can install it with the following command:

$ gem install cocoapods

Depending on your Deployment Target, specify the following in your Podfile:

Deployment Target: iOS 7.0+

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '7.0'

pod 'FLTextView/Legacy', '~> 1.0'

CocoaPods only supports Swift source files for iOS 8.0+ Deployment Targets. That is why after you have installed the pods you will have to manually include the folder Pods/FLTextView/FLTextView in your Xcode project as a group.

Deployment Target: iOS 8.0+

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.0'
use_frameworks!

pod 'FLTextView', '~> 1.0'

After editing your Podfile, run the following command:

$ pod install

Usage

You can either configure FLTextView through Interface Builder (see examples) or use it like this:

let textView = FLTextView(frame: CGRectZero, textContainer: nil)
textView.placeholder = "ClapClap"
textView.placeholderTextColor = UIColor.lightGrayColor()

Attributed strings are also supported:

let placeholder = NSMutableAttributedString(string: "No excuses")
placeholder.addAttribute(NSForegroundColorAttributeName, value: UIColor(white: 0.7, alpha: 1.0), range: NSMakeRange(0, 10))
placeholder.addAttribute(NSStrikethroughStyleAttributeName, value: NSUnderlineStyle.StyleDouble.rawValue, range: NSMakeRange(3, 7))
placeholder.addAttribute(NSUnderlineStyleAttributeName, value: NSUnderlineStyle.StyleSingle.rawValue, range: NSMakeRange(0, 2))

textView.attributedPlaceholder = placeholder

License

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

fltextview's People

Contributors

danilobuerger avatar janndriessen avatar pitsko 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.