开发者

Add a background image to TTWebController's UIToolbar

I would like to add a nice background image to the UIToolbar of a subclass of Three20's TTWebController.

Since I don't mind all UIToolbars of my app sharing the same back开发者_JAVA技巧ground, I tried using UIColor colorWithPatternImage in my style sheet and that doesn't seem to work (toolbar end up solid black).

I've also tried doing something like this:

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

with little success.. I certainely don't want to copy and paste the entire TTWebController code just to make my own class out of it since I actually don't modify anything else, but I don't really see anything else I can do. Anyone have a suggestion?


Ok, found my way like this: I subclassed the TTWebController to subclass the loadView: method.

-(void)loadView{
[super loadView];
 [_toolbar insertSubview:[[[UIImageView alloc] initWithImage:[UIImage imageNamed: kBackgroundImage]] autorelease] atIndex:0];

}

Better than nothing. Not extremely handy if they decide to change anything about the protected attribute _toolbar though...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜