UIView *aView = [[[NSBundle mainBundle] loadNibNamed:@"MyView" owner:self options:nil] lastObject];
[self.window addSubview:aView];

//打印数组,看你要的元素在哪里位置
NSLog(@"%@",[[NSBundle mainBundle] loadNibNamed:@"MyView" owner:self options:nil]);



UISearchBar *aSearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(10, 10, 200, 100)];

//改边框的颜色// 研究它到底有哪些视图
//方法一
[self allViews:aSearchBar index:0];
for (UIView *aView in aSearchBar.subviews)
{
if ([aView isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
[aView removeFromSuperview];
}
}

//方法二
//[[[aSearchBar subviews] objectAtIndex:0] removeFromSuperview];

[self.window addSubview:aSearchBar];


//找路径
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"plist"];
//从文件读
NSDictionary *dic = [NSDictionary dictionaryWithContentsOfFile:plistPath];

NSLog(@"%@",dic);




-(void)allViews:(UIView *)aView index:(NSInteger)index
{
NSLog(@"[-] %@",index,aView);
index++;
for (UIView *aiew in aView.subviews)
{
[self allViews:aiew index:index];
}
}

相关文章:

  • 2021-10-06
  • 2022-01-20
  • 2022-12-23
  • 2022-12-23
  • 2022-01-15
  • 2021-12-18
  • 2021-07-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案