Skip to content

模仿微信右上角的下拉弹窗,简便实现

License

Notifications You must be signed in to change notification settings

PZXforXcode/PZXPopView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

PZXPopView

模仿微信右上角的下拉弹窗,简便实现

实现代码

 import UIKit

class ViewController: UIViewController {

    private let popButton: UIButton = {
        let button = UIButton(type: .system)
        button.setTitle("菜单", for: .normal)
        button.setTitleColor(.white, for: .normal)
        button.backgroundColor = .systemBlue
        button.layer.cornerRadius = 8
        return button
    }()

    private var popView: PZXPopView?

    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .cyan

        // 配置按钮
        popButton.frame = CGRect(x: view.frame.width - 160, y: 100, width: 60, height: 40)
        popButton.addTarget(self, action: #selector(showPopView), for: .touchUpInside)
        view.addSubview(popButton)
        
        let items = [
            (UIImage(systemName: "star"), "收藏"),
            (UIImage(systemName: "square.and.arrow.up"), "分享"),
            (UIImage(systemName: "trash"), "删除")
        ]
        
         popView = PZXPopView(items: items) { index in
            print("选择了第 \(index)")
        }
    }

    @objc private func showPopView() {
        popView?.show(from: popButton)

    }
}

示例样式

19081733107364_ pic

样式可完全自定义 修改 PZXPopViewCell 即可

About

模仿微信右上角的下拉弹窗,简便实现

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages