Latest 0.5.0
Homepage https://github.com/chanricle/NCKTextView
License MIT
Platforms ios 9.0
Authors

[CI Status](https://travis-ci.org/Chanricle King/NCKTextView)
codebeat badge
Version
License
Platform

NCKTextView is a very high-performance rich editor. Because it’s a subclass of UITextView, not UIWebView. All of code by TextKit framework.

Features

  • Bold Text
  • Italic Text
  • Unordered List
  • Ordered List
  • List auto indentation
  • Undo and Redo
  • Rich Text Copy & Paste

Requirements

Xcode 7.3 or newer

Tag Swift
<= 0.4.x 2.2
>= 0.5.0 3.0

Usage

Not extends any class, not EditorController and so on…

You can embed NCKTextView to anywhere that you want.

// Init TextView
let textView = NCKTextView(frame: self.view.bounds, textContainer: NSTextContainer())

// If you want to use built-in toolbar, call it.
textView.enableToolbar()

// add to View
self.view.addSubview(textView)

Done.

UITextViewDelegate

Some feature I use delegate method, so NCKTextView is delegate self. And provide another delegate property named nck_delegate

public var nck_delegate: UITextViewDelegate?

Public methods

Type transform

public func changeCurrentParagraphTextWithInputFontMode(mode: NCKInputFontMode)
public func changeSelectedTextWithInputFontMode(mode: NCKInputFontMode)

public func changeCurrentParagraphToOrderedList(orderedList isOrderedList: Bool, listPrefix: String)

Text attributes persistent

Get JSON by

public func textAttributesJSON() -> String

This method return a JSON string that contains all attributes needs to reload.

A unordered list

  • A
  • B
  • C

convert to JSON look like:

{
  "text" : "- An- Bn- C",
  "attributes" : [
    {
      "location" : 0,
      "length" : 11,
      "fontType" : "normal",
      "name" : "NSFont"
    },
    {
      "location" : 0,
      "length" : 11,
      "listType" : 3,
      "name" : "NSParagraphStyle"
    }
  ]
}

Set JSON and display to UITextView by

public func setAttributeTextWithJSONString(jsonString: String)

Or just set attributes only by

public func setAttributesWithJSONString(jsonString: String)

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

demo

Installation

Stable source code

git clone -b master https://github.com/chanricle/NCKTextView.git

Cocoapods

NCKTextView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "NCKTextView"

Author

Chanricle King, [email protected]

License

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

Latest podspec

{
    "name": "NCKTextView",
    "version": "0.5.0",
    "summary": "NCKTextView is a high-performance rich editor based on UITextView and code with TextKit.",
    "description": "NCKTextView is a very high-performance rich editor. Because it's a subclass of UITextView, not UIWebView. All of code by TextKit framework.",
    "homepage": "https://github.com/chanricle/NCKTextView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Chanricle King": "[email protected]"
    },
    "source": {
        "git": "https://github.com/chanricle/NCKTextView.git",
        "tag": "0.5.0"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "NCKTextView/Classes/**/*",
    "resource_bundles": {
        "NCKTextView": [
            "NCKTextView/Assets/*"
        ]
    }
}

Pin It on Pinterest

Share This