Giter Club home page Giter Club logo

fstextview's Introduction

FSTextView

继承于UITextView的自定义TextView, 带placeholder和可限制最大输入字符数, 已适配横竖屏切换.

支持使用CocoaPods引入, Podfile文件中添加:
pod 'FSTextView'

注: 使用CocoaPods引入的话, 纯代码创建没有任何问题, 但在Storyboard中设置时会提示 Fail to update auto layout status: Fail to load designables from path (null)解决办法是在Podfile文件中添加use_frameworks!target 'YourProjectName' do前即可, 但这个方法只能是iOS8及往后版本才行, 如果你的项目版本支持的是iOS7及之前版本的话会报错, 或者你可以找到Pod文件夹中FSTextView的源码, 删除FSTextView.h中的IB_DESIGNABLE字段(删除后就没有了Storyboard中FSTextView的相关属性即设置即显示的效果).

基本使用方法:

FSTextView *textView = [FSTextView textView];
textView.placeholder = @"这是一个继承于UITextView的带Placeholder的自定义TextView, 可以设定限制字符长度, 以Block形式回调, 简单直观 !";
// 限制输入最大字符数.
textView.maxLength = 10;
// 添加输入改变Block回调.
[textView addTextDidChangeHandler:^(FSTextView *textView) {
    // 文本改变后的相应操作.
}];
// 添加到达最大限制Block回调.
[textView addTextLengthDidMaxHandler:^(FSTextView *textView) {
    // 达到最大限制数后的相应操作.
}];

竖屏状态

竖屏状态

横屏状态

横屏状态

目前已知的小问题: (不影响使用, Xcode8.3 已修复了这个问题)

在Storyboard中设置Placeholder颜色不会在Storyboard上马上呈现, 但是其实已经修改成功的了, 运行时Placeholder的颜色会是你所设置的颜色.

Requirements

iOS 6.0 +, Xcode 7.0 +

Version

  • 1.8 :

    Fix: 因为 UIMenuController 引起的 unrecognized selector sent to instance 错误.

  • 1.4 :

Fix: 达到最大限制字符数后 Undo 行为导致crash.

  • 1.3 :

    Fix: 在 Storyboard 中设置 text 后, 字符限制没有生效和 placeholder 没有自动隐藏的问题.

    新增: 添加 canPerformAction 属性来设定 FSTextView 是否允许长按弹出UIMenuController.

  • 1.2 :

    修复 #issue5

    删除了原来重载的父类属性 textgetter 方法, 如果需要获取一个去除首尾空格和换行符的字符串则调用 formatText 即可.

    FSTextView *textView = [FSTextView textView];
    textView.formatText; // 该属性获取到的字符串为去除首尾空格和换行符的.
  • 1.1 :

    更换注册通知的方式, 避免影响其它的 FSTextView 实例.

License

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

fstextview's People

Contributors

lifution avatar

Watchers

James Cloos 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.