1、自定义UITextView(将UITextView和UILabel想结合使用)
使用UITextView的时候需要在text显示一段提示文字,但是UITextView没有像UITextField一样的 placehoder属性对其进行设置,因此需要将将UITextView和UILabel相结合使用,自定义一个UITextView。
1、创建textView类继承于UITextView
2、在initWithFrame:(CGRect)frame中添加UILabel
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor clearColor];
// Initialization code
UILabel *placehoderLabel = [[UILabel alloc]init];
[self addSubview:placehoderLabel];
self.placehoderLabel = placehoderLabel;