PublishAddressPOICell.swift 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. //
  2. // PublishAddressPOICell.swift
  3. // RainbowPlanet
  4. //
  5. // Created by Christopher on 2019/6/19.
  6. // Copyright © 2019 RainbowPlanet. All rights reserved.
  7. //
  8. import UIKit
  9. import RxSwift
  10. import RxCocoa
  11. class PublishAddressPOICell: UITableViewCell {
  12. let disposeBag = DisposeBag()
  13. class func cellWith(tableView:UITableView,indexPath:IndexPath) -> PublishAddressPOICell {
  14. let ID = "PublishAddressPOICell"
  15. tableView.register(PublishAddressPOICell.self, forCellReuseIdentifier: ID)
  16. let cell : PublishAddressPOICell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! PublishAddressPOICell
  17. cell.indexPath = indexPath
  18. return cell
  19. }
  20. override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
  21. super.init(style: style, reuseIdentifier: reuseIdentifier)
  22. setupViews()
  23. setupLayouts()
  24. }
  25. required init?(coder aDecoder: NSCoder) {
  26. fatalError("init(coder:) has not been implemented")
  27. }
  28. //MARK: - indexPath
  29. var indexPath: IndexPath?{
  30. didSet {
  31. }
  32. }
  33. var suggestionInfo: BMKSuggestionInfo? {
  34. didSet {
  35. switch indexPath?.section {
  36. case 1:
  37. titleLabel.text = self.suggestionInfo!.district + self.suggestionInfo!.key
  38. default:
  39. break
  40. }
  41. }
  42. }
  43. var poiInfo: SwiftLocationPOIModel? {
  44. didSet {
  45. switch indexPath?.section {
  46. case 1:
  47. titleLabel.text = self.poiInfo?.name
  48. default:
  49. break
  50. }
  51. }
  52. }
  53. var locationAddress: String? {
  54. didSet {
  55. if locationAddress != "" && locationAddress != nil {
  56. titleLabel.text = locationAddress
  57. }else {
  58. titleLabel.text = LocationModel.shared().getLocationModel()?.city ?? "西安市"
  59. }
  60. }
  61. }
  62. //MARK: - 设置view
  63. private func setupViews() {
  64. self.selectionStyle = .none
  65. addSubview(titleLabel)
  66. addSubview(bottomLineLabel)
  67. }
  68. private func setupLayouts() {
  69. titleLabel.snp.makeConstraints { (make) in
  70. make.centerY.equalToSuperview()
  71. make.left.equalTo(14)
  72. make.right.equalTo(-14)
  73. make.height.equalTo(21)
  74. }
  75. bottomLineLabel.snp.makeConstraints { (make) in
  76. make.bottom.equalToSuperview()
  77. make.left.equalTo(titleLabel.snp_left)
  78. make.right.equalTo(titleLabel.snp_right)
  79. make.height.equalTo(0.5)
  80. }
  81. }
  82. private lazy var titleLabel: UILabel = {
  83. let titleLabel = UILabel()
  84. titleLabel.textColor = k333333Color
  85. titleLabel.font = kMediumFont15
  86. titleLabel.textAlignment = .left
  87. titleLabel.numberOfLines = 0
  88. return titleLabel
  89. }()
  90. private lazy var bottomLineLabel: UILabel = {
  91. let bottomLineLabel = UILabel()
  92. bottomLineLabel.backgroundColor = kf5f5f5Color
  93. return bottomLineLabel
  94. }()
  95. }