[英]UIToolbar background colour is not changing
I am using the below code to display a toolbar as a accessory view for a picker view. 我正在使用以下代码将工具栏显示为选择器视图的附件视图。 I want to customise the tool bar colour. 我要自定义工具栏颜色。 I am not sure whats wrong in this below code. 我不确定下面的代码有什么问题。 Is there a better way to achieve this 有没有更好的方法来实现这一目标
UIToolbar* state_close = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)];
state_close.translucent =NO; //.barStyle = UIBarStyleDefault;
state_close.barTintColor = [UIColor colorWithRed:0.94 green:0.94 blue:0.94 alpha:1.0];
[state_close sizeToFit];
Thanks in Advance 提前致谢
Your code is working fine. 您的代码运行正常。 try to change y
position of the state_close
like below 尝试更改state_close
y
位置,如下所示
UIToolbar *state_close = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 200, self.view.frame.size.width, 50)];
state_close.barTintColor = [UIColor blackColor];
state_close.alpha = 1.0;
[state_close sizeToFit];
[self.view addSubview:state_close];
if you want to set y = 0
then hide navigationBar. 如果要设置y = 0
则隐藏navigationBar。
[self.navigationController.navigationBar setHidden:true];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.