iOS textField设置placeHold的位置,颜色和输入文字的位置,切圆角

//textField占位文字的位置
-(CGRect)placeholderRectForBounds:(CGRect)bounds{
    [super placeholderRectForBounds:bounds];
    CGRect newBounds = bounds;
    newBounds.origin.x = bounds.origin.x + leftOfView;
    
    return newBounds;
    
}

  //textField输入文字的位置 + 光标的位置
  -(CGRect)editingRectForBounds:(CGRect)bounds{
    [super editingRectForBounds:bounds];
    //光标的颜色
//    self.tintColor= [UIColor whiteColor];

    CGRect newBounds = bounds;
    newBounds.origin.x = bounds.origin.x + leftOfView;
    
    return newBounds;
    
 }



//textField输入完成后的位子
- (CGRect)textRectForBounds:(CGRect)bounds{
CGRect newBounds = bounds;
newBounds.origin.x = bounds.origin.x + leftOfView;

return newBounds;


}


  //设置placeHold的颜色+切圆角
   -(void)drawRect:(CGRect)rect{
    
    [self setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
    self.layer.borderWidth = 2;
    self.layer.borderColor = [UIColor whiteColor].CGColor;
    self.layer.cornerRadius = 5;
    self.layer.masksToBounds = YES;

}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容