我可以在我的iPhone应用程序中为UIToolBar提供自定义背景吗? [英] Can I give a UIToolBar a custom background in my iPhone app?

查看:77
本文介绍了我可以在我的iPhone应用程序中为UIToolBar提供自定义背景吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从图像中为UIToolBar提供自定义背景,而不是通常的有色蓝/黑淡出?

Is it possible to give a UIToolBar a custom background from an image rather than the usual tinted blue/black fade out?

我试过给视图一个背景和设置UIToolBar的不透明度,但也影响其上的任何UIBarButtons的不透明度。

I've tried giving the view a background and setting the opacity of the UIToolBar but that also affects the opacity of any UIBarButtons on it.

推荐答案

在这里回答我自己的问题!覆盖drawRect函数并创建UIToolbar的实现可以解决这个问题:)

Answering my own question here!!! Overriding the drawRect function and creating an implementation of the UIToolbar does the trick :)

    @implementation UIToolbar (CustomImage)
- (void)drawRect:(CGRect)rect {
    UIImage *image = [UIImage imageNamed: @"nm010400.png"];
    [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end

这篇关于我可以在我的iPhone应用程序中为UIToolBar提供自定义背景吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆