iOS应用开发中使UITextField实现placeholder属性的方法

2020-01-15 13:33:34刘景俊

 

GGPlaceholderTextView *textView = [[GGPlaceholderTextView alloc] initWithFrame:CGRectMake(0, 64, SCREEN.width , 200)];
textView.backgroundColor = [UIColor whiteColor];
textView.placeholder = @"jb51.net";
[self.view addSubview:textView];

 


经过封装后的GGPlaceholderTextView,使用起来是不是跟UITextField非常相似。当然,我封装的比较简单,github上也有一些朋友封装带placeholder属性的UITextView。比如:TextViewPlaceholder。感兴趣的童鞋可以去试用一下。

注:相关教程知识阅读请移步到IOS开发频道。