【问题标题】:Add annotation to UIImageView给 UIImageView 添加注解
【发布时间】:2017-04-20 19:26:52
【问题描述】:

您会发现大量关于如何在 mapView 上添加注释的示例/库。 但我想知道是否有任何库可以向 UIImageView 添加注释。

感谢您的帮助!

【问题讨论】:

    标签: ios iphone swift uiimageview mkannotation


    【解决方案1】:

    你可以试试这个按钮和视图https://github.com/malcommac/CMPopTipView它就像一个魅力! (此代码用于按钮,但与 UIGestureRecognizer 的 uimageview 相同)

    class ViewController: UIViewController, SwiftPopTipViewDelegate {
    var roundRectButtonPopTipView: SwiftPopTipView?
    
    @IBAction func buttonAction(_ sender: UIButton) {
        // Toggle popTipView when a standard UIButton is pressed
        if let _ = roundRectButtonPopTipView {
            // Dismiss
            roundRectButtonPopTipView?.dismissAnimated(true)
            roundRectButtonPopTipView = nil
        } else {
            roundRectButtonPopTipView = SwiftPopTipView(message: "My message")
            roundRectButtonPopTipView?.delegate = self
            roundRectButtonPopTipView?.popColor = UIColor.lightGray
            roundRectButtonPopTipView?.textColor = UIColor.darkText
    
            roundRectButtonPopTipView?.presentPointingAtView(sender as! UIView, containerView: view, animated: true)
        }
    }
    
    //MARK: - SwiftPopTipViewDelegate methods
    func popTipViewWasDismissedByUser(popTipView: SwiftPopTipView) {
        // User can tap SwiftPopTipView to dismiss it
        roundRectButtonPopTipView = nil
    }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-01
      • 2013-03-31
      • 2023-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-07
      • 2013-07-03
      相关资源
      最近更新 更多