Control Nav Bar Tints with PSPDF - ios

Hi I have a PSPDFViewController embedded in a UINavigationController which I then have as the left controller in a splitview controller.
I have set the colour of the navbar to match the right hand controllers nav bar however it seems PSPDFKit is changeing the colour or alpha slightly. Is there any way I can turn this off?
Here is how I'm creating the controller:
PSPDFViewController *pspdfController = [[PSPDFViewController alloc] initWithDocument:document];
UINavigationController *pspdfNavigationController = [[UINavigationController alloc] initWithRootViewController:pspdfController];
pspdfNavigationController.barTintColor = [[UIColor alloc] initWithRed:252.0/255.0 green:14.0/255.0 blue:47.0/255.0 alpha:1.0];;
pspdfNavigationController.backgroundColor = [[[UIColor alloc] initWithRed:252.0/255.0 green:14.0/255.0 blue:47.0/255.0 alpha:1.0];
pspdfNavigationController.tintColor = [UIColor whiteColor];
navbar.translucent = NO;

Lulz:
self.transparentHUD = NO;

Related

Show custom view over tab bar in iOS

I want to show custom view over tab bar. I have seen that UIAlertView shows view over UITabBar and user can't interact with tab bar when alertView is open. I tried it by showing it over the keyWindow by using the code below:
[[[UIApplication sharedApplication] keyWindow] addSubview:myViewObject];
but user can still change the tabs.
I used to do it with overlayView when I create custom controls that need to block the block whole window and show
//self refers to active UIViewController
UIView *overlay =[[UIView alloc]initWithFrame:self.view.window.rootViewController.view.bounds];
overlay.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:.4];
overlay.tag = 1001;
[overlay setUserInteractionEnabled:YES];
[self.view.window.rootViewController.view addSubview:overlay];
you can add a tap gesture to remove overlayView from superview .
try this out:
UIView *coverView = [[UIView alloc] initWithFrame:self.view.frame];
coverView.backgroundColor = [UIColor greenColor];
coverView.alpha = .3f;
UIWindow *window = [[UIApplication sharedApplication] windows].lastObject;
[window addSubview:coverView];
You can set tabBarController.tabBar.userInteractionEnabled = false on the tab bar while the custom view is shown.

How to get a new view controller instead of parent view for a 1st tab in tabbar view controller?

I struck in a problem with using tab bar controller to my view controller.
Here is my problem
I have a view controller for that i embedded a tab bar controller and i have added four tabs for it and three views are created for the other three tabs, here is my Exact problem. i don't want my 1st tab bar controller select default if i click on my 1st tab i want to show the other view it should not display my parent view where i am showing all the tabs in a parent view.
Please give me some solution how to overcome this. hope my question is clear with details.
Somehow I am able understand your problem. Without posting code sometime its very difficult to identify exact problem.
I am sharing a code with you , assume that App launch a single view controller as "Login View Controller" which is follow by "Dashboard View Controller". Now you want to show TabBar after user login with four different tabs.
Please called below method "setUpTabBar" within Dashboard View Controller ViewDidLoad.
- (void)setUpTabBar
{
UIViewController *vc1 = [[UIViewController alloc] init];
vc1.title = #"Tab1";
vc1.view.backgroundColor = [UIColor clearColor];
UINavigationController *nav1 =[[UINavigationController alloc] initWithRootViewController:vc1];
nav1 =[self setTrasparentNav:nav1];
UIViewController *vc2 = [[UIViewController alloc] init];
vc2.title = #"Tab2";
vc2.view.backgroundColor = [UIColor clearColor];
UINavigationController *nav2 =[[UINavigationController alloc] initWithRootViewController:vc2];
nav2 =[self setTrasparentNav:nav2];
UIViewController *vc3 = [[UIViewController alloc] init];
vc3.title = #"Tab3";
vc3.view.backgroundColor = [UIColor clearColor];
UINavigationController *nav3 =[[UINavigationController alloc] initWithRootViewController:vc3];
nav3 =[self setTrasparentNav:nav3];
UITabBarController *tabBar = [[UITabBarController alloc] init];
tabBar.viewControllers = #[nav1,nav2,nav3];
tabBar.selectedIndex = 0;
tabBar.view.frame = self.view.bounds;
[tabBar willMoveToParentViewController:self];
[self.view addSubview:tabBar.view];
[self addChildViewController:tabBar];
[tabBar didMoveToParentViewController:self];
}
You can change default selected tab bar using tabBar.selectedIndex = 0;
Hope this will help you.
Update (As requested by questionnaire):-
UIView *viewBottom=[[UIView alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height- 60.0, self.view.bounds.size.width, 60.0)];
viewBottom.backgroundColor =[UIColor grayColor];
UIButton *btnAdd =[UIButton buttonWithType:UIButtonTypeSystem];
btnAdd.frame=CGRectMake(10, 10, 60.0, 40.0);
[viewBottom addSubview:btnAdd];
[self.view addSubview:viewBottom];
If you are trying from code, first see how to make uitabbarcontroller in code: How to programmatically add a UITabBarController & UINavigationController in AppDelegate?

UITabBarController initially highlights all tab bar item images

I'm programmatically instantiating a UITabBarController that will manage 2 view controllers, and then setting it as the rootViewController. However when the views appear, it highlights all the tab item's images (although the text is properly highlighted). No matter what I set to the selectedIndex the images will all appear highlighted. Only when you tap on the tab bar items does it actually toggle the highlighted state on the images. What's going on here?
Code:
UITabBarController *tabController = [[UITabBarController alloc] init];
UIStoryboard *storyboard = [self storyboard];
OGVideoStreamViewController *questionsController = [storyboard instantiateViewControllerWithIdentifier:#"OGVideoStreamViewController"];
questionsController.isQuestion = YES;
OGVideoStreamViewController *answersController = [storyboard instantiateViewControllerWithIdentifier:#"OGVideoStreamViewController"];
answersController.isQuestion = NO;
OGMatchesViewController *matchesController = [[OGMatchesViewController alloc] initWithNibName:#"OGMatchesViewController" bundle:nil];
questionsController.tabBarItem = [[UITabBarItem alloc] initWithTitle:#"Questions" image:[UIImage imageNamed:#"Tab Icon - Questions"] tag:0];
answersController.tabBarItem = [[UITabBarItem alloc] initWithTitle:#"Answers" image:[UIImage imageNamed:#"Tab Icon - Answers"] tag:1];
matchesController.tabBarItem = [[UITabBarItem alloc] initWithTitle:#"Inbox" image:[UIImage imageNamed:#"Tab Icon - Inbox"] tag:2];
[tabController setViewControllers:#[questionsController, answersController, matchesController] animated:NO];
tabController.selectedViewController = questionsController;
[[UIApplication sharedApplication] keyWindow].rootViewController = tabController;
I've had the same problem and it was due to me calling:
[UIView appearance].tintColor = [UIColor colorWithRed:1.000
green:0.793
blue:0.236
alpha:1.000];
I called it in my AppDelegate, so i could change it to the following:
self.window.tintColor = [UIColor colorWithRed:1.000
green:0.793
blue:0.236
alpha:1.000];

UITabbar disappears when i push view controller

This is my app delegate:
// Initialize your five tab controllers. with each tab has its own navigation controller
HomePageView *homePageView = [[HomePageView alloc]init];
UINavigationController *nav1 = [[UINavigationController alloc]initWithRootViewController:homePageView];
[nav1.navigationBar setTitleTextAttributes:#{NSForegroundColorAttributeName : [UIColor whiteColor]}];
// Set nav Bar to be completely transparent
[nav1.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
nav1.navigationBar.shadowImage = [UIImage new];
nav1.navigationBar.translucent = YES;
//Set Title
nav1.tabBarItem.title = #"Home";
ProfileViewController *profileViewController=[[ProfileViewController alloc]init];
UINavigationController *nav2 = [[UINavigationController alloc]initWithRootViewController:profileViewController];
// Set Title
nav2.tabBarItem.title = #"Profile";
// Set nav Bar to be completely transparent
[nav2.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
nav2.navigationBar.shadowImage = [UIImage new];
nav2.navigationBar.translucent = YES;
FeedViewController *feedViewController=[[FeedViewController alloc]init];
UINavigationController *nav3 = [[UINavigationController alloc]initWithRootViewController:feedViewController];
// Set nav Bar to be completely transparent
[nav3.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
nav3.navigationBar.shadowImage = [UIImage new];
nav3.navigationBar.translucent = YES;
// Set Title
nav3.tabBarItem.title = #"Feeds";
ListeningSessionViewController *listeningSessionViewController= [[ListeningSessionViewController alloc]init];
UINavigationController *nav4 = [[UINavigationController alloc]initWithRootViewController:listeningSessionViewController];
// Set nav Bar to be completely transparent
[nav4.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
nav4.navigationBar.shadowImage = [UIImage new];
nav4.navigationBar.translucent = YES;
// set Title
nav4.tabBarItem.title = #"Mussion";
RecievedViewController *recievedViewController =[[RecievedViewController alloc]init];
UINavigationController *nav5 = [[UINavigationController alloc]initWithRootViewController:recievedViewController];
// Set nav Bar to be completely transparent
[nav5.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
nav5.navigationBar.shadowImage = [UIImage new];
nav5.navigationBar.translucent = YES;
// Set Title
nav5.tabBarItem.title = #"Recieved";
// Set selected tab bar background
UIImage *whiteBackground = [UIImage imageNamed:#"whiteBackground"];
[[UITabBar appearance] setSelectionIndicatorImage:whiteBackground];
self.tabC.tabBar.translucent = YES;
// initialize tabbarcontroller,set your viewcontrollers and change its color.
self.tabC = [[UITabBarController alloc]init];
NSArray* controllers = [NSArray arrayWithObjects: nav1,nav2,nav3,nav4,nav5, nil];
[self.tabC setViewControllers: controllers animated:NO];
//[_window addSubview:self.tabC.view];
[self.window setRootViewController:self.tabC];
// Show window
[self.window makeKeyAndVisible];
return YES;
}
When i push a view controller from one of the tabbar controllers eg HomePageView, The tabbar disappears:
SearchSongViewController *Search_MusicTableView = [[SearchSongViewController alloc] init];
Search_MusicTableView.modalTransitionStyle=UIModalTransitionStyleCrossDissolve;
[self.navigationController presentModalViewController:Search_MusicTableView animated:YES];
When i present the modal view or even push another view controller, the tabbar disappears, please why is this ? and how do i fix it, Thanks alot !

ABUnknownPersonVIewController and NavigationBarColor

I've converted an app from ios6 to ios7. The app sets the background color of the navigationbar in the following way.
[[UINavigationBar appearance] setBackgroundColor: [UIColor blueColor]];
This works fine almost everywhere. But when I use the ABUnknownPersonViewController and click "create new contact" or "add to existing contact" the header is white on white background.
Is there any way to change the navbar background color of this view?
The view is initiated like this
ABUnknownPersonViewController *picker = [[ABUnknownPersonViewController alloc] init];
picker.unknownPersonViewDelegate = self;
picker.displayedPerson = aContact;
picker.allowsAddingToAddressBook = YES;
picker.allowsActions = YES;
picker.alternateName = self.contact.fullName;
picker.title = self.contact.fullName;
[self.navigationController pushViewController:picker animated:YES];
The first view looks fine with the custom header/background color. It's when you click "add" or "create" that the header goes white.
Thanks
Johan
Try
[[UINavigationBar appearance] setBarTintColor: [UIColor blueColor]];
try like this....
ABUnknownPersonViewController *picker = [[ABUnknownPersonViewController alloc] init];
UINavigationController *newNavigationController = [[UINavigationController alloc] initWithRootViewController:picker];
// customise navigation bar of navigation controller
[self presentModalViewController:newNavigationController animated:YES];

Resources