IOS-UITextField重写文字区域to left、center、right、up、down in TextField

重写UITextField方法:
-(CGRect)textRectForBounds:(CGRect)bounds

效果如图:-------->


-(CGRect)editingRectForBounds:(CGRect)bounds

@interface
MYTextField:UITextField

@end


@implementationMYTextField

-(CGRect)textRectForBounds:(CGRect)bounds {
   
int margin =10;
   
CGRect inset =CGRectMake(bounds.origin.x + margin, bounds.origin.y, bounds.size.width - margin, bounds.size.height);
   
return inset;
}

-(CGRect)editingRectForBounds:(CGRect)bounds {
   
int margin =10;
   
CGRect inset =CGRectMake(bounds.origin.x + margin, bounds.origin.y, bounds.size.width - margin, bounds.size.height);
   
return inset;
}

@end
posted on 2012-07-03 09:31  tx天翔  阅读(1406)  评论(0编辑  收藏  举报