从UITextField类继承一个类

.h文件

1 @interface CustomTextField : UITextField
2 
3 @end

 

.m文件

 1 #import "CustomTextField.h"
 2 
 3 @implementation CustomTextField
 4 
 5 - (CGRect)textRectForBounds:(CGRect)bounds{
 6     return CGRectInset(bounds, 5, 0);
 7 }
 8 
 9 - (CGRect)editingRectForBounds:(CGRect)bounds{
10     return CGRectInset(bounds, 5, 0);    
11 }
12 
13 - (void)drawRect:(CGRect)rect{
14     //[super drawRect:rect];
15     UIImage *bg = [[UIImage imageNamed:@"text_field_teal.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(15, 5, 15, 5)];
16     [bg drawInRect:[self bounds]];
17 }
18 
19 @end

 

相关文章:

  • 2022-12-23
  • 2021-08-29
  • 2022-12-23
  • 2022-01-27
  • 2021-08-02
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-14
  • 2022-12-23
  • 2021-12-21
相关资源
相似解决方案