set both backIndicatorImage and backIndicatorTransitionMaskImage on backbarbutton in IOS7 didnot show particular image - ios7

I searched all the topics about backbarbutton custom, but seems failed to find answers about my problem on backbarbutton.
To keep the property called interactivePopGestureRecognizer of UINavigationController, using leftBarButton to replace backBarButton is not a valid solution. But I want to custom the backbarbutton with a image, so I use the following code in my controller ViewDidLoad:
UIBarButtonItem * btnBack = [[UIBarButtonItem alloc]init];
btnBack.title = #"";
self.navigationController.navigationBar.backIndicatorImage = [UIImage imageNamed:#"backBtn"];
self.navigationController.navigationBar.backIndicatorTransitionMaskImage = [UIImage imageNamed:#"backBtn"];
self.navigationItem.backBarButtonItem = btnBack;
when I run my project, it shows just a blue rectangle in the place where backBarButton always show.
But the original image just like the system barbutton that called reply.
However, it has a different effect, just change to the image named "Drinks" which is a black image that show a glass of juice.
after run my project the place where always show backBarButton show a blue image just like "Drinks".
what happend! How can I custom my backBarButton with the giving image named backBtn.png, is there anyone can help me? Thanks in advance! For image submit has been reject, I discrible my problem in words.

The Image has be transparent where there should be nothing to be drawn. It should be opaque where the content of the image will be drawn. At least that worked for me. The final color will be tinted by the navigationbar's tintColor anyway.

Related

Why is [UIImage imageNamed] displaying a blue rectangle instead of my image?

I'm trying to use an image for a button in the Nav Bar. It appears to be finding the image, because when I run the app, there is blue rectangle roughly the size of my image centered on where the nav bar button is supposed to be. And when I click it, the action specified for the button happens. But why is the image not displayed? Here's my code:
UIImage *image = [UIImage imageNamed:#"newTweetSmall"];
[self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStyleBordered target:self action:#selector(newTweet)];
I've also tried
UIImage *image = [UIImage imageWithContentsOfFile:#"newTweetSmall"];
But that appears to not be finding the image at all, because there is no big blue rectangle, no button in the Nav Bar at all.
Here's the structure of my project, in case that matters. I've also tried using 'Resources/newTweetSmall' for the path of the image, but that results in no image or button either.
Your code is correct. Try use a png image with alpha channel.
It certainly solve your problem.
If you want to be convinced that your file was loaded to memory check the value in the image variable. If image is loaded this variable cannot be nil.

UILabel gets hidden behind UIImageView

I have made a subclass for UITableViewCell and I am implementing Subtitle TableViewCell with a thumbnail image.
Following are the UITableViewCell contents:
The issue I am facing is when the data loads in TableViewCell, the subtitleLabel text gets hidden upto the height of the imageView. But when I select any Cell, it shows subtitleLabelText completely.
I have added the screenshot of the same for complete reference:
The UIImageView has frame = CGRectMake(0,0,40,40);
Try to give a clearColor background color for the cell title label -
cell.textLabel.backgroundColor = [UIColor clearColor];
It turns out I was using TableViewCell style as subtitle instead of custom. The style settings in subtitle was making the other labels to hide below them. What a silly miss!
In your nib or storyboard file, make sure that the label is below the image view in the list of subview components (it is in the left of the screen). The first subview in that list will be at the lowest level (behind every other subview, if they overlap).
write one line of code
Titlelabel.backgroundcolor = [UIColor ClearColor];
because your label has white background..and Titlelabel height is too large so label is colliding.
Let me know working or not!!!
Happy Coding!!!
What is the frame of Title Label? if its height is more, then also it may possible that it hides your subtitle Label
Here's a great tutorial which helped me when I was trying to do something like you want :
http://www.appcoda.com/ios-programming-customize-uitableview-storyboard/
You can adapt the size of the different components (ImageView, TitleLabel, Subtitle,...)

Transparent image overlay over below view

I am pretty new to iOS and had a question regarding subview and their behaviour. I am trying to present a modal screen to the user upon login of a basic info screenshot. It has a bunch of tet bubbles that i want to display on top of the user login page so the user can get info on what the different options on the screen mean. Its like a transparent view on top of the screen behind it giving help texts overlays. What is the best way to do this? Currently i have a class for this overlay and i push a view in that class. but i cannot get the view below to show once i display the image overlay on top. Can anyone tell me how to do this?
This code should set an image inside of an imageview and by setting UserInteractionEnabled to NO will allow you to click content beneath the image.
UIImageView *iview = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"thanks.png"]];
[iview setFrame:CGRectMake(5,5, iview.frame.size.width, iview.frame.size.height)];
[iview setUserInteractionEnabled:NO];
[self.view addSubview:iview];

NavigationBar setBackgroundImage issue

I am setting an image to navigation bar Using following lines of code:
UIImage *toolBarIMG = [UIImage imageNamed: #"header.png"];
if ([self.navigationController.navigationBar respondsToSelector:#selector(setBackgroundImage:forBarMetrics:)]) {
[self.navigationController.navigationBar setBackgroundImage:toolBarIMG forBarMetrics:0];
}
After using this the bar looks like same as i wanted to do it. But a problem is coming, there is a thin line of gray color is showing up at top left corner of the bar(please have a look on the image below).
can anybody please help in this?
I tried to do same. And all work fine. Please check your header.png image.
Sources for this example here.

Could not set tab bar image in Xcode 4.2 Programmatically

I created new tab bar project in xcode 4.2 and there is no app delegate xib file. Project has two navigation controller. I can set name of tab bar but couldn't set image. I am completely fed up with many tries. FirstViewController *firstView = [[FirstViewController alloc] initWithNibName:#"FirstViewController_iPhone" bundle:nil]
firstView.title=#"Birthdays";
firstView.tabBarItem.image=[UIImage imageNamed:#"bottomleft.png"];
SecondViewController *secondView = [[SecondViewController alloc] initWithNibName:#"SecondViewController_iPhone" bundle:nil];
secondView.title=#"Settings";
secondView.tabBarItem.image=[UIImage imageNamed:#"bottomright.png"];
UINavigationController *navController2 = [[UINavigationController alloc] initWithRootViewController:secondView];
navController2.navigationBarHidden=YES;
[viewControllers addObject:navController2];
Here you can see what sort of output I am getting.
Hard to tell from the code you posted, but you probably want to set the image on the tabBarItem of the UINavigationController (navController2), since it looks like that is what you directly add to you UITabBarController:
navController2.tabBarItem.image = [UIImage imageNamed:#"bottomright.png"];
The reason you can set the title is that navigation controllers by default automatically have the title of their current child view controller.
It looks like you successfully replaced the left image, however it has no transparent areas. Did you follow the guidelines for designing the tab icon?
http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/IconsImages/IconsImages.html
You need to use a white image on transparent background. If your background is not transparent, the whole image will just be a blue box, like the one on your left tab.
Example: To make a tab with a star on it, draw a completely white star on a transparent background. Do not use any other colors than completely white and transparent black.
You never need to do this:
[UIImage imageNamed:#"bottomleft2x.png"];
UIImage will automatically determine whether the #2x is needed or not based on the screen scale, so make it simply:
[UIImage imageNamed:#"bottomleft.png"];
Unless, of course, your resource name is actually bottomleft2x#2x.png
dude tab bar only allows white color and transparent background so if u want the picture to be like a birthday cake then draw a white birthday cake on a transparent background then add some transparent pixel in side the cake to create the looks of a cake instead of just the outline of the cake then u can set yr image to tab bar