UIToolbar 类别drawRect:不起作用
我尝试了以下操作:
@implementation UIToolbar (Image)
-(void)drawRect:(CGRect)rect {
UIImage *img = [UIImage imageNamed: @"navigationBar.png"];
[img drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
没有任何成功,但它与 UINavigationBar+Image 的完全相同的代码完美配合。
UIToolbar 没有调用drawRect 方法,为什么呢?
I've tried the following:
@implementation UIToolbar (Image)
-(void)drawRect:(CGRect)rect {
UIImage *img = [UIImage imageNamed: @"navigationBar.png"];
[img drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
Without any success, but it works perfectly with the exact same code for UINavigationBar+Image.
the drawRect method is not getting called for UIToolbar, why is that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了解决方案
来源:http://atastypixel.com/blog/making- uitoolbar-and-uinavigationbars-background-totally-transparent/
所以我实现了
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
:I found a solution
Source: http://atastypixel.com/blog/making-uitoolbar-and-uinavigationbars-background-totally-transparent/
So I implemented
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
instead: