Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何在ios中使搜索栏视图透明_Iphone - Fatal编程技术网

Iphone 如何在ios中使搜索栏视图透明

Iphone 如何在ios中使搜索栏视图透明,iphone,Iphone,Ha ii各位,我想用搜索栏创建一个视图,如下图所示。我看到很多应用程序都使用这个。我的应用程序中有一个搜索控制器视图,当用户点击按钮时,它会重定向到搜索视图,但我需要的是搜索视图希望处于透明模式,我们可以在搜索视图后面看到主视图。请查看我的imagelink。 提前感谢。您应该将背景颜色设置为小于1.0 alpha的颜色,以生成透明度 例如: yourSearchView.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.

Ha ii各位,我想用搜索栏创建一个视图,如下图所示。我看到很多应用程序都使用这个。我的应用程序中有一个搜索控制器视图,当用户点击按钮时,它会重定向到搜索视图,但我需要的是搜索视图希望处于透明模式,我们可以在搜索视图后面看到主视图。请查看我的imagelink。
提前感谢。

您应该将背景颜色设置为小于1.0 alpha的颜色,以生成透明度

例如:

yourSearchView.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.5];

您应该将背景颜色设置为小于1.0 alpha的颜色,以生成透明度

例如:

yourSearchView.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.5];

也可以将颜色更改为与背景相同的颜色。首先将背景图像设置为“空”图像,然后将backgroundColor设置为与视图相同的颜色

[[UISearchBar appearance] setBackgroundImage:[[UIImage alloc] init]];
[[UISearchBar appearance] setBackgroundColor:[UIColor lightGrayColor]];

考虑到此解决方案仅适用于颜色不是图像的基础视图,您还可以将颜色更改为与背景相同的颜色。首先将背景图像设置为“空”图像,然后将backgroundColor设置为与视图相同的颜色

[[UISearchBar appearance] setBackgroundImage:[[UIImage alloc] init]];
[[UISearchBar appearance] setBackgroundColor:[UIColor lightGrayColor]];

考虑到此解决方案仅适用于具有颜色而非图像的基础视图,我现在刚刚尝试了此解决方案,它在iOS7中具有很好的透明效果

self.searchbar.backgroundImage = [[UIImage alloc]init];

我刚刚尝试过这个,它在iOS7中有一个很好的透明效果

self.searchbar.backgroundImage = [[UIImage alloc]init];

我将serchviews alpha设置为0,我尝试了它,但什么也没发生。0.0意味着它完全透明,这意味着它好像不存在。将其设置为稍高一点的值以获得更好的效果。我将背景alpha设置为.90,但不显示任何内容。我希望看到此视图后面的主页。如image.self.view.backgroundColor=[UIColor colorWithRed:1.0绿色:1.0蓝色:1.0 alpha:0.5];我在viewdidload中输入此选项。我的搜索视图是uiview控制器,而不是子视图。ios中是否有执行此操作的搜索选项?链接我的图像。我将serchviews alpha设置为0,我尝试过,但没有任何效果。0.0表示它完全透明,这意味着它好像不存在。将其设置为稍高一点的值以获得更好的效果。我将背景alpha设置为.90,但不显示任何内容。我希望看到此视图后面的主页。如image.self.view.backgroundColor=[UIColor colorWithRed:1.0绿色:1.0蓝色:1.0 alpha:0.5];我在viewdidload.中输入此信息。我的搜索视图是uiview控制器,而不是子视图。ios中是否有任何搜索选项可用于此操作?链接我的图像。