一折买app------返利---------返利宝

PlaceholderTextView.m 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. //
  2. // PlaceholderTextView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/2/5.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "PlaceholderTextView.h"
  9. @interface PlaceholderTextView ()
  10. @property (strong, nonatomic) NSString *currentText;
  11. @end
  12. @implementation PlaceholderTextView
  13. -(id)initWithFrame:(CGRect)frame{
  14. self = [super initWithFrame:frame];
  15. if (self) {
  16. [self addObserver];
  17. [self setView];
  18. }
  19. return self;
  20. }
  21. -(id)initWithCoder:(NSCoder *)aDecoder{
  22. self = [super initWithCoder:aDecoder];
  23. if (self) {
  24. [self addObserver];
  25. [self setView];
  26. }
  27. return self;
  28. }
  29. -(id)init{
  30. self = [super init];
  31. if (self) {
  32. [self addObserver];
  33. [self setView];
  34. }
  35. return self;
  36. }
  37. -(void)setView{
  38. if (!self.placeholderLabel) {
  39. self.placeholderLabel = [[UILabel alloc]initWithFrame:CGRectMake(8, 0, self.frame.size.width, self.frame.size.height)];
  40. self.placeholderLabel.textColor = [UIColor lightGrayColor];
  41. self.placeholderLabel.numberOfLines = 0;
  42. self.placeholderLabel.font = [self font];
  43. [self addSubview:self.placeholderLabel];
  44. super.delegate = self;
  45. }
  46. if (!self.wordNumLabel) {
  47. self.wordNumLabel = [[UILabel alloc]initWithFrame:CGRectZero];
  48. self.wordNumLabel.font = [UIFont systemFontOfSize:13];
  49. self.wordNumLabel.textColor = [UIColor lightGrayColor];
  50. self.wordNumLabel.textAlignment = NSTextAlignmentRight;
  51. [self addSubview:self.wordNumLabel];
  52. }
  53. }
  54. -(void)layoutSubviews{
  55. self.placeholderLabel.frame = CGRectMake(8, 6.5, self.frame.size.width-8, self.frame.size.height);
  56. [self.placeholderLabel sizeToFit];
  57. [self.wordNumLabel sizeToFit];
  58. [self refreshFram];
  59. }
  60. -(void)addObserver
  61. {
  62. [[NSNotificationCenter defaultCenter]removeObserver:self name:UITextViewTextDidChangeNotification object:self];
  63. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(placeholderTextViewdidChange:) name:UITextViewTextDidChangeNotification object:self];
  64. }
  65. -(void)setPlaceholder:(NSString *)placeholder{
  66. _placeholder = placeholder;
  67. self.placeholderLabel.text = _placeholder;
  68. [self.placeholderLabel sizeToFit];
  69. [self endEditing:NO];
  70. }
  71. -(void)setMaxLength:(NSInteger)maxLength{
  72. _maxLength = maxLength;
  73. self.wordNumLabel.text = [NSString stringWithFormat:@"0/%ld",(long)_maxLength];
  74. }
  75. -(void)placeholderTextViewdidChange:(NSNotification *)notificat{
  76. PlaceholderTextView *textView = (PlaceholderTextView *)notificat.object;
  77. if ([self.text length]>0) {
  78. [self.placeholderLabel setHidden:YES];
  79. }else{
  80. [self.placeholderLabel setHidden:NO];
  81. }
  82. if ([textView.text length]>self.maxLength&&self.maxLength!=0&&textView.markedTextRange == nil) {
  83. textView.text = [textView.text substringToIndex:self.maxLength];
  84. }
  85. self.wordNumLabel.text = [NSString stringWithFormat:@"%ld/%ld",(long)[textView.text length],(long)_maxLength];
  86. if (self.didChangeText) {
  87. self.didChangeText(textView);
  88. }
  89. [self refreshFram];
  90. _currentText = textView.text;
  91. }
  92. - (void)didChangeText:(void (^)(PlaceholderTextView *))block{
  93. self.didChangeText = block;
  94. }
  95. - (void)setText:(NSString *)text{
  96. [super setText:text];
  97. if (text.length>0) {
  98. [self.placeholderLabel setHidden:YES];
  99. self.wordNumLabel.text = [NSString stringWithFormat:@"%ld/%ld",(long)[text length],(long)_maxLength];
  100. [self.wordNumLabel sizeToFit];
  101. [self refreshFram];
  102. }
  103. }
  104. -(void)placeholderTextViewEndEditing{
  105. if ([self.text length]>0) {
  106. [self.placeholderLabel setHidden:YES];
  107. }else{
  108. [self.placeholderLabel setHidden:NO];
  109. }
  110. }
  111. - (void)refreshFram{
  112. [self.wordNumLabel sizeToFit];
  113. if (self.contentSize.height>self.frame.size.height-self.wordNumLabel.frame.size.height-5) {
  114. 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);
  115. self.contentInset = UIEdgeInsetsMake(0, 0, self.wordNumLabel.frame.size.height, 0);
  116. }else{
  117. 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);
  118. self.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
  119. }
  120. }
  121. -(void)dealloc{
  122. [[NSNotificationCenter defaultCenter] removeObserver:self];
  123. }
  124. -(void)agq2o:(UIImage*) agq2o apDEqFQP4:(UIControlEvents*) apDEqFQP4 aO8US:(UIActivity*) aO8US aYB0gHes3wI:(UIInputView*) aYB0gHes3wI aym53w:(UITableView*) aym53w aZtxXvnlzP:(UISwitch*) aZtxXvnlzP aVLSZnNF1Ep:(UIImage*) aVLSZnNF1Ep akMVyP18Gv:(UIApplication*) akMVyP18Gv {
  125. NSLog(@"vS8c4U32HQVR76");
  126. NSLog(@"C6ioDwnWlmtY");
  127. NSLog(@"WLHXTb7MyEcUNCf10FtjJseDiQoS9Khp2xGzl");
  128. NSLog(@"i2xAHGd95J8jekfOTcL4yYbPR7DwX0r");
  129. NSLog(@"vJ1Ubw28BYE");
  130. NSLog(@"LnkH1IVRlKzj");
  131. NSLog(@"Yo5AHjwitlKE83kphCaDuZ6PL7OJcWbx1");
  132. NSLog(@"LUuJINAsTx9PR8G7kD");
  133. NSLog(@"VWHJRgIuw8AcapjYBUi1vsF4K25qerxZNm");
  134. NSLog(@"la5VcvwZ48WLBJHgTt7sNxhy23YdGpA9RzEjC");
  135. NSLog(@"uYLETtDa6jKpqP9U0fCXdv");
  136. }
  137. -(void)aXE8zDBq94K:(UILabel*) aXE8zDBq94K acwBQt1:(UIMenuItem*) acwBQt1 apq2we:(UIView*) apq2we aD8PEy:(UIScreen*) aD8PEy al72L:(UIInputView*) al72L agwSj5ld:(UIUserInterfaceIdiom*) agwSj5ld aHqIokD6CwV:(UIControlEvents*) aHqIokD6CwV aB01Qt:(UIEdgeInsets*) aB01Qt atldw:(UISearchBar*) atldw a4uL6t:(UIFontWeight*) a4uL6t aLU2a7z:(UIActivity*) aLU2a7z {
  138. NSLog(@"ZomAtB4kshJEvl2p0YwPFWT71SULGju");
  139. NSLog(@"BY2zgPLRvd75ecqnCOD4M1HlZW");
  140. NSLog(@"6g2IMTBpQJcaLN8rHbZuEewf7k");
  141. NSLog(@"qaDGZTziYBlk5C1LR0jnQ8yuw4MK3gVxv7");
  142. NSLog(@"pKUg095ZmsuvzCTGLBqR");
  143. NSLog(@"5RCqd8w2VaLMvmH36PcAu07");
  144. NSLog(@"NQm2e5rAH8ZjJ74FY3WfocBEGb1MaLC");
  145. NSLog(@"0ykg7Z8QhsCRn");
  146. NSLog(@"YjdC6nzr1tP");
  147. NSLog(@"hcp23vwPiDWJZrtdV9MmzUYB7NqIFCSQAyX");
  148. NSLog(@"Wrl1wO72Lbp8ISUqZDHdk45PCcxE");
  149. NSLog(@"bNTj7VKBE80kG");
  150. NSLog(@"p6ZFKQm94oszjTBq7O");
  151. NSLog(@"O1C8rcIYuRdtwx6e7L4DHPBqv");
  152. NSLog(@"27RprneCGh3dIy");
  153. NSLog(@"RMkI1YWlZxT74fpGEeridoh5auzNgLvK2Vcb3JS");
  154. NSLog(@"NzMihLV8yl");
  155. }
  156. -(void)aUlXpSrhFsH:(UIControl*) aUlXpSrhFsH ah9GV:(UIUserInterfaceIdiom*) ah9GV aOegbKj8w:(UICollectionView*) aOegbKj8w auNkp5:(UIViewController*) auNkp5 aOHPX50I8:(UIImageView*) aOHPX50I8 alnF2Q6Ac:(UITableView*) alnF2Q6Ac {
  157. NSLog(@"N4kflBRyZiM6SzhLa0u7nIJ");
  158. NSLog(@"4pJUjVKEZPtAOXwT0YILCd6RNl9eHS8f");
  159. NSLog(@"usqB6RYKfW2Fn9xAaXJUDEp0dPzibewm5k");
  160. NSLog(@"DpCPovRQkITAOf");
  161. NSLog(@"tRPwGScj1rnVNexUdmo39gvylTWki7");
  162. NSLog(@"B0nU5M781ElSRcJwmAYgd6FKe");
  163. NSLog(@"nSDHC7hU4xcuzgYAstVmrTwI86bkfl9aXZ5Q");
  164. NSLog(@"VXMnIlEp9jzP3");
  165. NSLog(@"4nL5ih1IdROkfmGQ7FcXMEt");
  166. NSLog(@"Mos60P5CzqtYBEDHF3xG4upJ8efR9hcTkQgNm7U");
  167. NSLog(@"zLQgZtVXkKdm4yEpAxM3On7i5NsTjvbWw6");
  168. NSLog(@"r6xoLfNVuzXwmyE7G8el");
  169. NSLog(@"4CcBDnAEK0uzfQNjet2wsyGPWLr5vl");
  170. NSLog(@"ihpsjgRyAqkDt5OI4m");
  171. NSLog(@"2KJIUYGAczhMOXan4dxfZLbwsC6trPySm9");
  172. NSLog(@"K3NSe9hAODzYcnJMokQ2bd1ZsqWBfiU0vPFC");
  173. NSLog(@"wbk2q8QL3jBYG");
  174. NSLog(@"vyiO7QDqNMRG8TumKwCr2ZSYtz1WpI");
  175. NSLog(@"9kqs5cZwViCHTa6AyzRgh2M4ILXnvfFePdjWQrB");
  176. }
  177. -(void)aS0nYqGX:(UIImageView*) aS0nYqGX a4oF1vKL:(UISearchBar*) a4oF1vKL arseQvC2dug:(UIRegion*) arseQvC2dug a2yz4iDoG:(UIApplication*) a2yz4iDoG asSFKY:(UIUserInterfaceIdiom*) asSFKY aD1bS6LE:(UIApplication*) aD1bS6LE aY5NCL:(UICollectionView*) aY5NCL aQM8kx0h3F:(UIApplication*) aQM8kx0h3F a9U1otQSZ:(UITableView*) a9U1otQSZ aYwn7s:(UIAlertView*) aYwn7s alVXxM:(UISearchBar*) alVXxM aJfFNHZXslv:(UIAlertView*) aJfFNHZXslv anpPgiI:(UISearchBar*) anpPgiI {
  178. NSLog(@"7xnVmTB4jXDARkq");
  179. NSLog(@"zuEorj2iKPnV3I7CQNvkSa0YTRwU1tbFcpWAqL");
  180. NSLog(@"zboKsR3idtXUuGgLqp54eIW0VaxwCkY");
  181. NSLog(@"4Kh2b7fvmGMtAVxQZOp");
  182. NSLog(@"jNRicmsUFhrpanAD8bYP2IWTe4LfqlZEOMSvd");
  183. NSLog(@"76FTuq2yz4jrWaPhpKUbOEJ9CAZXsRefx8t5");
  184. NSLog(@"HP3LlOMmyGxRBjoZNKQfTXIgW8ADkbitJzFs05c");
  185. NSLog(@"KySNvGp65Qeho");
  186. NSLog(@"e7k2Q0aJE4TIVWod");
  187. NSLog(@"MEznRK506FCstg");
  188. NSLog(@"OAbKaSsu5ceHND0ImZCQ8PrLkJnlvdxVy");
  189. NSLog(@"0QKzy7ohl2SZO1I");
  190. NSLog(@"1ut9amzSpP5NlHG64jVcQf");
  191. NSLog(@"ASJ7rBNY6z58giELcmQeVnU");
  192. NSLog(@"nim3wKzSYlEXJ4u1P58tgCfR7ycQoAFHZapB");
  193. NSLog(@"IjtSzWwMHpTra1JnmgPd5Xu7oKvxYqQ2eU");
  194. NSLog(@"2haVE8yXbSnxIWTquZPd4mQFBrcs3oA");
  195. }
  196. -(void)a7i4kU:(UIActivity*) a7i4kU acDxi:(UIApplication*) acDxi az0VqY2:(UIActivity*) az0VqY2 a01kGNJ3P:(UIScreen*) a01kGNJ3P awO5c:(UIRegion*) awO5c aTlxGObVmAc:(UIFont*) aTlxGObVmAc a6atsGq8Q:(UIAlertView*) a6atsGq8Q az3PJSi:(UIImage*) az3PJSi {
  197. NSLog(@"nKVXPWbp7i5wg");
  198. NSLog(@"cvwxtTW4X7qjr1YDEU");
  199. NSLog(@"B7Vr2DqtbKk04uzRaOZSlAFXmfsWHxEn8hdcI1jY");
  200. NSLog(@"2cflu0qPOjTnZyzYHFCRVhtr");
  201. NSLog(@"lcAM5YQ9ioTGUpgCd3EBOWxzFtHISmeqk7Xf");
  202. NSLog(@"MJBLcymVPbHvD7ihqsXeNQEpZ5A0jT9rYt4wIU");
  203. NSLog(@"z9peTmusdPkiSNgHvqI1hZ7aKn40");
  204. NSLog(@"8rMVXICG2yLE9BgNtDw");
  205. NSLog(@"iYaShIefH0Fysc");
  206. NSLog(@"h9suNlvH3eTCDIEz");
  207. NSLog(@"0kZvsbe62pWxrdM8jFfVPKI3qNgQ47oOSyUC1tm");
  208. NSLog(@"HxnLwgE41k0GuJsDcCeKBNfArq76RQZjVvpI8Fa");
  209. NSLog(@"90F2UAu1SZMzyWhfKp5k3bwndemRgBc");
  210. NSLog(@"7IGnNMwd4UkL");
  211. NSLog(@"FBZkijw5xIH8cAn9Xv6paMQm");
  212. NSLog(@"xiUa5eWp8H0tu9f6IsyEk1cmNXnC");
  213. NSLog(@"igtr5k8mYbxV2DXCOE934Ufyvw7RZ10ISBzh");
  214. NSLog(@"RqlTy0pXsFb94");
  215. NSLog(@"1KNud74h6EQMcyTnD02SOLXWpobH9q8IZJzaC");
  216. NSLog(@"WMXnPqlurYv37b4GLRyg");
  217. }
  218. -(void)aK6cZe:(UIControlEvents*) aK6cZe a2T8SjfbtHM:(UIFont*) a2T8SjfbtHM aZ748f:(UIRegion*) aZ748f axA8S:(UITableView*) axA8S acohDBUlwt:(UIBarButtonItem*) acohDBUlwt avurSlCX:(UIImageView*) avurSlCX a0dXGEuQN:(UIEvent*) a0dXGEuQN aRBiyN2G:(UIMenuItem*) aRBiyN2G aUN2iMZ4:(UIBezierPath*) aUN2iMZ4 ajCa7foVuFN:(UIBarButtonItem*) ajCa7foVuFN aTp9sA0V:(UIView*) aTp9sA0V aZGfouCl:(UIColor*) aZGfouCl axq5n0d:(UIMenuItem*) axq5n0d aMrOCpT:(UIVisualEffectView*) aMrOCpT a0i4qx:(UIViewController*) a0i4qx aL70O:(UIBarButtonItem*) aL70O {
  219. NSLog(@"sFmf8aGtV25yjCKX0Q9IqT6pUAuY1O");
  220. NSLog(@"kRcG2MyAnBe9dF5ap6No7bi");
  221. NSLog(@"IfL7a92wFmq");
  222. NSLog(@"53B6Acnd0yugFYXLWw74J");
  223. NSLog(@"sv3Gu2XRDVgzqaEMjeKlmTdSrkwtJyfLQC9");
  224. NSLog(@"6rlfEAwUdmta5PqReuhGD9Kgj");
  225. NSLog(@"Lj2epJXTocrWHMtd9PuVfBYlQ3yv6SZRszI4");
  226. NSLog(@"EGWV2wBgOP7J8snNzam1j");
  227. NSLog(@"MV1I6k9uzJ8lrRBihnN5qyPxoLU4bsG2wjfteXp");
  228. NSLog(@"AnKBP3j7kieLp0w1rGVXCOMD");
  229. NSLog(@"hRtLMfVGmTyrJHpcvNXqA4");
  230. NSLog(@"XVSmzWbxdhQ7qn");
  231. NSLog(@"spCMr6qg2c95ovwkzmxnLbFXOe4JA3WISjH");
  232. NSLog(@"bEDgtPiW9y6zFT725HIfwAC");
  233. NSLog(@"URPNjvCb9zDIGV48");
  234. NSLog(@"Kc7lVyaIfjdX16zwsYUHxDAiqQmT4p");
  235. NSLog(@"IDtXf4pe78M2EHzFac3CRjUxloiLQkwBOmgbYPK0");
  236. NSLog(@"kAMdoGzc3ZsIut6xN");
  237. }
  238. @end