I am wondering how I can set the backgroundColor of my UIView to the scroll View Textured background color.
this is the way I plan on implementing it but im just not sure what the patternImage is called .
jumpBarContainer.backgroundColor = [UIColor colorWithPatternImage:????]
any help would be greatly appreciated.
jumpBarContainer.backgroundColor = [UIColor scrollViewTexturedBackgroundColor];
[UIColor scrollViewTexturedBackgroundColor]
is what you need to use.
Related
Hi can any one tell me how can i remove the black edges at the corner of mY UITableView GroupStyle. i have create a custom view for my UITableView Cell. i have tried this code but it work in IOS 5 and not work in IOS 4.0 what the problem is that i have tried all the proposed solution Please Help! self.tableView = [UIColor ClearColor]; in viewDidLoad work in Ios 5 not in IOS 4 what problem is that . when i run this on simulator 5.1 then it not show black edges but show black edges in simultor 4.3. Please Help
To remove the borders from the cells:
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
In code:
tableView.backgroundView = nil;
And if you putting table through xib :
Make SeparatorStyle = Single Line
thank you all for helping me.
Actually this work for me
self.tableView backgroundcolor = [UIColor ClearColor];
but i was missing the IBOutlet of tableView so i connect the property of tableview with interface Builder it work for me!
I replaced the tableView's backgroundView with a new view.
I then relied on the tableView's backgroundColor property to set the color I wanted:
self.tableView.backgroundView = [[[UIView alloc] init] autorelease];
self.tableView.backgroundColor = [UIColor whiteColor];
I have an image prepared with transparency, like this:
With two UIviews, I configure the background colors as so:
self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
self.dashedView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"red_square.png"]];
I expect the red square to be repeated over the UIView with transparency preserved, but it's been filled by a solid color like this:
I don't understand why. Is there a simple way to draw a tiled image with transparency? Or do I need to look at drawing Core Graphics patterns?
Pattern images should be keeping the transparency just fine.
Try [self.dashedView setOpaque:NO]
all you have to do is set opaque to NO after setting the colorWithPatternImage.
self.dashedView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"red_square.png"]];
self.dashedView.opaque = NO;
Yar, thanks for the feedback.
I found this only happens on iOS 4.3.x but not on iOS 5.0.x. So on 4.3.x I had to do what Yar id and set opaque to NO, then set background image, then set to YES.
UIButton* cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
cancelButton.opaque = YES; // fix for strange issue in 4.x, need to set YES, set bg color image, then set back to NO
cancelButton.backgroundColor = [UIColor colorWithPatternImage: cancelImage];
cancelButton.opaque = NO;
I need to set some background image for my view. How can I do this?
view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"background.png"]];
The simpliest way is to add an imageView to your view with appropriate background image. Just make sure that it is the lowest by z-order subview by adding it first or by calling [view sendSubviewToBack:backGroundView];
As an alternative you can set your image as a contents for your view's layer:
#import <QuartzCore/QuartzCore.h>
...
view.layer.contents = yourImage.CGImage;
I'm setting the background color of my UIView (which is within a UIViewController) as follows:
myView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"myTransparentBG.png"]];
I've even tried messing with [myView setOpaque:NO]; but the image doesn't appear transparent. It has a black background to it. Am I abel to fix this programmatically? Otherwise, how are we supposed to set a transparent background to our view?
This seems like a question that should have been asked before, but I couldn't find an answer.
When using a transparent pattern, after setting the backgroundColor property, you need to set opaque property to NO on both view and its layer. Here's a sample:
UIView* paperView = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,700)];
paperView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"paper.png"]];
[paperView.layer setOpaque:NO];
paperView.opaque = NO;
I haven't ever actually done this, but here's what I'd try.
Set the UIView's .backgroundColor to [UIColor clearColor]. Then put a UIImageView containing your PNG as the "lowest" item on the UIView's stack of subviews. Make sure the UIImageView's background color is also clear.
Use this: myView.backgroundColor = [UIColor clearColor];
This will set it to a transparent background.
I've seen some iPhone applications that use a custom image as the background for a grouped UITableView, instead of the standard gray lines.
How is this achieved?
Here's what worked for me (and fairly simple once I figured it out ;)
1) Add a view in your app delegate and make it a subview of the window:
UIView *bgView = [[UIView alloc]initWithFrame:window.frame];
bgView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"screenBG.png"]];
[window addSubview:bgView];
[bgView release];
2) On each view controller .m file, under ViewDidLoad, set background color of that particular view to transparent (so the other bgView created above will show through):
self.view.backgroundColor = [UIColor clearColor];
And in my case, the view controller in step 2 was a tableviewcontroller. Looks great.
And BTW, doing the following in each view controller did NOT work well:
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"screenBG.png"]];
So follow steps 1 and 2 above.
Hope this helps out,
Tbone
Try this
- (void) viewDidLoad {
[super viewDidLoad];
self.tableView.backgroundColor = [UIColor clearColor];
self.view.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:#"wallpaper.png"]];
self.tableView.opaque = NO;
}
In another project (developed using 2.2.1) I did this by setting my UITableView's background opacity to 0%, and then simply layering a UIImageView behind it using Interface Builder. This allowed me to have a fixed background regardless of the table state. You can also set the background of the UITableView to be an image instead, but then the background scrolls with the table. (I don't have the code handy at the moment, but I got the tip a while back on the Apple developer forums).
Note that this can cause some performance issues. Apple discourages using transparency whenever possible because the GPUs on the pre-3GS models aren't particularly beefy.
You can use the +[UIColor colorWithPatternImage:(UIImage)] method like so:
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"Background.png"]];
the problem with colorWithPatternImage: is that you need to use "patterned" images, otherwise your image will be tiled randomly
this link has a simple solution, if you want all your views to have the same background
http://howtomakeiphoneapps.com/2009/03/how-to-add-a-nice-background-image-to-your-grouped-table-view/
self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"SortByCategory_320x480.png"]];
self.tableView.separatorColor = [UIColor clearColor];
self.tableView.backgroundColor = [UIColor clearColor];
Hope this will help. It won't display hideous translucent background behind the cells especially in case of Grouped UITableView.