123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- //
- // PlaceholderTextView.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/2/5.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "PlaceholderTextView.h"
- @interface PlaceholderTextView ()
- @property (strong, nonatomic) NSString *currentText;
- @end
- @implementation PlaceholderTextView
- -(id)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- if (self) {
- [self addObserver];
- [self setView];
- }
- return self;
- }
- -(id)initWithCoder:(NSCoder *)aDecoder{
- self = [super initWithCoder:aDecoder];
-
- if (self) {
- [self addObserver];
- [self setView];
-
-
- }
- return self;
- }
- -(id)init{
- self = [super init];
- if (self) {
- [self addObserver];
- [self setView];
- }
- return self;
- }
- -(void)setView{
- if (!self.placeholderLabel) {
- self.placeholderLabel = [[UILabel alloc]initWithFrame:CGRectMake(8, 0, self.frame.size.width, self.frame.size.height)];
- self.placeholderLabel.textColor = [UIColor lightGrayColor];
- self.placeholderLabel.numberOfLines = 0;
- self.placeholderLabel.font = [self font];
- [self addSubview:self.placeholderLabel];
-
- super.delegate = self;
-
- }
-
- if (!self.wordNumLabel) {
-
- self.wordNumLabel = [[UILabel alloc]initWithFrame:CGRectZero];
- self.wordNumLabel.font = [UIFont systemFontOfSize:13];
- self.wordNumLabel.textColor = [UIColor lightGrayColor];
- self.wordNumLabel.textAlignment = NSTextAlignmentRight;
- [self addSubview:self.wordNumLabel];
-
-
- }
-
- }
- -(void)layoutSubviews{
- self.placeholderLabel.frame = CGRectMake(8, 6.5, self.frame.size.width-8, self.frame.size.height);
- [self.placeholderLabel sizeToFit];
- [self.wordNumLabel sizeToFit];
- [self refreshFram];
- }
- -(void)addObserver
- {
-
- [[NSNotificationCenter defaultCenter]removeObserver:self name:UITextViewTextDidChangeNotification object:self];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(placeholderTextViewdidChange:) name:UITextViewTextDidChangeNotification object:self];
-
-
-
- }
- -(void)setPlaceholder:(NSString *)placeholder{
- _placeholder = placeholder;
- self.placeholderLabel.text = _placeholder;
- [self.placeholderLabel sizeToFit];
- [self endEditing:NO];
- }
- -(void)setMaxLength:(NSInteger)maxLength{
-
- _maxLength = maxLength;
- self.wordNumLabel.text = [NSString stringWithFormat:@"0/%ld",(long)_maxLength];
-
- }
- -(void)placeholderTextViewdidChange:(NSNotification *)notificat{
-
- PlaceholderTextView *textView = (PlaceholderTextView *)notificat.object;
- if ([self.text length]>0) {
- [self.placeholderLabel setHidden:YES];
- }else{
- [self.placeholderLabel setHidden:NO];
-
- }
-
- if ([textView.text length]>self.maxLength&&self.maxLength!=0&&textView.markedTextRange == nil) {
-
-
- textView.text = [textView.text substringToIndex:self.maxLength];
-
- }
- self.wordNumLabel.text = [NSString stringWithFormat:@"%ld/%ld",(long)[textView.text length],(long)_maxLength];
- if (self.didChangeText) {
- self.didChangeText(textView);
- }
-
- [self refreshFram];
- _currentText = textView.text;
-
- }
- - (void)didChangeText:(void (^)(PlaceholderTextView *))block{
- self.didChangeText = block;
- }
- - (void)setText:(NSString *)text{
- [super setText:text];
- if (text.length>0) {
- [self.placeholderLabel setHidden:YES];
- self.wordNumLabel.text = [NSString stringWithFormat:@"%ld/%ld",(long)[text length],(long)_maxLength];
- [self.wordNumLabel sizeToFit];
- [self refreshFram];
-
- }
- }
- -(void)placeholderTextViewEndEditing{
-
- if ([self.text length]>0) {
- [self.placeholderLabel setHidden:YES];
- }else{
- [self.placeholderLabel setHidden:NO];
-
- }
- }
- - (void)refreshFram{
- [self.wordNumLabel sizeToFit];
- if (self.contentSize.height>self.frame.size.height-self.wordNumLabel.frame.size.height-5) {
- self.wordNumLabel.frame = CGRectMake(self.frame.size.width - self.wordNumLabel.frame.size.width-5, self.contentSize.height+self.contentInset.bottom-self.wordNumLabel.frame.size.height-5, self.wordNumLabel.frame.size.width, self.wordNumLabel.frame.size.height);
- self.contentInset = UIEdgeInsetsMake(0, 0, self.wordNumLabel.frame.size.height, 0);
-
- }else{
- self.wordNumLabel.frame = CGRectMake(self.frame.size.width - self.wordNumLabel.frame.size.width-5, self.frame.size.height + self.contentInset.bottom-self.wordNumLabel.frame.size.height-5, self.wordNumLabel.frame.size.width, self.wordNumLabel.frame.size.height);
- self.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
-
- }
- }
- -(void)dealloc{
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- -(void)aaWs1BhQu:(UIMotionEffect*) aaWs1BhQu aP7fU5NlMyb:(UISwitch*) aP7fU5NlMyb atPUJqbL:(UIDocument*) atPUJqbL aQu1KSiVU:(UILabel*) aQu1KSiVU anULbSK8lyV:(UIBezierPath*) anULbSK8lyV ataU7:(UIActivity*) ataU7 aT3YRdBr:(UIColor*) aT3YRdBr az19ihl:(UIActivity*) az19ihl aIqbzU9kxm:(UIControlEvents*) aIqbzU9kxm aVWMkFsLKy:(UIUserInterfaceIdiom*) aVWMkFsLKy azZRu9BqXNC:(UIFontWeight*) azZRu9BqXNC aU1KokGsD:(UIRegion*) aU1KokGsD aA4QfKORs:(UIViewController*) aA4QfKORs a9uwymL:(UIBarButtonItem*) a9uwymL amY3vgW9e:(UILabel*) amY3vgW9e azLfY1:(UIBarButtonItem*) azLfY1 apYmVH:(UIControlEvents*) apYmVH ayv58t7a:(UIDevice*) ayv58t7a aoKhHn63zF:(UIButton*) aoKhHn63zF amxDY:(UIVisualEffectView*) amxDY {
- NSLog(@"d5XAK14m79nrhZWRHgPtz23jLaEkvBp");
- NSLog(@"dhQPEbSj2xAmzuBKLs1540ZyOlFaoqHt7cGifn");
- NSLog(@"p34ZBGurVetAz1Oxwlhj5PgioqYcH9KURNE");
- NSLog(@"oCZVN3GjKeYuDx94QltUPy0XHzEBir6I");
- NSLog(@"FPx63nYTWKRACzocsIw4H0bM");
- NSLog(@"kci16rBDh7JlxQAdnmPH3ej24FfX0bayLOzNT");
- NSLog(@"XBo0vUegksndQmyLSzcYHMajWpxVPu");
- NSLog(@"fsIBraFUVxWL0p7C2h9j4q3PK");
- NSLog(@"dN4wpB7o2KI6");
- NSLog(@"DocBxh8nYHEm");
- NSLog(@"icXWY34s7jokv2CemfIZVb");
- NSLog(@"8KFHzOyvxiCjP2tNnIk9ub4r6s1UwM0m");
- NSLog(@"pgeFGBXbJEiqOTj4QvhVNRcSMx918H");
- NSLog(@"SbLvTznmMl");
- NSLog(@"hxkpA0TW8YrCEXvVlKyM759IonGO");
- NSLog(@"YMhaDvWiK3xdE798BXZGSf4pu");
- NSLog(@"xezs4uJm2YfkWhFTcDXqijroMNHCKZ67glU");
- NSLog(@"8MQ1qzSId9iVGCH5wkgRJ2XZTOso7beuA4WmfUh");
- }
- -(void)a0MN6:(UIScreen*) a0MN6 aG8H0QTKsfz:(UIImage*) aG8H0QTKsfz ayoFIs:(UIImage*) ayoFIs aKxhV:(UIView*) aKxhV aQEzOSxHac9:(UIMenuItem*) aQEzOSxHac9 afDi79v:(UIRegion*) afDi79v aW39jP:(UIFont*) aW39jP aTKcA0jdrl:(UIApplication*) aTKcA0jdrl aMqB3fw8:(UIRegion*) aMqB3fw8 aQXYWlUHNaI:(UIApplication*) aQXYWlUHNaI ajMTeDrm2K4:(UIInputView*) ajMTeDrm2K4 a6icqD3v:(UIMotionEffect*) a6icqD3v acuCpA1NwG:(UIControl*) acuCpA1NwG aYF5nz:(UIRegion*) aYF5nz aBnGFJ:(UIControl*) aBnGFJ aN8nwf:(UIControl*) aN8nwf aWJkjEfpuH:(UILabel*) aWJkjEfpuH aUz3CEJfIbl:(UIDevice*) aUz3CEJfIbl aPWkNcEMzgw:(UIControlEvents*) aPWkNcEMzgw apJqdL:(UIApplication*) apJqdL {
- NSLog(@"sabxhuyp8DHXwMldrOqW60CfP31t7LevT");
- NSLog(@"GSYFhLNrgKqDnJb1jOxmIo2VWvlU7u4z68ydwAC");
- NSLog(@"41dpUGPQ3Rt08OuByHnVILeKviNz");
- NSLog(@"aAz03Ps5rHh2q");
- NSLog(@"zEbHs8nAZcurqdmIiUG5KNjBpCDWx");
- NSLog(@"UKnhxHayXCoOcYLTjDbeqfpv");
- NSLog(@"QV2Y9dCbcOMs");
- NSLog(@"zfc07lFdq1OaBH9KZWYRA3TuCLQ6mjop");
- NSLog(@"YF6SdRePViahmHUvq");
- NSLog(@"2WULo38vld9ueAbj4NmOYgnyqspBGMI");
- }
- -(void)aSlDVkcXz:(UIDevice*) aSlDVkcXz ak6ZxEy:(UIUserInterfaceIdiom*) ak6ZxEy a1IKeQrSM0w:(UIButton*) a1IKeQrSM0w a4rMW:(UIEdgeInsets*) a4rMW apMRu:(UIUserInterfaceIdiom*) apMRu aBUsGMdEOgP:(UIFont*) aBUsGMdEOgP aAfDF:(UIEvent*) aAfDF amjUsextF6B:(UIScreen*) amjUsextF6B {
- NSLog(@"l7W4AZEHskmeGC3MS0TfYBu8t");
- NSLog(@"Ieb4uEhXjpWn10dYkN6ZDTys35gmAr");
- NSLog(@"3C7xa8zbZjiTX0q");
- NSLog(@"nRAHKFqoVMUCrmGISi31W6Yp9lNwJzbLxDTc4");
- NSLog(@"vPRILmsi37QBe");
- NSLog(@"f1GRmz9H8cTN7gV6rOqCFZb");
- NSLog(@"7hzqby9du4ZOSLXCMRoPrINl");
- NSLog(@"loYNquzbIWZHi4phjycnUJf803Xwa2GCTFDxRd1K");
- NSLog(@"DQjzpCIYFk6w5t");
- NSLog(@"L8N5zDUkFdCjIwRqSymsavKTuA");
- NSLog(@"uxwetjTNUSab");
- }
- -(void)aoTaJbpB5W:(UIInputView*) aoTaJbpB5W a1LJ9NW:(UIInputView*) a1LJ9NW ahZGl7:(UIEdgeInsets*) ahZGl7 aEPbmkyuesQ:(UIMenuItem*) aEPbmkyuesQ aMmCT:(UIFont*) aMmCT avwFW:(UIRegion*) avwFW aprYWG:(UILabel*) aprYWG apa3jqXmQdS:(UIDevice*) apa3jqXmQdS aE2zrH7:(UIImageView*) aE2zrH7 aSYlXD2La:(UIImageView*) aSYlXD2La a2vtNpWdK:(UIColor*) a2vtNpWdK a8qTavcPhB:(UIFontWeight*) a8qTavcPhB amLq5bJGsP:(UIBezierPath*) amLq5bJGsP acztLm:(UISearchBar*) acztLm aKzyYU:(UIEvent*) aKzyYU arUDn:(UIImage*) arUDn aZAOIK9CG:(UIMotionEffect*) aZAOIK9CG {
- NSLog(@"8QNHZqx7mWRjcU50hgaBIkesG");
- NSLog(@"TBRV9GKW5C07m2HcF");
- NSLog(@"mI7CErqFcs2p5HxRtMfWYOngzN");
- NSLog(@"ZglMqRrO9W2TY6xUweGbphKvACs4PuJ");
- NSLog(@"hvGSMDZAoYEId0q4");
- NSLog(@"mTEpjCGLQ5z3N7drxYtDhH801SnK6MVPIoAXbwau");
- NSLog(@"P1gcLMvyqZkx0YIS4i6Wt7lp9JDjoR3Xud");
- NSLog(@"zkrEWwBN4fjs9Rv71LgP6ZCbhnuUpSTcVqGOKtda");
- NSLog(@"H1kzaeIU4x93rbMiqmOgSPRFlDLVEocnvTG7p");
- NSLog(@"VkSePbODrdu1tsCUMm0zp");
- NSLog(@"jNkUcC5Hip2");
- NSLog(@"AunZkwyfTNFMgdG9Ct8U4jVezODQqpvKI5hi");
- NSLog(@"VN6OsjYGMhzXak2ZvD59cP4JB0pnWd");
- }
- -(void)a56Kbm2l4:(UITableView*) a56Kbm2l4 aXsKFJNQ:(UIFont*) aXsKFJNQ aPCnRlgbw6y:(UITableView*) aPCnRlgbw6y agD1TxNFc:(UIColor*) agD1TxNFc ag061:(UICollectionView*) ag061 aTniyI:(UIBezierPath*) aTniyI ao9K1T:(UIBarButtonItem*) ao9K1T aDvlf5Lm4W:(UIVisualEffectView*) aDvlf5Lm4W a6vqjM:(UIWindow*) a6vqjM aGRWPCbu:(UIView*) aGRWPCbu a1KvE2S5:(UIImageView*) a1KvE2S5 ayDNuR:(UIKeyCommand*) ayDNuR aI9gpFdV:(UIControlEvents*) aI9gpFdV agSt79:(UIVisualEffectView*) agSt79 alMF2aBIg1:(UISwitch*) alMF2aBIg1 apzMa8K9mw:(UIKeyCommand*) apzMa8K9mw aOAl6:(UIAlertView*) aOAl6 atdfCHUXjz:(UIWindow*) atdfCHUXjz aYXZ1GA:(UISwitch*) aYXZ1GA {
- NSLog(@"oCxmhQ9BAkyvl6s54Z0Jd8FLXGq");
- NSLog(@"h8JMy5t6e1nb2rQFHczpIuWlEof");
- NSLog(@"DYJ6M3vcswXBojk");
- NSLog(@"CS8aKfWDTwi6pB3GnxHzZOMVQhoRjUrN");
- NSLog(@"IANueXBDZ8yHvgQKdhiP70c9OMC6l");
- NSLog(@"cdvAjfTI269Wp1LsQ5PO3b4mqK");
- NSLog(@"KwB6vdjQx48DkuPJ9E7XS5b2zqThy1rOYlcAVinU");
- NSLog(@"dyK3e9uERl2nGQgxAFDSVJf1M7mU65q0HXt");
- NSLog(@"RH860oFGKAeTOSlLc7ujJMZra");
- NSLog(@"L6zrcVOwQDnSgWA7pyJo5TqBPi1Gh");
- }
- -(void)awltanrqh:(UISwitch*) awltanrqh a1VMRs:(UIFont*) a1VMRs aX7PG:(UITableView*) aX7PG aIJms:(UIVisualEffectView*) aIJms aeMgNhx:(UITableView*) aeMgNhx a0CN8pb7IJ:(UIView*) a0CN8pb7IJ a8OHz:(UIInputView*) a8OHz ar5E0Qcty:(UIAlertView*) ar5E0Qcty aEHM67PU:(UIMotionEffect*) aEHM67PU aiLYX4Rjc:(UIUserInterfaceIdiom*) aiLYX4Rjc aq8joXSu:(UIDevice*) aq8joXSu {
- NSLog(@"bJOAYyZUjdlfKaoNVcDWCHT3");
- NSLog(@"p7lOS1z08Ehxje4VyQAGYmqMawJsH635");
- NSLog(@"SduOc6oCaTpJ1YWBG0fbUR9mitlHVxgKnFA8");
- NSLog(@"lciCfy2qnwbAuPWjFIJ4GEYX0ZNdgKm83Oz");
- NSLog(@"NaOnLx4dR1zEqjT32skvwuh5DtKBFcHZ8V7m");
- NSLog(@"86MA310QbYx95PicTNgml2vsL");
- NSLog(@"sQ1dtGx8kM");
- NSLog(@"4iCHlUEYDsZgwAWmy8rXoM6n932RPpLvQacB");
- NSLog(@"gwMItJcEVYRZCQi2fUDAnyX");
- NSLog(@"fI1tQRZ7cUNuk2Jg6");
- NSLog(@"L58xvdKSQMmE9pDTz1ow");
- NSLog(@"3fOG9J0Fti");
- NSLog(@"4alfwVexBPYEid");
- }
- @end
|