iphone:界面更改时搜索栏删除背景
我已使用此代码删除搜索栏后面的背景,但是当我将视图旋转为横向或在横向视图中启动应用程序时,搜索栏周围会显示黑色容器,
for (UIView *searchSubview in mySearchBar.subviews) {
NSLog(@"Subview: %@", searchSubview);
if ([searchSubview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
//[searchSubview removeFromSuperview];
[searchSubview setAlpha:0.0];
//[searchSubview setBackgroundColor:[UIColor clearColor]];
//break;
}
}
请告诉我这一点。我尝试在 willRotate、shouldRotate 和 didRotate 方法中实现此代码,但问题仍然存在。请赐教我这一点。
问候 安基特
I have used this code to remove background behind searchbar but when I rotate the view to Landscape or launch the application in landscape view a black container is displayed around searchbar
for (UIView *searchSubview in mySearchBar.subviews) {
NSLog(@"Subview: %@", searchSubview);
if ([searchSubview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
//[searchSubview removeFromSuperview];
[searchSubview setAlpha:0.0];
//[searchSubview setBackgroundColor:[UIColor clearColor]];
//break;
}
}
Please enlighten me on this. I tried to implement this code in willRotate, shouldRotate and didRotate methods but problem persist. Please enlighten me on this.
Regards
Ankit
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
明白了....
打开界面生成器
在视图中的搜索栏属性下,模式设置为“重绘”,将其设置为scaleToFill
got it ....
open the interface builder
under searchbar attributes in view, Mode is set as 'Redraw' set it to scaleToFill