- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
self.tintColor = [UIColor whiteColor];
}
return self;
}
-(void) layoutSubviews
{
UITextField *searchField;
NSUInteger numViews = [self.subviews count];
for(int i = 0; i < numViews; i++) {
if([[self.subviews objectAtIndex:i] isKindOfClass:[UITextField class]]) { //conform?
searchField = [self.subviews objectAtIndex:i];
}
}
if(!(searchField == nil)) {
searchField.placeholder = @"输入要查找的艺人的名字";
[searchField setBorderStyle:UITextBorderStyleRoundedRect];
[searchField setBackgroundColor:[UIColor whiteColor]];
//自己的搜索图标
NSString *path = [[NSBundle mainBundle] pathForResource:@"GUI_search" ofType:@"png"];
UIImage *image = [UIImage imageWithContentsOfFile:path];
UIImageView *iView = [[UIImageView alloc] initWithImage:image];
[iView setFrame:CGRectMake(0.0, 0.0, 30.0, 30.0)];
searchField.leftView = iView;
}
[super layoutSubviews];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
@end