NewMainAppCollectionViewCell.swift 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // NewMainAppCollectionViewCell.swift
  3. // O2Platform
  4. //
  5. // Created by 刘振兴 on 2017/3/12.
  6. // Copyright © 2017年 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. class NewMainAppCollectionViewCell: UICollectionViewCell {
  10. @IBOutlet weak var appIconImageView: UIImageView!
  11. @IBOutlet weak var appNameLabel: UILabel!
  12. private var nowData:O2App?
  13. override func awakeFromNib() {
  14. super.awakeFromNib()
  15. }
  16. func setAppData(app: O2App) {
  17. self.nowData = app
  18. self.appIconImageView.image = UIImage(named: app.normalIcon!)
  19. self.appNameLabel.text = app.title
  20. if let storeBoard = app.storyBoard, storeBoard == "webview" {
  21. if let iconUrl = AppDelegate.o2Collect.generateURLWithAppContextKey(ApplicationContext.applicationContextKey2, query: ApplicationContext.applicationIconQuery, parameter: ["##applicationId##":app.appId! as AnyObject]) {
  22. let url = URL(string: iconUrl)
  23. let size = self.appIconImageView.bounds.size
  24. if size.width == 0 {
  25. self.appIconImageView.bounds.size = CGSize(width: 38, height: 38)
  26. }
  27. self.appIconImageView.image = UIImage(named: app.normalIcon!)
  28. self.appIconImageView.highlightedImage = UIImage(named: app.normalIcon!)
  29. self.appIconImageView.hnk_setImageFromURL(url!, placeholder: UIImage(named: app.normalIcon!), format: nil, failure: { (err) in
  30. self.appIconImageView.image = UIImage(named: app.normalIcon!)
  31. }) { image in
  32. if self.nowData?.appId == app.appId {
  33. self.appIconImageView.image = image
  34. }
  35. }
  36. } else {
  37. self.appIconImageView.image = UIImage(named: app.normalIcon!)
  38. }
  39. }
  40. }
  41. }