I want to achieve next things in my UITableViewController:
Have transparent table Header View with fixed height.
Have solid colored Table Footer View (for example with white color).
To achieve this I need to set my TableViews’ background to clearColor. But once I set whole tableView backgroundColor to clearColor my header and footer also gets transparent, and I don’t need footerView as transparent.
You may say: use TableView inside UIViewController, but I can’t do it, because I’m using static cells with dynamic height, and static TableView will never conform UITableViewDataSource protocol (only way to change cell heights dynamically), because I haven’t got methods like tableView(cellForRowAtIndexPath).
Try setting the tableFooterView property:
tableView.tableFooterView = UIView()
Hope this helps!
Related
I am having a custom cell where I add a UIImageView as a subview for the cell's contentView.
This UIImageView is placed outside the boundaries of the cell which results with image appearing underneath the table view separator as follows:
I wish that the image will override the table view separator as follows:
How can I do that?
That you can't do with tablview's separator. You first need to hide tableview's separator (i.e set seperator to none from IB or you can set to none by code also).
Take UIView with same width of separator and with height = 1 or 2 if want thick separator. And put it to the end of contentview of cell.
The easiest way is to default separators in tableview and add a simple uiview line as a subview to your cell below your image view.
How can I customize my UITableViewCell to get this appearance ?
I don't want to use a custom UIView for my UITableViewCell?
You will need to create a UITableViewCell subclass for this.
The spacing between the cells isn't really spacing. It is fake.
Each cell has a shadow image that has some of the background around it.
You'll need to add a UIView that then has a shadow around it and is inset from the edge of the actual cell. Then add the contents of the cell to that.
Add this inside UITableViewCell subclass :
override func layoutSubviews() {
contentView.frame = UIEdgeInsetsInsetRect(contentView.frame, UIEdgeInsetsMake(10, 10, 10, 10))
}
Create a subclass of UITableViewCell.
Add a View and place required UIElements to its contentView.
Make UIEgdeInset to how much you want.
Custom view color should be lighter than the cell then it will be look like what you want.
It's all about how you set up your UITableViewCell's XIB really.
Add a UIView as a child view of the contentView in the UITableViewCell. Set the trailing, leading, top and bottom spacing of this UIView to it's parent view (contentView) to 5 or whatever value you desire. Set the background colour of the contentView as Clear Colour. Set the backgroundColour of your UITableView to the desired colour with the background colour of the contentView being white.
You can set the cornerRadius of the layer of the UIView to 5.0 to achieve the cornered effect as in your image
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 add a static background to a collectionview because at the moment the background scrolls with the cells and the image looks quite bad.
my code at the moment
collectionView.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"bg.png"]];
There are 2 ways to do what you're asking.
add the background to the UICollectionView as a subview like you're doing now and implement the scrollViewDidScroll: delegate method. Inside that method, set the frame of the background view based on the contentOffset of the collection view which will make it appear to be static on the screen. You will just need to set the frame's Y origin to be the contentOffset.y and it should work. (If there is a non-zero contentInset you may need to do a bit of additional math to get it right.)
add the background to the superview of your collection view, underneath the collection view. This is an easier and probably more efficient solution since you don't need to mess with the contentOffset at all since the background will not be in the scroll view itself.
if I understand your requirement correctly, here's how you can do it:
1) Add your static image as a subview to the parentView.
2) Set the backgroundColor of collectionView to [UIColor clearColor]
3) Add collection view as a subview to the parentView.
How do you create buttons like the "Settings", "Notifications", and "Cash Out" buttons in venmo shown below? Also, is the scroll view they use just a UIScrollView or a modified UITableView? I can't figure out how to add things like the buttons or the picture with balance info and name to a UITableView.
For this example, I think it's easier to use a UITableView than to build a custom subclass of UIScrollView. If you want to customize the look of the table view's cells, initialize the table view with the UITableViewStylePlain style and give each UITableViewCell the appropriate backgroundView & selectedBackgroundView in –[UITableViewDataSource tableView:cellForRowAtIndexPath:].
For the "Settings," "Notifications," and "Cash Out" buttons, just add them as subviews of the cell in the first row of the first section. Use -[UIButton setTitle:forState:] & -[UIButton setImage:forState:] to give each button a title & image, respectively. Set the UIButton properties titleEdgeInsets and/or imageEdgeInsets so that each button's title appears below its image.
To add a picture with a name, bio, and balance at the top, use the tableHeaderView property of UITableView. In -[UIViewController viewDidLoad], initialize a UIView *tableHeaderView with the desired height and give it subviews, e.g., pictureButton, nameLabel, bioTextView, balanceLabel. Then, do self.tableView.tableHeaderView = tableHeaderView.
They have used tableView. It contains 3 sections. They have chaged customCell in each section. In cellForRow delegate method you get section. Accordingly you can change cells. In CustomCell you can add any view like buttons.