Skip to content

Instantly share code, notes, and snippets.

View harrysummers's full-sized avatar

Harry Summers harrysummers

  • EBSCO Ind.
  • Birmingham AL
View GitHub Profile
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let gif = gifs[indexPath.row]
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellId, for: indexPath) as! GifCollectionViewCell
cell.gifView.loadGif(name: gif)
return cell
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
import UIKit
class AddAlbumView: UIView {
var albumArt: UIImageView = {
var imageView = UIImageView()
imageView.contentMode = .scaleAspectFill
imageView.translatesAutoresizingMaskIntoConstraints = false
imageView.backgroundColor = UIColor.CustomColors.spotifyDark
return imageView
@harrysummers
harrysummers / gist:a5d7c503ef04bba329f8c99ba6b5ccdc
Created May 18, 2018 21:13
View controller property in UIView
weak var viewController: UIViewController? {
didSet {
setupViewController()
}
}
@harrysummers
harrysummers / gist:763c761b3c20380b7cd9224291e196f1
Created May 18, 2018 21:15
UIView property in View Controller
let addAlbumView: AddAlbumView = {
let view = AddAlbumView()
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()
@harrysummers
harrysummers / gist:33cb567be3c4f9008833456f4b95db34
Created May 18, 2018 21:17
Assigning the viewController property
override func viewDidLoad() {
super.viewDidLoad()
addAlbumView.viewController = self
}
@harrysummers
harrysummers / gist:430bc09387f45c3e5801bd6312852fb1
Created May 19, 2018 19:36
Get currently active view controller
fileprivate func getShowingViewController(_ rootViewController: UIViewController) -> UIViewController? {
var isRoot = false
var showViewController: UIViewController? = rootViewController
while (!isRoot) {
if let tempViewController = showViewController?.presentedViewController {
showViewController = tempViewController
} else {
isRoot = true
}
}