UItextfield
userInfoText = [[CustomTextFieldalloc]init];
userInfoText.frame = CGRectMake(34, 127, 252, 35);
userInfoText.placeholder = @"请输入您的个人信息";
userInfoText.font = [UIFontsystemFontOfSize:15];
userInfoText.layer.masksToBounds=YES;
//设置边框的颜色
userInfoText.layer.borderColor = GIFT_SEPARATELINE_CGCOLOR;
userInfoText.layer.borderWidth =1.0f;
userInfoText.contentVerticalAlignment =UIControlContentVerticalAlignmentCenter;
userInfoText.delegate = self;
//设置显示键盘的类型以及return键的外观
userInfoText.returnKeyType =UIReturnKeyDone;
userInfoText.keyboardType =UIKeyboardTypeNumberPad;
[self.exhangeScrollViewaddSubview:userInfoText];
自定义textfield显示文字以及光标显示起始位置
#import "CustomTextField.h"
@implementation CustomTextField
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
- (CGRect)textRectForBounds:(CGRect)bounds {
return CGRectInset(bounds, 20, 0);
}
- (CGRect)editingRectForBounds:(CGRect)bounds {
return CGRectInset(bounds, 20, 0);
}