0

In my project I want to design custom View Cell programatically with SVGKImageView & UILabel like this enter image description here

here square is an SVGKImageView & "Dadar" is an UILabel.

But now I am getting output like this

enter image description here

This is my code

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
 {
    // intialize collection cell with media collection cell
    let cell = collectionView.dequeueReusableCellWithReuseIdentifier("mediaCell", forIndexPath: indexPath) as! ViewContentMediaCollectionCell

    // get the data from view model
    let viewModelobj = mViewContentViewModelObj!.getViewContentData()

    // set the page imageview frame with default size
    var mSVGImageView = SVGKFastImageView(frame: CGRect(x: 0, y: 0, width: cell.frame.width, height: (50)))

    // set the pageImageview with actual pageImage
    mSVGImageView = SVGKFastImageView(SVGKImage: viewModelobj[indexPath.row].mContentPage)

    // add page imageview in the cell
    cell.contentView.addSubview(mSVGImageView)

    // add the title label
    let titleLabel : UILabel = UILabel(frame: CGRect(x: 0, y: cell.frame.height - 20, width: cell.frame.width, height: 20))

    // set the page title
    titleLabel.text = viewModelobj[indexPath.row].mPageTitle

    // add title label to the collection view cell
    cell.contentView.addSubview(titleLabel)

    // return the cell
    return cell

  }
Priyanka Kanse
  • 1,051
  • 1
  • 15
  • 27

1 Answers1

0

You should create a custom view that contains an ImageView and a label like your design then add to the contentView