How to align labels in custom UITableViewCells? - ios

I like to use the built-in cell styles (right detail, basic, subtitle) as much as possible, but some times I need custom controls, like a UISwitch or a UIStepper to be added to the cell, and I have to create my own custom cell styles on Storyboard.
Since iOS 13 and 14 suggests using the cell's imageView is a good idea to be used for adding icons to the rows, I use it on cells with built-in styles. It seems the image view doesn't have a fixed width and the table view adapts itself to the widest image.
What should I use to tie my UITextLabels on my custom cells to in order to make advantage of this behavior? When I tie the left side of the label to the left margin, then the label overlaps the imageView.

Related

UICollectionViewCell Shadow on all four sides

I was wondering want the best way to add drop shadows to a set of collectionviewcells that do not have spaces between them?
Background
Part of my layout has various cells positioned across the screen like a post. It notes and the second half of the layout is structured to look like a tableview except all the cells don't go to the edges there's a bit of padding. So I can't really add a shadow around the collection view itself.
I have added shadows to the cells in the post. It note part which works great because the cells have spaces between them but I'm now struggling with the second half (the tableview looking part) because obviously when you add the shadows to the cells depending on the zIndex you may see the shadow overlapping the below or top cell.
So I was wondering what is the best way to do this?
Should the shadows decoration views underneath the cells?
OR
Should the shadows be attached to the cell and increase the ZIndex for each cell so they appear on different levels hiding the shadow - but that leads to a question on how to do the first cell and have a top shadow?
OR
Should I almost fake it by using an image of a shadow inside the cell itself?
I also have deletion functionality so I need to figure out how to make sure if I delete the first cell, the second cell should then have the top shadow in a nice animated way.
EDIT:
I am trying to create the following view inside the collection view. I have got the layout correct. 1
The green lines are the shadows I have working but the red are the ones I'm having trouble with and the boxes are the different cells.

UITableView fixed section with dynamic size

I am trying to implement something like this:
I have a UITableView with 1. "static" section, the total number of sections in the tableView can vary. I always want the first section (white area) to be visible to the user, the remaining sections should scroll underneath the first section. I have tried to implement this with two UITableViews, but since the (white area) can vary in size, I can't set a definite frame. I am using Storyboards with autolayout. At the moment the best solution I have come up with is the two UITableViews, but I need to find a way that I can resize the two tableViews according to the content of the white area and according to each other. The white area, one of the tableViews is containing a section with two rows, the first row is containing text that can vary in length and therefore needs dynamic resizing.
Any Idea how I can tackle this? Can I change the NSLayoutConstraints dynamically somehow?
If i understand correct, your first UIView rectangle if fixed, bottom table is scrollable.
To implement this, you should create typical UIViewController, add UIView and UITableView (programmatically or through an outlets). You should manage each view (tableView and UIView) separately.

Need assistance regarding custom UITableView and custom UITableViewCell

This is screenshot of whatsapp, I have to create a tableview just like this one.
It has space on left side (Dont know top two cell are custom or default with right detail style).
Few cells in between have no separators.
How I am suppose to do same with my uitableview.
Start from iOS 7 left inset of UITalbeViewCell is default. Default value is 15, but you can change it.
This is not a few cells. This is One custom cell. I mean work+main+iPhone it is one cell.

How to set the height of prototype cells in an iOS table views

I have a table view with a prototype cell containing both disclosure and detail accessories. I want to use a font size of 12 in the cell and reduce the row height accordingly. Thus the size of the two accessory icons need to be reduced in size as well. I assumed this would be one of the more obvious things one might want to do with a table view but fail miserably in figuring out how?
Assuming you are have a nib or storyboard, you should see a resize handle on the cells when you select a cell in the editor. Just grab and resize.

iOS: iMessage style header and divider UI

I'm trying to recreate pieces of the iMessage UI. Specifically the top buttons and dividers (i.e. "iMessage" label + line)
I'm assuming:
The top buttons are within custom UIView as the header of a UITableView
The divider is a custom UITableViewCell with a centered label and some kind of repeated background imageā€¦
Can anyone confirm or elaborate on this? Specifically the dividers.
First, I would create the divider and the "iMessage" text as a single image.
Since the divider and the buttons on top of it is "non-sticky" I would just create a custom UITableViewCell and put everything (buttons and divider image) in the table cell.

Resources