O2BBSCreatorView.swift 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // O2BBSCreatorView.swift
  3. // o2app
  4. //
  5. // Created by 刘振兴 on 2018/1/3.
  6. // Copyright © 2018年 zone. All rights reserved.
  7. //
  8. import UIKit
  9. protocol O2BBSCreatorViewDelegate {
  10. func creatorViewClicked(_ view:O2BBSCreatorView)
  11. }
  12. class O2BBSCreatorView: UIView {
  13. private var _iconImage:UIImage?
  14. var iconImage:UIImage? {
  15. get {
  16. return _iconImage
  17. }
  18. set(newImage){
  19. _iconImage = newImage
  20. if _iconImage != nil {
  21. self.actionButton.setImage(_iconImage, for: .normal)
  22. }
  23. }
  24. }
  25. @IBOutlet weak var actionButton: UIButton!
  26. @IBOutlet weak var creatorView: UIView!
  27. var delegate:O2BBSCreatorViewDelegate?
  28. override func awakeFromNib() {
  29. actionButton.layer.cornerRadius = 25
  30. actionButton.layer.masksToBounds = true
  31. creatorView.layer.cornerRadius = 25
  32. creatorView.layer.masksToBounds = true
  33. self.layer.cornerRadius = 25
  34. self.layer.masksToBounds = true
  35. }
  36. @IBAction func creatorViewClicked(_ sender: UIButton) {
  37. guard let _ = delegate else {
  38. return
  39. }
  40. self.delegate?.creatorViewClicked(self)
  41. }
  42. }