Skip to content

💪之前代码是基于UITextView进行的封装,侵入性较强,不方便使用,现使用Category重构代码,支持Cocoapods

License

Notifications You must be signed in to change notification settings

CrabMen/CMInputView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DECLARATION:

Because the original code use inheritance which is too intrusive, now I use category to reconstruct the code, and released new version 。

Table of contents

Screenshots

效果展示

Installation

CocoaPods:

  • For iOS8+:
use_frameworks!
target '<Your Target Name>' do
    pod 'UITextView+CMInputView'
end

Manually:

  • Drag all files under CMInputView/CMInputView/Class folder into your project.

Pre-knowledge

Example

Firstly, you need import the .h file.

if cocoaposd:

#import <UITextView+CMInputView.h>

if manually:

#import "UITextView+CMInputView.h"

Then create UITextView and use this category to configure .

    UITextView * inputView = [[UITextView alloc]initWithFrame:CGRectMake(0, 100, self.view.bounds.size.width, 55)];
    inputView.font = [UIFont systemFontOfSize:18];
    
    inputView.cm_placeholder =  @"UITextView+CMInputView";
    inputView.cm_placeholderColor = [UIColor redColor];
    inputView.cm_maxNumberOfLines = 3;
    
    [self.view addSubview:inputView];

If you want to make the UITextView break line automatically ,you can write like this:

    UITextView * inputView = [[UITextView alloc]initWithFrame:CGRectMake(0, 100, self.view.bounds.size.width, 55)];
    inputView.font = [UIFont systemFontOfSize:18];
   
    inputView.cm_placeholder =  @"UITextView+CMInputView";
    inputView.cm_placeholderColor = [UIColor redColor];
    inputView.cm_autoLineBreak = YES;
    
    [self.view addSubview:inputView];

Congratulations! You're done. 🎉

Notes

  • The category do not support constrained layout,please use carefully !
  • Once you set cm_maxNumberOfLines ,the effect always works,even if you set YES to cm_autoLineBreak

Support this repo

  • ★Star this repo
  • If you find somes bugs or need some new functions,please Issue me

License

"UITextView+CMInputView" is available under the MIT license. See the LICENSE file for more info.

About

💪之前代码是基于UITextView进行的封装,侵入性较强,不方便使用,现使用Category重构代码,支持Cocoapods

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published