OOLinkManInfoHeader.swift 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // OOLinkManInfoHeader.swift
  3. // o2app
  4. //
  5. // Created by 刘振兴 on 2017/11/23.
  6. // Copyright © 2017年 zone. All rights reserved.
  7. //
  8. import UIKit
  9. class OOLinkManInfoHeader: UIView {
  10. @IBOutlet weak var iconImageView: UIImageView!
  11. @IBOutlet weak var nameLabel: UILabel!
  12. @IBOutlet weak var manButton: UIButton!
  13. @IBOutlet weak var womenButton: UIButton!
  14. @IBOutlet weak var oftenLinkManButton: UIButton!
  15. override init(frame: CGRect) {
  16. super.init(frame: frame)
  17. }
  18. required init?(coder aDecoder: NSCoder) {
  19. super.init(coder: aDecoder)
  20. }
  21. override func awakeFromNib() {
  22. commonSetupNib()
  23. }
  24. private func commonSetupNib(){
  25. self.iconImageView.layer.masksToBounds = true
  26. self.iconImageView.layer.cornerRadius = 37.5
  27. self.manButton.isUserInteractionEnabled = false
  28. self.womenButton.isUserInteractionEnabled = false
  29. }
  30. func configHeaderOfPerson(_ viewModel:OOLinkManViewModel,_ person:OOPersonModel){
  31. self.nameLabel.text = person.name
  32. let gender = person.genderType ?? "u"
  33. if gender == "m" {
  34. self.manButton.isSelected = true
  35. self.womenButton.isSelected = !self.manButton.isSelected
  36. }else if gender == "f" {
  37. self.womenButton.isSelected = true
  38. self.manButton.isSelected = !self.womenButton.isSelected
  39. }
  40. viewModel.getIconOfPerson(person) { (image, errMSg) in
  41. self.iconImageView.image = image
  42. }
  43. }
  44. }