不過只係設定UISearchBar的Frame Size就只會把UISearchBar背景放大,
而中間的Text Field沒有放大,
於是又用到找Subview的方法,
找出Text Field來放大,
不過要放大UISearchBar內其他完件的大小,
不可以在平時的Method Call完成,
要用到Override UIView下layoutSubviews method才可以完成
@implementation UISearchBar (Override)
- (void)layoutSubviews
{
UITextField *searchField;
for(int i = 0; i < [self.subviews count]; i++)
{
if([[self.subviews objectAtIndex:i] isKindOfClass:[UITextField class]])
{
searchField = [self.subviews objectAtIndex:i];
}
}
}
@end
- (void)layoutSubviews
{
UITextField *searchField;
for(int i = 0; i < [self.subviews count]; i++)
{
if([[self.subviews objectAtIndex:i] isKindOfClass:[UITextField class]])
{
searchField = [self.subviews objectAtIndex:i];
}
}
}
@end
沒有留言:
張貼留言