1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- //
- // CommentInputView.swift
- // RainbowPlanet
- //
- // Created by 南鑫林 on 2019/7/8.
- // Copyright © 2019 RainbowPlanet. All rights reserved.
- //
- import UIKit
- import IQKeyboardManagerSwift
- import RxSwift
- class CommentInputView: UIView {
-
- let disposeBag = DisposeBag()
-
- typealias CommentInputViewClosure = () -> ()
- var commentInputViewClosure :CommentInputViewClosure?
-
- override init(frame: CGRect) {
- super.init(frame: frame)
- setupViews()
- }
-
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
-
- func setupViews() {
- self.backgroundColor = UIColor.white
- addSubview(inputTextView)
- addSubview(sendButton)
- }
- lazy var inputTextView: IQTextView = {
- let inputTextView = IQTextView(frame: CGRect(x: 14, y: 10, width: kScreenWidth - 14 - 84, height: 30))
- inputTextView.backgroundColor = kf0f0f0Color
- inputTextView.font = kRegularFont14
- inputTextView.layoutManager.allowsNonContiguousLayout = false
- inputTextView.enablesReturnKeyAutomatically = true
- inputTextView.scrollsToTop = false
- inputTextView.textContainerInset = UIEdgeInsets(top: 5, left: 15, bottom: 5, right: 15)
- inputTextView.textContainer.lineFragmentPadding = 0
- inputTextView.layer.cornerRadius = 14
- inputTextView.layer.masksToBounds = true
- inputTextView.placeholder = "添加评论...";
- inputTextView.tintColor = kThemeColor
- inputTextView.isEditable = false
- inputTextView.addTapGesture(1, target: self, action: #selector(showKeyBoard))
- return inputTextView
- }()
-
- lazy var sendButton: UIButton = {
- let sendButton = UIButton(type: UIButton.ButtonType.custom)
- sendButton.frame = CGRect(x: kScreenWidth - 14 - 60, y: 11, width: 60, height: 28)
- sendButton.setTitle("发布", for: UIControl.State.normal)
- sendButton.setBackgroundImage(UIImage.imageWithColor(color: kThemeColor), for: UIControl.State.normal)
- sendButton.setBackgroundImage(UIImage.imageWithColor(color: kd8d8d8Color), for: UIControl.State.disabled)
- sendButton.titleLabel?.font = kRegularFont14
- sendButton.layer.cornerRadius = 14;
- sendButton.layer.masksToBounds = true
- sendButton.isEnabled = false
- return sendButton
- }()
-
- @objc func showKeyBoard() {
- if let commentInputViewClosure = commentInputViewClosure {
- commentInputViewClosure()
- }
- }
-
- }
|