How to set background for uitextfield with uiimage - uiimageview

I want set background image for a UITextField with width:300 with UIImageVIew (22x43), but my UIImageVIew doesn't fit with my UITextField
So, how I can achieve this?
Thanks!

You can try :
myTextField.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"myImage.png"]];

Related

Setting the height of the UINavigationBar

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

Add programmatically UIImageView adapted for 3.5 and 4 inch

I would like to add an UIImageView to this view. Can anyone help me please?
The problem is the compatibilities for 4/3.5 inch
I tryed this
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, self.view.bounds.size.height)];
[imageView setImage:[UIImage imageNamed:#"test.png"]];
[self.view addSubview:imageView];
but the image comes out of the screen!
Thank you!
Controllers are created with a default size and resized after viewDidLoad. Depending on where you are creating your image view, it could cause you problems
Add this code:
imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
Also make sure that you don't have other views that you don't want to step over with your image, like the bottom toolbar

NILauncherView Background Colour

I'm trying to set the background image of a NILauncherViewController included with iOS NimbubKit (update of the three20 kit).
I've tried
self.launcherView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"Background.png"]];
And self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"Background.png"]];
self.launcherView.backgroundColor = [UIColor clearColor];
But neither work.
Nor does adding a UIImageView as a subview to the viewController and making the launcher view clear.
Yes the images has the correct name.
Edit
If anybody needs to know how to fix this I simply made a UIViewController and added a NILauncherView as a subview and then copied the delegate/datasource methods from the NILauncerViewController
It looks like the view property for the NILauncherViewController is not a NILauncherView. To access the NILauncherView instance just do something like:
NILauncherView *view = [controller.view.subviews objectAtIndex:0];
And you can then set the background color with:
view.backgroundColor = ...

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