2019-06-29

2019-06-29  本文已影响0人  奋斗的遗忘人

完美解决TextView的占位文字(利用KVC修改对象的私有属性)

 UILabel *placeHolderLabel = [[UILabel alloc] init];
    placeHolderLabel.text = @"Please tell us in detail why you want to refund the goods.";
    placeHolderLabel.numberOfLines = 0;
//    placeHolderLabel.backgroundColor = [UIColor redColor];
    placeHolderLabel.font = [UIFont systemFontOfSize:14];
    placeHolderLabel.textColor = [UIColor lightGrayColor];
    [placeHolderLabel sizeToFit];
    [self.contentTextView addSubview:placeHolderLabel];
    //kvc赋值(这是一个完美的方法)
    [self.contentTextView setValue:placeHolderLabel forKey:@"_placeholderLabel"];

修改TextField的光标的其实位置

  //修改光标的起始位置
   self.currentPassworTF.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, 0)] ;
   self.currentPassworTF.leftViewMode = UITextFieldViewModeAlways;
上一篇 下一篇

猜你喜欢

热点阅读