how to change TTNavigator (for a web url) bottom bar color?

我只是一个虾纸丫 提交于 2019-12-11 16:03:07

问题


Here is a code i made to open a website via TTNavigator-

- (IBAction)btnTemp_Click{

    TTNavigator* navigator = [TTNavigator navigator];
    navigator.supportsShakeToReload = YES;
    navigator.persistenceMode = TTNavigatorPersistenceModeAll;

    [navigator openURLAction:[[TTURLAction actionWithURLPath:@"http://www.google.com"] applyAnimated:YES]];
}

and here i was able to manage its navigation bar items, color etc-

- (void)addSubcontroller:(UIViewController *)controller animated:(BOOL)animated transition:(UIViewAnimationTransition)transition 
{
    [self.navigationController addSubcontroller:controller animated:animated transition:transition];

    UIButton *btnBack =  [UIButton buttonWithType:UIButtonTypeCustom];
    [btnBack setImage:[UIImage imageNamed:@"navback.png"] forState:UIControlStateNormal];
    [btnBack addTarget:self action:@selector(popThisView) forControlEvents:UIControlEventTouchUpInside];
    [btnBack setFrame:CGRectMake(0, 0, 32, 32)];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btnBack];

    UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btnBack];
    [controller.navigationItem setLeftBarButtonItem:backBarButtonItem animated:YES];

    [btnBack release];
    TT_RELEASE_SAFELY(backBarButtonItem);
}

but i am not able to change color of bottom bar that has back, fwd, stop and refresh bottons.

Anybody please help. It must be done because i saw this in different colors on many applications.


回答1:


changing the colors and style of the toolbars should be done using a TTStyleSheet class.

First, you should extend the TTDefaultStyleSheet to your own class and include these functions to change the colors for both the UINavigationBar and the lower UIToolbar:

///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark TTDefaultStyleSheet


///////////////////////////////////////////////////////////////////////////////////////////////////
- (UIColor*)navigationBarTintColor {
  return RGBCOLOR(0, 60, 30);
}


///////////////////////////////////////////////////////////////////////////////////////////////////
- (UIColor*)toolbarTintColor {
  return RGBCOLOR(0, 60, 30);
}

Then you should load your style sheet class into your app delegate:

[[[TTStyleSheet setGlobalStyleSheet:[[[StyleSheet alloc] init] autorelease]];



回答2:


Thanx aporat, Here is the stuff i did-

  1. Created a new class (simply as new viewcontroller is created) with name Stylesheet.h and Stylesheet.m
  2. imported #import <Three20Style/Three20Style.h> in .h file
  3. replaced UIViewController with TTDefaultStyleSheet
  4. in .m file i put the methods navigationBarTintColor and toolbarTintColor
  5. in project delegate file first i imported Stylesheet.h then on the 1st line of - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions i placed [TTStyleSheet setGlobalStyleSheet:[[[Stylesheet alloc] init] autorelease]];

THATS IT :)



来源:https://stackoverflow.com/questions/7513849/how-to-change-ttnavigator-for-a-web-url-bottom-bar-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!