I have class for a cell
import UIKit
class LinkCellView: UITableViewCell {
#IBOutlet weak var cellTitleLabel: UILabel!
#IBOutlet weak var tagsListView: UIView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
I fill the tagsListView in cellForRowAt
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "linkCell", for: indexPath) as! LinkCellView
let object = links[indexPath.row]
cell.cellTitleLabel!.text = object.description
let tag = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 21))
tag.text = "Frkul"
cell.tagsListView.addSubview(tag)
return cell
}
Unfortunately when I then run the app in simulator, list of tags is just barely visible there. My expectation is to see the whole tags list.
I am pretty new to iOS development, so it is possible I am missing some fundamental knowledge of designing iOS UI. If it is not possible to answer this question directly, pls point me to a tutorial / webinar taking newbies through this topic.
Xcode Version 10.0
iOS 12
iOS simulator Version 10.0
Static version of the App — https://gitlab.com/lipoqil/stackview-in-table-cell
Ok, for some reason, if I use UIStackView, instead of UIView, it displays almost as I wish.
It introduces one change in the code
cell.tagListView.addSubview(tag) → cell.tagListView.addArrangedSubview(tag)
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "linkCell", for: indexPath) as! LinkCellView
cell.tagListView.subviews.forEach { $0.removeFromSuperview() }
let object = links[indexPath.row]
cell.cellTitleLabel!.text = object.description
let tag = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 21))
tag.shadowColor = .blue
tag.text = object.tags
cell.tagListView.addArrangedSubview(tag)
return cell
}
I still need to solve, how to fit the tags there, how to make its look more tagish, but I believe that's beyond the original question.
if you have a collection of tags you need to implement a collection view into your tableView Cell, and if you just have 1 tag, just implement it in your xib ?
Here is my code.
func numberOfSections(in tagsCV: UICollectionView) -> Int {
return 1
}
func collectionView(_ tagsCV: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return videoObject?.tags?.count ?? 0
}
func collectionView(_ tagsCV: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize{
let fontAttributes = [NSAttributedStringKey.font: StylesBook.hashtag.value.textFont]
let size = (videoObject?.tags?[indexPath.row] ?? "" as String).size(withAttributes: fontAttributes)
return CGSize(width: size.width + CGFloat(20) , height: 50)
}
func collectionView(_ tagsCV: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = tagsCV.dequeueReusableCell(withReuseIdentifier: "TagCollectionViewCell", for: indexPath) as! TagCollectionViewCell
cell.tagBtn.setTitle(englishNumToPersian(text: videoObject?.tags?[indexPath.row] ?? "") , for: .normal)
cell.tagBtn.addTarget(self, action: #selector(tagTaped(sender:)), for: .touchDown)
cell.transform = CGAffineTransform(scaleX: -1, y: 1)
return cell
}
The key is that you need to set ur collection view's scroll direction horizontal. This way whether you have 1 or 1000 tag, they'll all be shown perfectly, and the button (or label) width will fit its content. I recommend you to use button, instead of label, and disable its user interaction to act like a label.
Related
Question:
How To Make UITableViewCell Height Dynamic according the UICollectionViewCell?
View Hierarchy:
UIViewController
UITableView
UITableViewCell
UICollectionView
UICollectionViewCell1
Label 1
UICollectionViewCell2
Label 2
UICollectionViewCell3
Label 3
[So on]
Explanation:
Here Label1, Label2, label 3 are have dynamic height and numberOfRows in UICollectionView is also dynamic. I need Height of UITableViewCell according to the UICollectionViewCell.
View Hierarchy In UIViewController
Steps:
Bind Delegate And Datasource
Bind UITableView delegate and datasource with the UIViewController.
Bind UICollectionView Delegate and datasource with the UITableViewCell here TblCell.
In UIViewController
class CollectionVC: UIViewController, UITableViewDataSource, UITableViewDelegate {
:
:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension // For tableCell Dynamic Height
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return 200 // For tableCell Estimated Height
}
// Above two delegates must be necessary or you can use property for same.
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1 // returning 1, as per current single cell
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "TblCell") as! TblCell
return cell
}
}
In TblCell
class TblCell: UITableViewCell , UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout{
#IBOutlet var colViewObj: UICollectionView!
// Array for Label
var arrData = ["Hello", "How re you?", "rock the world", "Nice to meet you.", "Hey! It is awsome."]
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
self.colViewObj.isScrollEnabled = false
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
// Get width of Label As per String characters.
let aWidth : CGFloat = arrData[indexPath.row].width(withConstraintedHeight: 40, font: UIFont.systemFont(ofSize: 17.0))
return CGSize(width: aWidth + 40 , height: 40)
}
// THIS IS THE MOST IMPORTANT METHOD
//
// This method tells the auto layout
// You cannot calculate the collectionView content size in any other place,
// because you run into race condition issues.
override func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize {
// If the cell's size has to be exactly the content
// Size of the collection View, just return the
// collectionViewLayout's collectionViewContentSize.
self.colViewObj.frame = CGRect(x: 0, y: 0,
width: targetSize.width, height: 600)
self.colViewObj.layoutIfNeeded()
// It Tells what size is required for the CollectionView
return self.colViewObj.collectionViewLayout.collectionViewContentSize
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return arrData.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ColViewCell", for: indexPath) as! ColViewCell
cell.lblTitle.text = arrData[indexPath.item]
cell.lblTitle.layer.borderColor = UIColor.black.cgColor
cell.lblTitle.layer.borderWidth = 1.0
return cell
}
}
extension String {
func width(withConstraintedHeight height: CGFloat, font: UIFont) -> CGFloat {
let constraintRect = CGSize(width: .greatestFiniteMagnitude, height: height)
let boundingBox = self.boundingRect(with: constraintRect, options: .usesLineFragmentOrigin, attributes: [NSFontAttributeName: font], context: nil)
return ceil(boundingBox.width)
}
}
Output:
Red Border : UITableViewCell
Yellow Border : UICollectionViewCell
Black Outline : Label
with UICollectionViewDelegateFlowLayout
without UICollectionViewDelegateFlowLayout
Reference:
UICollectionView inside a UITableViewCell -- dynamic height?
Note :
TableViewCell height is based on collectionview content size i.e. if same tableCell have any other UI component other than collectionview or there is top bottom margin for collectionView then it won't be calculated. For this, you can create multiple cells in which one cell only contain collectionview (Best Approach for now) or you can return your actual tableViewCell height in systemLayoutSizeFitting by calculation.
how to give height to cell accorting to text in swift
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
{
let message = "Swift is a powerful and intuitive programming language for macOS, iOS, watchOS and tvOS. Writing Swift code is interactive and fun, the syntax is concise yet expressive, and Swift includes modern features developers love."
let font = UIFont.systemFont(ofSize: 12.0)
let height = heightForLabel(text: message, font: font, width: self.view.bounds.width )
if height > 40 {
return height
} else {
return 40.0;
}
}
func heightForLabel(text:String, font:UIFont, width:CGFloat) -> CGFloat
{
let label:UILabel = UILabel(frame: CGRect(x:0,y: 0,width:width,height:CGFloat.greatestFiniteMagnitude))
label.numberOfLines = 0
label.lineBreakMode = NSLineBreakMode.byWordWrapping
label.font = font
label.text = text
label.sizeToFit()
return label.frame.height
}
Question:
How To Make UITableViewCell Height Dynamic according the UICollectionViewCell?
View Hierarchy:
UIViewController
UITableView
UITableViewCell
UICollectionView
UICollectionViewCell1
Label 1
UICollectionViewCell2
Label 2
UICollectionViewCell3
Label 3
[So on]
Explanation:
Here Label1, Label2, label 3 are have dynamic height and numberOfRows in UICollectionView is also dynamic. I need Height of UITableViewCell according to the UICollectionViewCell.
View Hierarchy In UIViewController
Steps:
Bind Delegate And Datasource
Bind UITableView delegate and datasource with the UIViewController.
Bind UICollectionView Delegate and datasource with the UITableViewCell here TblCell.
In UIViewController
class CollectionVC: UIViewController, UITableViewDataSource, UITableViewDelegate {
:
:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension // For tableCell Dynamic Height
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return 200 // For tableCell Estimated Height
}
// Above two delegates must be necessary or you can use property for same.
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1 // returning 1, as per current single cell
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "TblCell") as! TblCell
return cell
}
}
In TblCell
class TblCell: UITableViewCell , UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout{
#IBOutlet var colViewObj: UICollectionView!
// Array for Label
var arrData = ["Hello", "How re you?", "rock the world", "Nice to meet you.", "Hey! It is awsome."]
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
self.colViewObj.isScrollEnabled = false
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
// Get width of Label As per String characters.
let aWidth : CGFloat = arrData[indexPath.row].width(withConstraintedHeight: 40, font: UIFont.systemFont(ofSize: 17.0))
return CGSize(width: aWidth + 40 , height: 40)
}
// THIS IS THE MOST IMPORTANT METHOD
//
// This method tells the auto layout
// You cannot calculate the collectionView content size in any other place,
// because you run into race condition issues.
override func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize {
// If the cell's size has to be exactly the content
// Size of the collection View, just return the
// collectionViewLayout's collectionViewContentSize.
self.colViewObj.frame = CGRect(x: 0, y: 0,
width: targetSize.width, height: 600)
self.colViewObj.layoutIfNeeded()
// It Tells what size is required for the CollectionView
return self.colViewObj.collectionViewLayout.collectionViewContentSize
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return arrData.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ColViewCell", for: indexPath) as! ColViewCell
cell.lblTitle.text = arrData[indexPath.item]
cell.lblTitle.layer.borderColor = UIColor.black.cgColor
cell.lblTitle.layer.borderWidth = 1.0
return cell
}
}
extension String {
func width(withConstraintedHeight height: CGFloat, font: UIFont) -> CGFloat {
let constraintRect = CGSize(width: .greatestFiniteMagnitude, height: height)
let boundingBox = self.boundingRect(with: constraintRect, options: .usesLineFragmentOrigin, attributes: [NSFontAttributeName: font], context: nil)
return ceil(boundingBox.width)
}
}
Output:
Red Border : UITableViewCell
Yellow Border : UICollectionViewCell
Black Outline : Label
with UICollectionViewDelegateFlowLayout
without UICollectionViewDelegateFlowLayout
Reference:
UICollectionView inside a UITableViewCell -- dynamic height?
Note :
TableViewCell height is based on collectionview content size i.e. if same tableCell have any other UI component other than collectionview or there is top bottom margin for collectionView then it won't be calculated. For this, you can create multiple cells in which one cell only contain collectionview (Best Approach for now) or you can return your actual tableViewCell height in systemLayoutSizeFitting by calculation.
how to give height to cell accorting to text in swift
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
{
let message = "Swift is a powerful and intuitive programming language for macOS, iOS, watchOS and tvOS. Writing Swift code is interactive and fun, the syntax is concise yet expressive, and Swift includes modern features developers love."
let font = UIFont.systemFont(ofSize: 12.0)
let height = heightForLabel(text: message, font: font, width: self.view.bounds.width )
if height > 40 {
return height
} else {
return 40.0;
}
}
func heightForLabel(text:String, font:UIFont, width:CGFloat) -> CGFloat
{
let label:UILabel = UILabel(frame: CGRect(x:0,y: 0,width:width,height:CGFloat.greatestFiniteMagnitude))
label.numberOfLines = 0
label.lineBreakMode = NSLineBreakMode.byWordWrapping
label.font = font
label.text = text
label.sizeToFit()
return label.frame.height
}
I need an auto scrolling Image slider in top of viewcontroller followed by list of some entities(dynamic cells with image and title). To implement that I have taken a uitableview and I'm adding scrollview to my first cell, and my code is as follows
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.row == 0{
return 200
}
else {
return 50
}
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 20
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
if indexPath.row == 0 {
let sv = UIScrollView(frame: CGRect(x: 0, y: 0, width: cell.frame.width, height: cell.frame.height))
sv.auk.show(url: "url for image1")
sv.auk.show(url: "url for image2")
cell.addSubview(sv)
print("inside if")
}
else {
print("else")
cell.textLabel?.text = "cool"
}
return cell
}
I'm using this repository to create image slider which creates slider on a scrollview, So for first cell I have added scrollview. But as you can see in the picture the image slider reappears on multiple rows. Please tell me what is the mistake that I'm doing.In case if there is any better approaches please suggest .
Try taking a separate class for dynamic cells. Dequeue both the cells (static and dynamic cells) in the cellForRow method as follows:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return indexPath.row == 0 ? 200 : 50
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 20 }
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.row == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
scrollViewWidth = cell.frame.width
scrollViewHeight = cell.frame.height
let scrollView = prepareScrollView(width: scrollViewWidth, height: scrollViewHeight)
cell.addSubview(scrollView )
print("First row")
return cell
}
else {
let myCustomCell: MyCustomTableViewCellClass = tableView.dequeueReusableCell(withIdentifier: "MyCustomTableViewCellIdentieier", for: indexPath) as! MyCustomTableViewCellClass
myCustomCell.textLabel?.text = "Cool"
print("Other dynamic rows")
return myCustomCell
}
}
func prepareScrollView(_ width: Float, height: Float) -> UIScrollView {
let scrollViewFrame = CGRect(x: 0, y: 0, width: width, height: height)
let scrollView = UIScrollView(frame: scrollViewFrame)
scrollView.auk.show(url: "url for image1")
scrollView.auk.show(url: "url for image2")
return scrollView
}
Take a separate class as MyCustomTableViewCellClass of type UITableViewCell and subclass your dynamic cell with this class. Don't forget to give cell identifier as "MyCustomTableViewCellIdentieier"
After this, your static cell will dequeue only once and no chances od repeating UI elements
You can try this code in your table view cell class -
override func prepareForReuse() {
//set your lable and image view to nil
}
SideMenuTVCell is a my custom UITableViewCell class -
Hope like this you have your own class within this class you add prepareForReuse() method -
class SideMenuTVCell: UITableViewCell {
#IBOutlet weak var iconIView: UIImageView!
#IBOutlet weak var lblTitle: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
override func setHighlighted(_ highlighted: Bool, animated: Bool) {
super.setHighlighted(highlighted, animated: animated)
}
override func prepareForReuse() {
//set your lable and image view to nil
self.iconIView.image = nil
self.lblTitle.text = nil
}
}
So, I am right now making an app with a collection view layout and was wondering how to go about designing it to make it look nice. I found a picture online that I would like it to look like and was wondering how I should go about making it.
Here is the picture:
The collection view I would like to replicate is the one in the middle.
Here is how my current cells look like:
My Cells after the first answer:
This is my current code for configuring the cells:
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "channelCell", for: indexPath) as? ChannelCollectionViewCell
let channel = channels[indexPath.row]
// Configure the cell
cell?.configureCell(channel: channel)
return cell!
}
My guess is there would be 2 main things to making the deisgn I want which brings me to two specific questions.
How do I make a cell have rounded corners?
How do I space a cell from the side of screen and reduce gaps between cells?
ViewController Class
class YourClass: UIViewController {
//MARK:-Outlets
#IBOutlet weak var yourCollectionView: UICollectionView!
//Mark:-Variables
var cellWidth:CGFloat = 0
var cellHeight:CGFloat = 0
var spacing:CGFloat = 12
var numberOfColumn:CGFloat = 2
//MARK:-LifeCycle
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
yourCollectionView.contentInset = UIEdgeInsets(top: spacing, left: spacing, bottom: spacing, right: spacing)
if let flowLayout = yourCollectionView.collectionViewLayout as? UICollectionViewFlowLayout{
cellWidth = (yourCollectionView.frame.width - (numberOfColumn + 1)*spacing)/numberOfColumn
cellHeight = 100 //yourCellHeight
flowLayout.minimumLineSpacing = spacing
flowLayout.minimumInteritemSpacing = spacing
}
}
extension YourClass:UICollectionViewDataSource{
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 10
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as? YourCollectionViewCell{
//Configure cell
return cell
}
return UICollectionViewCell()
}
}
extension YourClass:UICollectionViewDelegateFlowLayout{
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: cellWidth, height: cellHeight)
}
}
CollectionViewCell Class
class YourCollectionViewCell:UICollectionViewCell{
override func awakeFromNib() {
super.awakeFromNib()
self.layer.cornerRadius = 10 //customize yourself
self.layer.masksToBounds = true
}
}
My button labels are stacked/regenerated when I scroll. So the first label might display Alabel with Elabel on top of it after has left the view and re-entered. I'm simply trying to create a single row of scrollable buttons (or labels for that matter). The collection view and cell were created via Storyboard. The code generates the correct number of cells in the CV, but the labels become layered when scrolled (horizontal).
let buttonLabels = ["Alabel", "Blabel", "Clabel", "Dlabel", "Elabel", "Flabel", "Glabel", "Hlabel", "Ilabel", "Jlabel", "Klabel", "Llabel", "Mlabel"]
#IBOutlet weak var btnCollVw: UICollectionView!
//loadColFlowLayout() is called from ViewDidLoad()
func loadColFlowLayout() {
let btnLayout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
btnLayout.scrollDirection = UICollectionViewScrollDirection.Horizontal
btnLayout.sectionInset = UIEdgeInsets(top: 0, left: 1, bottom: 0, right: 1)
btnLayout.itemSize = CGSize(width: 63, height: 30)
btnCollVw.collectionViewLayout = btnLayout
btnCollVw!.backgroundColor = UIColor.whiteColor()
}
func numberOfSections() -> Int {
return 1
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return buttonLabels.count
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
var cell: UICollectionViewCell = self.iconCollVw.dequeueReusableCellWithReuseIdentifier("swIconsCell", forIndexPath: indexPath) as UICollectionViewCell
var makeButton = UIButton(frame: CGRectMake(0, 0, 63, 29))
makeButton.setTitle(buttonLabels[indexPath.item], forState: .Normal)
makeButton.setTitleColor(UIColor.blackColor(), forState: .Normal)
cell.addSubview(makeButton)
// or using cell.contentView.addSubview(makeButton)
return cell
}
}
the problem in cell reusing, each time when you dequeue cell from collection view it can already has button, look at my a bit improved version when I check for button with known tag on cell:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
var cell: UICollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("swIconsCell", forIndexPath: indexPath) as UICollectionViewCell
if cell.viewWithTag(1234) == nil {
var makeButton = UIButton(frame: CGRectMake(0, 0, 63, 29))
makeButton.setTitle(buttonLabels[indexPath.item], forState: .Normal)
makeButton.setTitleColor(UIColor.blackColor(), forState: .Normal)
makeButton.tag = 1234;
cell.addSubview(makeButton)
// or using cell.contentView.addSubview(makeButton)
}
return cell
}
you can do the same in another way for example create subclass of UICollectionViewCell