CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✗ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Sep 2016 |
| SPMSupports SPM | ✗ |
Maintained by chanricle.
NCKTextView is a very high-performance rich editor. Because it’s a subclass of UITextView, not UIWebView. All of code by TextKit framework.
Xcode 7.3 or newer
| Tag | Swift |
|---|---|
| <= 0.4.x | 2.2 |
| >= 0.5.0 | 3.0 |
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.
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 func changeCurrentParagraphTextWithInputFontMode(mode: NCKInputFontMode)
public func changeSelectedTextWithInputFontMode(mode: NCKInputFontMode)
public func changeCurrentParagraphToOrderedList(orderedList isOrderedList: Bool, listPrefix: String)Get JSON by
public func textAttributesJSON() -> StringThis method return a JSON string that contains all attributes needs to reload.
A unordered list
convert to JSON look like:
{
"text" : "- A\n- B\n- 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)To run the example project, clone the repo, and run pod install from the Example directory first.
git clone -b master https://github.com/chanricle/NCKTextView.git
Chanricle King, [email protected]
NCKTextView is available under the MIT license. See the LICENSE file for more info.