Setting the height of the UINavigationBar - xcode

I have set a UINavigationBar background image to an image with a height of 68px as opposed to the default 44px. Now the image is shown fine, but the content in the UINavigationController is overlapped in the first (68-44)px = 12px by the header image.
How do I fix this? I have tried setting the frame of the UINavigationBar without luck.
Thanks, Caspar.
This is my code (AppDelegate.m):
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.frontTableViewController];
UINavigationBar *navBar = navigationController.navigationBar;
[navBar setBackgroundImage:[UIImage imageNamed:#"header"] forBarMetrics:UIBarMetricsDefault];
self.window.rootViewController = navigationController;

try setting the image for the navigationbar this way
self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"myNavBarImage.png"]];
or have a look at this Answer

Related

Xcode UIImageView in UIScrollView IOS

can you help me? I would like add background image with scrolling, because my background image is too high. How can I do this? I add UIScrollView and into I add UIImageView but it doesnt scroll.
Thank you for replies.
Here is working code:
- (void)viewDidLoad
{
[super viewDidLoad];
//create scrollView and set the frame to the size you want.
//In this example the scrollView frame is the whole ViewController size
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[scrollView setBackgroundColor:[UIColor clearColor]];
//create a UIImage,set the imageName to your image name
UIImage *image = [UIImage imageNamed:#"YourImageName.png"];
//create UIImageView and set imageView size to you image height
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, image.size.height)];
[imageView setImage:image];
//add ImageView to your scrollView
[scrollView addSubview:imageView];
//set content size of you scrollView to the imageView height
[scrollView setContentSize:CGSizeMake(self.view.frame.size.width, imageView.frame.size.height)];
[self.view addSubview:scrollView];
}
If you want the scroll view to scroll, set the content size to be bigger than the scroll view frame.

custom navigation bar in xcode is cutting the image

/*enter code here */ UIImage *image = [UIImage imageNamed: #"top-bar.png"];
UIImageView *imageview = [[UIImageView alloc] initWithImage: image];
// set the text view to the image view
self.navigationItem.titleView = imageview;
I am using this code for custom navigation bar but the image is cutting out . Although the image width is same as device width.
Any idea, how to solve this.
The titleView property only covers title area of the navigation not the complete navigation-bar.

Add a label to UINavigationBar in addition to the titleView

I'm using a UINavigationController to push my views. I want to add a UILabel above the title in the UINavigationBar of the root view controller.
When I use the following code, the label appears, but under the UINavigationBar:
[self.view addSubview:newLabel];
Is there a way to add the label to the UINavigationBar or to the UIView so that it appears above the navigation bar?
I know I can create a new UINavigationBar and build it with multiple controls like this:
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
navBar.barStyle = UIBarStyleBlack;
navBar.translucent = YES;
[self.view addSubview:navBar];
[navBar release];
UILabel *navLabel = [[UILabel alloc] initWithFrame:CGRectMake(20,8,280,30)];
navLabel.text = #"My Text";
[navBar addSubview:navLabel];
[navLabel release];
However, doesn't that defeat the purpose of using the navigation controller?
You can refer this site, may be it help you in sorting your problem
http://iphonesdevsdk.blogspot.com/2011/04/uinavigationbar.html

iphone: customise cell.accessoryType

hi am doing an iphone twitter app with json and i am wondering if it is possible to set the
cell.accessoryType to a image in UITableView? or possible move the image to the right hand side...any clues?
Sure. Just use the accessoryView property of UITableViewCell and assign a UIImageView:
UIImage *image = [UIImage imageNamed:#"fileNameOfYourImage.jpg"]; //or wherever you take your image from
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
cell.accessoryView = imageView;
[imageView release];
No need to use imageview, just provide this for simple arrow.
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;

change uibarbuttonitem background using image

i have an uibarbuttonitem, but i was initialize it using initwithcustomview. I want to change it backgrounds using an image, but i dont know how to do. I was using setBackground method, like this
NSArray *segmentText = [segmentTextMutable copy];
UIImage *image = [[[UIImage alloc] init] autorelease];
image = [UIImage imageNamed:#"bunga.jpg"];
_docSegmentedControl = [[UISegmentedControl alloc] initWithItems:segmentText];
_docSegmentedControl.autoresizingMask = UIViewAutoresizingFlexibleHeight;
_docSegmentedControl.segmentedControlStyle = UISegmentedControlStyleBezeled;
[_docSegmentedControl addTarget:self action:#selector(docSegmentAction:) forControlEvents:UIControlEventValueChanged];
[_docSegmentedControl setBackgroundColor:[UIColor colorWithPatternImage:image]];
but the uibarbuttonitem still not show the image, it's just change the segmented control background, not the barbutton.
Can somebody help me?
Perhaps you want to change the tint-color (#property(nonatomic, retain) UIColor *tintColor) because UISegmentedControl has no background-color (just because it inherits it from UIView does not mean it uses it though)

Resources