| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- //
- // QSLHomeAddFriendView.swift
- // QuickSearchLocation
- //
- // Created by Destiny on 2025/9/23.
- //
- import UIKit
- class QSLHomeAddFriendView: UIView {
-
- lazy var contentView: UIView = {
-
- let contentViewW = QSLConst.qsl_kScreenW
- let contentViewH = 365.0.rpx
- let contentView = UIView(frame: CGRect(x: 0, y: 0, width: contentViewW, height: contentViewH))
- return contentView
- }()
-
- lazy var centerImage : UIImageView = {
- let centerImage = UIImageView()
- centerImage.contentMode = .scaleAspectFit
- centerImage.image = UIImage(named: "home_friends_alert_bg")
- return centerImage
- }()
-
- lazy var titleLabel: UILabel = {
-
- let label = UILabel()
- label.text("查找好友定位")
- label.boldFont(30)
- label.textColor = QSLColor.textColor_333
- return label
- }()
-
- lazy var contentLabel: UILabel = {
-
- let label = UILabel()
- label.text("去添加Ta的好友开启守护!")
- label.font(12)
- label.textColor = .hexStringColor(hexString: "#61877F")
- return label
- }()
-
- lazy var oneButton: UIButton = {
-
- let btn = UIButton()
- btn.addRadius(radius: 22.rpx)
- btn.title("查找好友")
- btn.textColor(.white)
- btn.mediumFont(16)
- btn.gradientBackgroundColor(color1: .hexStringColor(hexString: "#15CBA1"), color2: .hexStringColor(hexString: "#1FE0BA"), width: 250.rpx, height: 44.rpx, direction: .horizontal)
- btn.addTarget(self, action: #selector(oneBtnAction), for: .touchUpInside)
- return btn
- }()
-
- lazy var hideButton: UIButton = {
- let btn = UIButton()
- btn.title("下次再说")
- btn.textColor(.init(white: 0, alpha: 0.4))
- btn.font(11)
- btn.addTarget(self, action: #selector(removeView), for: .touchUpInside)
- return btn
- }()
-
- var oneBtnClosure: (() -> ())?
-
- class func alert(view: UIView,
- clickBtnClosure: @escaping () -> () = {}) {
-
- let window = QSLHomeAddFriendView(frame: CGRect(x: 0, y: 0, width: QSLConst.qsl_kScreenW, height: QSLConst.qsl_kScreenH))
- view.addSubview(window)
- window.oneBtnClosure = clickBtnClosure
-
- UIView.animate(withDuration: 0.4, delay: 0, usingSpringWithDamping: 0.95, initialSpringVelocity: 0.05) {
- window.backgroundColor = .hexStringColor(hexString: "#000000", alpha: 0.7)
- window.contentView.isHidden = false
- }
- }
-
- override init(frame: CGRect) {
- super.init(frame: frame)
-
- initView()
- }
-
- required init?(coder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
-
-
- // 单按钮点击事件
- @objc func oneBtnAction() {
- if let oneBtnClosure = self.oneBtnClosure {
- oneBtnClosure()
- }
- removeView()
- }
-
- // 移除
- @objc func removeView() {
-
- UIView.animate(withDuration: 0.4, delay: 0, usingSpringWithDamping: 0.95, initialSpringVelocity: 0.05) { [weak self] in
- self?.backgroundColor = UIColor.init(white: 0, alpha: 0)
- self?.contentView.isHidden = true
- self?.centerImage.isHidden = true
- } completion: { [weak self] finished in
- self?.removeFromSuperview()
- }
- }
- }
- extension QSLHomeAddFriendView {
-
- func initView() {
-
- addSubview(contentView)
- contentView.snp.makeConstraints { make in
- make.size.equalTo(CGSize(width: QSLConst.qsl_kScreenW, height: 365.0.rpx))
- make.center.equalToSuperview()
- }
-
- contentView.addSubview(centerImage)
- centerImage.snp.makeConstraints { make in
- make.top.bottom.left.right.equalTo(0)
- }
-
- contentView.addSubview(titleLabel)
- titleLabel.snp.makeConstraints { make in
- make.left.equalTo(54.rpx)
- make.right.equalTo(-54.rpx)
- make.top.equalTo(22.rpx)
- make.height.equalTo(42.rpx)
- }
-
- contentView.addSubview(contentLabel)
- contentLabel.snp.makeConstraints { make in
- make.left.equalTo(54.rpx)
- make.right.equalTo(-54.rpx)
- make.top.equalTo(titleLabel.snp.bottom)
- make.height.equalTo(14.rpx)
- }
-
- contentView.addSubview(hideButton)
- hideButton.snp.makeConstraints { make in
- make.size.equalTo(CGSize(width: 60.rpx, height: 28.rpx))
- make.centerX.equalToSuperview()
- make.bottom.equalTo(-18.rpx)
- }
-
- contentView.addSubview(oneButton)
- oneButton.snp.makeConstraints { make in
- make.size.equalTo(CGSize(width: 250.rpx, height: 44.rpx))
- make.centerX.equalToSuperview()
- make.bottom.equalTo(-54.rpx)
- }
- }
- }
|