Is possible to create this separator style effect programmatically?
I have tried adding a uiview with an image created with photoshop but doesn't work very well.
Thank you
I would simply set separatorStyle = UITableViewCellSeparatorStyleNone and in the cell view add a UIImageView subview that has the separator you want at the bottom.
You can use a combination of separatorStyle and separatorColor on the table view. You can also add views with images or simply background colours and transparency to the top / bottom of your cells.
It looks like you could just set the tableView.separatorColor = [UIColor blackColor]; and add a 1px high view to the top of your cell with a white background and alpha = 0.1.
You can achieve this by setting a background image to your view and make tablecell seperator color [UIColor clearColor]
[tableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
tableView.separatorColor = [UIColor colorWithRed:132.0f/255.0f green:132.0f/255.0f blue:131.0f/255.0f alpha:1.0f];
Related
I will like add a white view under all cell in to the UITableView, because TableView background is Clear Color, and when Cell N is one or two under these is clear.
Screenshot
I will like under these cells view color will white.
P.D. Sorry, my english is so bad. =(
You mentioned above that there are UIView elements on your UITableView background so setting he background color of it would not work, correct?
You could try setting the background color of the UITableViewCell itself, and add any of your custom views as subviews on the cell.
cell.backgroundColor = [UIColor whiteColor];
Try to set up tableview's footer view, and make it with a white background.
is it possible to make a distance between cells like that in standard UITableView? There is no options to make separator bigger. Also this distance from right and left.
you can do this by set your cell background to whatever background you want (let's say gray in this case) and in the cell, add a white uiview with left, right, and bottom margin like this:
Then go to your table view, set the separator as none
and one last step, set the background of your table view to the same gray background as your cell.
Then you don't have to do anything particularly in your code besides simply initial your table cell based on the custom nib file (i assume you want to do this anyway).
If you prefer to construct your cell in codes, you can use the same logic.
in method:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
...
cell.backgroundColor = [UIColor whiteColor];
// This will create a line of 3 pixels that will be separating the cells
UIView *separator = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,3)];
separator.backgroundColor = [UIColor darkGrayColor];
[cell.contentView addSubview: separator];
// and if you want the border do left and right add:
UIView *separatorRx = [[UIView alloc] initWithFrame:CGRectMake(318,0,2,cell.frame.size.height)];
separatorRx.backgroundColor = [UIColor darkGrayColor];
[cell.contentView addSubview: separatorRx];
UIView *separatorSx = [[UIView alloc] initWithFrame:CGRectMake(0,0,2,cell.frame.size.height)];
separatorSx.backgroundColor = [UIColor darkGrayColor];
[cell.contentView addSubview: separatorSx];
return cell;
}
One way would be to set the backgroundView of the UITableViewCell to an UIImageView containing this white box on that gray background
You have to make a subclass of UITableViewCell. In your own subclass you may make everything you dream about! So, you need to add UIView with whiteColor background and margins as subview on your custom UITableViewCell.
There is not padding option in UITableView. You can either add a UIView in your UITableViewCell which will contains all the cell subviews, and change it's frame to create a padding right in the cell.
I suggest you to use UICollectionView instead, you can easily set the space between cells using a layout. If the cell is smaller than the actual collection View, then it's automatically centered.
I want to make the scrollbar's background color clear, but I cannot find the property for it.
Just help me.
How are you coloring the cells? It looks like the contentView of the cell is being adjusted to fit the section index view. Try setting a backgroundView on the table cell with your background color.
Set UITableView background view as nil to make it transparent.
[tableView setBackgroundColor:[UIColor clearColor]];
tableView.opaque = NO;
tableView.backgroundView = nil;
Hope it helps you.
I'm customizing a Tableview ..
I want to hide the top seperator line separating on the first cell. Any ideas how to do this?
Configure TableView with no Separators, and then add custom image at the bottom of every cell which will look same as separator, so you can achieve this functionality.
UITableView has
#property(nonatomic) UITableViewCellSeparatorStyle separatorStyle;
#property(nonatomic,retain) UIColor *separatorColor;
So try this
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
or
tableView.separatorColor = [UIColor clearColor];
And after that you should customize all of your cells with your own separators.
Simply add view with autoresizing mask flexible top margin and flexible width
Don't forget to add it to cell.contentView
Actual color of separator is [UIColor grayColor];
I want to display a double bordered like following image...
The border has a dark color (magenta) and a light color (white) (not the actual colors).
I have created a custom .xib file and a custom class extending UITableViewCell for my table view cells.
self.tableView.separatorColor = [UIColor whiteColor];
Then in the custom table view class, I did this...
- (void)awakeFromNib
{
[super awakeFromNib];
UIView *cellBottom = [[UIView alloc] initWithFrame:CGRectMake(0, self.bounds.size.height, self.bounds.size.width, 1.0f)];
cellBottom.backgroundColor = [UIColor magentaColor]; //
[self addSubview:cellBottomView];
// ... other code
}
I got the following result... there seems to be some gap between backgroundColor and separatorColor.
Why is this happening? The height of UIView has been set to 1 and is positioned at the bottom of UIView as well.
If there is some better solution to this could somebody throw some light on that?
Michal Zygar is partially correct.
Make sure your -(NSInteger)tableView:(UITableView*) heightForRowAtIndexPath:(NSIndexPath*) is correctly set to the height of the view. It doesn't automatically do that for you.
The other tip I would suggest as I do it myself, is to NOT use separators. Set your separator to none, and then add in two 1px-heigh views at the top and bottom of the cell in the XIB file.
Make sure to set the autosizing for the bottom two to stick only to the bottom edge, just in case you want to change the cell's height!