Skip to content

Instantly share code, notes, and snippets.

@MylesCaley
Created April 17, 2017 15:29
Show Gist options
  • Save MylesCaley/d6257386fc8e1cbdc8417ca46a4e89dd to your computer and use it in GitHub Desktop.
Save MylesCaley/d6257386fc8e1cbdc8417ca46a4e89dd to your computer and use it in GitHub Desktop.
RxDataSources - get data
func collectionView(_ collectionView: UICollectionView, heightForAnnotationAtIndexPath indexPath: IndexPath, withWidth width: CGFloat) -> CGFloat {
let x = dataSource?[indexPath]
let font = UIFont(name: "OpenSans", size: 11)!
let rect = NSString(string: x?.brief ?? "").boundingRect(with: CGSize(width: width, height: CGFloat(MAXFLOAT)), options: .usesLineFragmentOrigin, attributes: [NSFontAttributeName: font], context: nil)
// if multiple types
// var height = 400
//
// switch x! {
// case let .feedUpdateSectionItem(item):
// if item.prototypeUpdate?.media.first != nil {
// height = 403
// } else {
// height = 203
// }
// case let .feedProjectSectionItem(item):
// if item.prototype?.media != nil {
// height = 426
// } else {
// height = 203
// }
//
// case let .feedIdeaSectionItem(item):
// if item.idea?.media.first != nil {
// height = 426
// } else {
// height = 146
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment