0

need to move the collection view cell accordingly. I have attached my screenshot for your reference: enter image description here

the above is my current image but I need that to be like this: enter image description here

Then I need to add image to the textfield but I have added some code but I could not add it

searchtextfield.leftViewMode = UITextFieldViewMode.always
searchtextfield.leftView = UIImageView(image: UIImage(named: "search"))
vahdet
  • 6,357
  • 9
  • 51
  • 106
KARTHICK T M
  • 75
  • 1
  • 8
  • Welcome to stackoverflow. Please edit your post and add a minimal, Complete, and Verifiable example - otherwise it is hard to tell what the exact problem is. You may want to have a look at too. – quant Nov 09 '18 at 07:11
  • For Left View Mode : https://stackoverflow.com/questions/27903500/swift-add-icon-image-in-uitextfield – Amit Nov 09 '18 at 07:15

1 Answers1

0

For the collection view cell width and height you have to use below method:

extension "Your Controller" : UICollectionViewDelegateFlowLayout {

    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        return CGSize(width: collectionView.frame.size.width/2 - 15, height: collectionView.frame.size.width/2 - 15)
    }
}

To make the the cell square I have added the with and height same. You can change it according to your requirement. The collection view width changes for different devices so you have to change the cell width and height too.

Don't forget to do the change in this too according to your requirement:

enter image description here

Hope this helps.

Amit
  • 4,837
  • 5
  • 31
  • 46