I have been looking all over the web for this issue, but I have not been able to find anything helpful. Any help or direction will be highly appreciated.
I have a UICollectionView with a header (that contains simple text/title) and then a grid. What I want is to have the header background as clear and rest of the area below header should have white background.
Cell background will not work because the actual space that is required to be white is the visible area on top, left, bottom and right of the cells.
Thanking in advance for your help.
EDIT: You can think of it as a UICollectionView is added as a subview to another UIView. The headerView (UICollectionReusableView) should have clear background so that we can see the parent UIView. where as the rest of the collectionView (Cell area and space around them) should have white background. It will look like as if the title is floating.
for me I used UICollectionReusableView for my HeaderView of my UICollectionViewController. Setting the background color with
self.backgroundColor = [UIColor clearColor];
did the trick.
Related
I have set my tableView's background color, and I want there is space(10px) around each cell show that color.
e.g.(ignore the red line)
What I am doing now is make the cell embed a smaller view, and set the cell's background to be clear. But it is annoying to create such embed view again and again.
So, I am seeking for a better solution, I believe it would be good if i can increase separator's height. But the old answers did not solve my problem.
(How to increase the UITableView separator height?)
EDIT:
However, if I add my own separator in cell. I may not able to set the cell having round corner
Set the tableView's separatorStyle to .None.
Create a custom UITableViewCell subclass.
In the storyboard (or xib if you created one for the custom cell), add a subview that's inset the amount that you want padded on all four sides.
If you want rounded views, do that on the custom cell's subview (e.g. subview.layer.cornerRadius = 10.0, subview.layer.masksToBounds = true).
Set the custom cell's ContentView to have a clear background.
Set the table view's background to that lovely shade of blue.
Set the cell subview's background color to white.
You don't have to use the cell repeatedly in InterfaceBuilder. Just give the cell an ID, and in your implementation of the table view's data source, dequeue a cell instance using that ID and set the values of the labels inside it.
Have you thought of just making the cell height taller and putting your own separator on the bottom of your custom cells? Nice table layout by the way.
I've been futzing around trying to get some padding between the bottom of my subview and its container UITableViewCell. I have an xib file, but changes to that don't seem to affect my actual ui (i've had to pragmatically change the tableviewcell height, for example).
I've also tried a few examples on SO regarding adjusting the center value of the subview, but no cigar.
Any ideas?
Thanks in Advance.
So, I decided to just move the individual elements within the inner cell which is less reusable than just adjusting the whole cell, but.. It will do for now!
Cheers.
So this problem is pretty weird and a little difficult to describe. Essentially I have a UITableView where each cell has an image, and a UIView covering part of the image. The UIView has it's background colour set to about 30% transparent white, giving it the appearance of washing out the image beneath. There's also some labels and such on it. All these views are added to a single parent container view, which is finally added to the cell's contentView. This all works fine - until I try to select the cell. For some reason, whenever the cell is highlighted, the backgroundColor property on each and every one of those views is set to clear, until the cell is unhighlighted (at which point the old colour returns).
Can anyone explain why this happens, and more important if there's a way to fix it? At most I could create a single pixel image of white, turn the UIView into a UIImageView, and set it's image to that pixel - but that's inelegant at best. Any suggestions?
When you select the cell, the implementation of setSelected:animated: is called and set the background color of all the views included in this cell to transparent.
Simply, you can just disable the selection of the cell by setting its selectionStyle to None:
cell.selectionStyle = UITableViewCellSelectionStyleNone;
Or, if you want to use the result of selection, you can override the setSelected:animated: method and reset the background color of your UIView
I have a UITableView on a UIView. This UIView is in a UICollectionViewCell which means that I can do the action you can see in the image. A new UICollectionViewCell is coming on from the right. As a new cell comes onto the visible rect it is slightly resized you can see that the right one is slightly smaller.
While this new cell is "sliding on" the table view has some black lines that show through. It is not the actual separator lines as you can clearly see them, further turning them off or making them the same colour as the cell does not change things.
So can anyone tell me what these black lines are and if I can either directly get rid of them or cover them over somehow.
I believe that the lines are cell separators. You could set the separatorStyle property to UITableViewCellSeparatorStyleNone.
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
On the app Foodspotting, you have a scrolling view that has two elements:
1) An image.
2) Some information below it.
Like this:
When you start scrolling down, the behaviour is not natural of a UITableView, or at least I am not understanding it. The below view start's going up and overlapping the UIImageView above it:
And finally:
What I have tried:
1) Using the first four cells without content and invisible and finally an UIImageView as subView of the UITableView
2) The same as above but using the UIImageView as subView of the root view and below the UITableView.
3) Mixing the UITableView and a UIScrollView with an UIImageView inside the UIScrollView.
So my question, how was this achieved?
Edit 1.0
If someone want to try, you can check the project here.
Looks to me like a UIViewController with a UIImageView on the bottom.
Then a UITableView on top of that (grouped table view) with a transparent background.
The header height is then set to almost the height of the entire view. With a button (or whatever that is) near the bottom of the header.
You could access the scrollView:didScroll to adjust the position of the UIImageView in the background (it looks like the center point of the image is always half way down the visible part of the header.
bgImageView.center = CGPointMake(0, (bgImageView.frame.size.height - scrollView.offset.y) * 0.5);
or something like that.
Obviously the image view would not move any further down than the top so you'd have to catch that somehow.
Looks like an image view is the background view of the table (so it won't scroll), a large transparent view as the table header (possibly with that first button in it, or that could be a transparent cell) then opaque cells for the remaining content.
And that risotto is far too wet. 0 stars, more like rice soup.