Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ThemesVC: UIViewController {
- var images: [UIImage] = []
- override func viewDidLoad() {
- super.viewDidLoad()
- images = ThemeManager().themeBackgroundImages()
- // whatever else you're doing in viewDidLoad
- // ...
- }
- }
- extension ThemesVC: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout{
- func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
- return images.count
- }
- func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ThemesCollectionViewCell", for: indexPath) as! ThemesCollectionViewCell
- cell.contentView.layer.cornerRadius = 20
- cell.themeCellImageView.image = images[indexPath.row]
- return cell
- }
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
- return UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20)
- }
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
- return 20
- }
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
- return 20
- }
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
- return CGSize(width: view.frame.size.width/2.34, height: view.frame.size.height * 0.3)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement