Styling separator of table view cells - ios

I have the following code in my willDisplayCell function
//bottom border
UIView* bottomBorderView = [[UIView alloc] initWithFrame:CGRectMake(0, cell.frame.size.height-1, cell.frame.size.width, 1)];/// change size as you need.
bottomBorderView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"dot.png"]];// you can also put image here
[cell.contentView addSubview:bottomBorderView];
It worked just fine in iOS7, but ever since I updated Xcode and started testing the app on iOS8 the borders have been displaying incorrectly. I cant figure out what changed that is causing the issue. The problem seems to get worse the more you scroll.

Related

UIRefreshControl wrong size on UITableView/UICollectionView

I'm trying to use a UIRefreshControl that has a colored background. I found that the UIRefreshControl's size is actually inaccurate when you use it on a UITableView or UICollectionView.
To highlight this, I set a background color to the UIRefreshControl and to the cells.
How do I fix this gap? This is driving me nuts. It looks very unprofessional and seems to be hidden with people using white UIRefreshControls.
Here the UIRefreshControl is flush against the UITableView
Now we start to see a little bit of a gap
Now the gap is much bigger
To reproduce this, simply have a plain Storyboard with a UITableViewController.
Relevant code:
self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl setBackgroundColor:[UIColor redColor]];
self.refreshControl.tintColor = [UIColor clearColor];
Repo with code:
https://github.com/Lyricalpanda/RefreshControl/tree/master/RefreshControl
Well, in your sample app, I can make that white gap go away by saying:
self.view.backgroundColor = [UIColor redColor];
But if that's acceptable you don't need to set the refresh control's background color at all just the view's.

InAppSettingsKit Strange cell content allignment after iOS9 update

I use InAppSettingsKit in my projects. And everything was good befor iOS 9 update. I hadn't this problem in iOS 8. It still work but now cell alignment looks strange. Now cell content has strange offset from the left and right sides.
I've downloaded the sample project and found interesting moment. And edited one cell configuration cell. So in fact cell is green, contentView is red.
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:kIASKPSToggleSwitchSpecifier];
cell.accessoryView = [[IASKSwitch alloc] initWithFrame:CGRectMake(0, 0, 79, 27)];
cell.contentView.autoresizingMask |= UIViewAutoresizingFlexibleWidth;
cell.contentView.backgroundColor = [UIColor redColor];
cell.backgroundColor = [UIColor greenColor];
[((IASKSwitch*)cell.accessoryView) addTarget:self action:#selector(toggledValue:) forControlEvents:UIControlEventValueChanged];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
When controller configuring form xib it works good.
Configuration:
Result:
So... Normal left and right offsets. Have no any problems. But! after programmatically push.
- (IBAction)showSettingsPush:(id)sender {
[self.navigationController pushViewController:[[IASKAppSettingsViewController alloc] init] animated:YES];
}
I have this strange result(The same problem in my app):
InAppSettingsKit Source
P.S. Any way thanks for your attention. I would be grateful for any help.
This is actually an iOS 9 feature (cellLayoutMarginsFollowReadableWidth) that limits cells to a good readable width. And IMO your second screenshot looks better. (On a sidenote: in your first shot the section titles are incorrectly aligned - not sure what's the reason for this, works fine in the sample app here).
There's a pull request that allows you to disable this property (default is YES): https://github.com/futuretap/InAppSettingsKit/pull/317
I'll look into potential side effects and might merge this at some time.

UITableView background has weird behavior

I have a UIViewController with a UITableView, which is showed from the root view controller. In the simulator everything is working fine, but when testing the app on a real device running iOS7, the background of the UITableView is the same image of the root view. Setting both backgroundColor and backgroundView has no effect. I have also tried to set tableView.opaque = NO and setting the background of the cells, but still not results.
Any ideas on how to fix this behaviour?
Try with this piece of code:
contentTable = [[UITableView alloc] initWithFrame:tableFrame style:UITableViewStylePlain];
contentTable.delegate = self;
contentTable.dataSource = self;
[contentTable setBackgroundView:nil];
[contentTable setBackgroundColor:[UIColor blueColor]]; // i.e. Bluecolor as backgrounf
This will return a table with a blue background.

UITableView FooterView background color to clear color doesnt work

i try to set the UITableView Footerview backgroundcolor to clearColor but it stays white, any
other color works fine, any ideas?
_footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, _incredientsTable.frame.size.width, 60)];
[_footerView setBackgroundColor:[UIColor clearColor]];
Thanks.
Ask yourself these questions:
What do you expect to see through the footer view? Is it the table's background? The underlying view controller's views? In the latter case there are more views between your and the object that you want to be visible under the footer view. That is at least the UITable itself and probably the background of self.view (which in most cases but not all is the table)
You need to set background color of table view in this case.
tblView.backgroundColor = [UIColor clearColor];

table background clear - objective c - cocoa

Hi I want to display my table view without any background color so I used the following code to clear it
[uiTableView setBackgroundColor:[UIColor clearColor]];
This worked fine in the new iPad and also other generation iPads except it failed to work in iPad version one. The table shows with the background gray color. Is this something to do with iOS 5 ? Can anyone let me know if we can clear the background color in first version iPads.
I have noticed the same thing under iOS 5+. Try this:
[uiTableView setBackgroundColor:[UIColor clearColor]];
[uiTableView setBackgroundView:nil];
Should work as intended.
EDIT: If you're using the default cells, they cover the UITableView, so changing the UITableView's background color and view doesn't do anything. Try this in your tableView:cellForRowAtIndexPath: method:
cellName.backgroundColor = [UIColor clearColor];
cellName.backgroundView = nil;
As tableview has one more view as its background. You can set the backgroundColor in two ways.
i) Set the background color for the tableview and set the backgroundView to nil.
[uiTableView setBackgroundColor:[UIColor clearColor]];
[uiTableView setBackgroundView:nil];
ii) Set the backgroundColor for the tableView backgroundView.
UIColor *backgroundColor = [UIColor clearColor];
uiTableView.backgroundView = [[UIView alloc] initWithFrame:self.tableView.bounds];
uiTableView.backgroundView.backgroundColor = backgroundColor;

Resources