简体   繁体   English

我如何在Uinavigationbar上制作uiview

[英]how can i make uiview on the Uinavigationbar

I am doing one iphone app. 我正在做一个iPhone应用程序。 In this app i want to disable the back navigationleftbarbutton . 在这个应用程序中,我想禁用后向导航leftbarbutton I have used this below code for disable the navigationleftbarbutton but it is not working. 我已经使用下面的代码禁用了navigationleftbarbutton,但是它不起作用。 Now i have created one view and i have added in uinavigationbar. 现在,我创建了一个视图,并在uinavigationbar中添加了它。 But now i want to make that view in transparent view. 但是现在我想以透明视图显示该视图。 And also how can i remove my customview(myview1) from the navigationbar. 还有如何从导航栏中删除我的customview(myview1)。 I have attached my code. 我已附上我的代码。 please some body help me to solve my issue. 请一些人帮助我解决我的问题。

Disable Code: 禁用代码:

self.navigationItem.leftBarButtonItem setEnabled:NO];

And This is my customview Code: 这是我的customview代码:

myview1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];
myview1.backgroundColor = [UIColor redColor];
button = [[UIBarButtonItem alloc]initWithCustomView:myview1];
self.navigationItem.leftBarButtonItem = button;

How can i make myview is transparent view. 我怎样才能使myview是透明视图。 And how can i remove mycustomview(myview1) from navigationbar. 以及如何从导航栏中删除mycustomview(myview1)。 Thanks in advance. 提前致谢。

you can hide navigation back button by writing code below: 您可以通过以下代码隐藏导航后退按钮:

self.navigationItem.leftBarButtonItem.hidden = YES;

and your view ie myview can be transparent by changing alpha value of the view 和您的视图,即myview可以通过更改视图的alpha值来透明

[myview setAlpha:0.3];   //alpha value ranges from 0 to 1

By settign alpha value 0.0 makes view transparent and increases transparency as u increases alpha value 通过设置Alpha值0.0使视图透明,并随着u增加Alpha值而增加透明度

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM