NILauncherView Background Colour - three20

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 = ...

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

Disable Subview of UITableview from Scrolling

(xCode 4.3.2, ARC, Storyboard) I have a Master/Detail project and the MasterViewController is a UITableViewController, as usual. It has a navigation bar at the top and a toolbar at the bottom. I've created a custom subview that I load programmatically in viewDidLoad.
It loads fine, and is on top just like I want, but when the user scrolls the tableview, the subview scrolls too. I need the subview to "stick" to the bottom.
Here is the code I used to add the subview:
CGRect totalFrame = CGRectMake(0, 314, 320, 58);
UIView *totalBG = [[UIView alloc] initWithFrame:totalFrame];
totalBG.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"totalBG.png"]];
[self.view addSubview:totalBG];
CGRect totalLabelFrame = CGRectMake(12, 12, 80, 40);
totalLabelBG = [[UILabel alloc] initWithFrame:totalLabelFrame];
totalLabelBG.backgroundColor = [UIColor clearColor];
totalLabelBG.text = #"Total:";
[totalLabelBG setFont:[UIFont boldSystemFontOfSize:22]];
totalLabelBG.userInteractionEnabled = NO;
totalLabelBG.textColor = [UIColor whiteColor];
totalLabelBG.shadowColor = [UIColor blackColor];
totalLabelBG.shadowOffset = CGSizeMake(0, 1);
[totalBG addSubview:totalLabelBG];
I tried setting userInteractionEnabled to NO in viewDidLoad and detecting a
touch, and setting the totalLabelBG.center property, and neither worked.
I've also read through a lot of threads on disabling scrolling for webviews, but found nothing relevant.
I found another SOF question with a response that may or may not work, but the user did not explain the answer. "The trick is to adjust the frame of the "non-scrollable" subview inside -layoutSubviews."
I achieved the desired result by adding the subview to the UINavigationController container like this:
[self.navigationController.view addSubview:totalBG];
Like in the answer above. Just add that particular subview to any subview outside on the UIScrollView instance. If its not suppose to scroll then it doesn't make sense to put it inside the scroll view to begin with. Instead make the scroll view only take up the height up to the top of the totals subview

How to create NSTextField programmatically?

I want to create NSTextField programmatically. I am new to Mac App Development.
Can anyone help me in this ?
Update :
I tried this code
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSView *myView = [[NSView alloc] init];
NSRect frameRect = NSMakeRect(20,20,100,140);
NSTextField *myTextField = [[NSTextField alloc] initWithFrame:frameRect];
[myView addSubview:myTextField];
}
This does nothing. Please correct me if i'm wrong anywhere.
Thank you.
Creating UI elements programmatically is very simple in Cocoa.
It involves two steps:
Create the view and set a frame to it.
Add it as a subview to any super view.
Following snippet will you help you understand better.
NSRect frameRect = NSMakeRect(20,20,40,40); // This will change based on the size you need
NSTextField *myTextField = [[NSTextField alloc] initWithFrame:frameRect];
[myView addSubview:myTextField];
It looks like you're creating an NSTextField OK, but you're not adding it to anywhere visible in the view hierarchy. Your app probably contains one or more NSWindow instances; if you want a view to appear in a particular window, you should add it as a subview of that window's content view.

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