Use a UICollectionView instead of a UITableView
Cells are automatically centered, just create a square size.
質問
I'm curious of how Youtube `s UITableViewCells are done, here is a screenshot:
Like you can see the cells are like squared and centred, how can I do that?
解決 2
Use a UICollectionView instead of a UITableView
Cells are automatically centered, just create a square size.
他のヒント
While you actually can use UICollectionView
instead of a UITableView
, this layout (YouTube App) can actually be achieved with UITableView
as well.
You will need to create a custom UITableViewCell
, that has few images and labels. When you create a custom UITableViewCell
, you add items to the contentView
property. You can then change the constraints or frame of the contentView
property to achieve the effect.
Of course, there are more ways to achieve this layout, but I would follow this one:
UITableViewCell
.UITableViewCell
a clear background.contentView
UIView
property of the created subclass.contentView
in UITableViewCell
.contentView
.It is basically not hard to create a design like this.