corin8823 / Popover

Popover is a balloon library like Facebook app. It is written in pure swift.
MIT License
2.11k stars 327 forks source link

Popup OriginPoint coming from TabBar for reasons? #144

Open swimnbird opened 2 years ago

swimnbird commented 2 years ago

I have a situation to where the origin of the pop over is coming from my tab bar instead of the button itself. I assume this must be because I have the button within a PageViewController. Possibly I should be using something other than 'sender.frame', but I don't know what.

    @IBAction func button1Action(_ sender: UIButton) {

        //Origin Point
        let originPoint = CGPoint(x: sender.frame.midX, y: sender.frame.maxY + 158) //(Y = down)

        let popoverView = UIView(frame: CGRect(x: 32, y: sender.bounds.maxY + 20, width: self.view.bounds.width - 64, height: 200))

        let textLabel = UILabel(frame: CGRect(x: +15, y: 0, width: popoverView.bounds.width - 15, height: popoverView.bounds.height))

        textLabel.lineBreakMode = .byWordWrapping
        textLabel.numberOfLines = 0
        textLabel.textColor = .white
        textLabel.text = "Use neutral framing of the events rather than perceptually colored language. eg:\n\n____ event occured.\n____ person said: '____'.\n____ object was altered in ____ way."
        textLabel.textAlignment = .left

        popoverView.addSubview(textLabel)

        let options: [PopoverOption] = [
            .cornerRadius(25),
            .color(.systemTeal)
        ]

        let popover = Popover(options: options)
        popover.show(popoverView, point: originPoint)

    }
swimnbird commented 2 years ago

Hello...?

Gguerrero1133 commented 2 months ago

I have a situation to where the origin of the pop over is coming from my tab bar instead of the button itself. I assume this must be because I have the button within a PageViewController.

Possibly I should be using something other than 'sender.frame', but I don't know what.


    @IBAction func button1Action(_ sender: UIButton) {

        //Origin Point

        let originPoint = CGPoint(x: sender.frame.midX, y: sender.frame.maxY + 158) //(Y = down)

        let popoverView = UIView(frame: CGRect(x: 32, y: sender.bounds.maxY + 20, width: self.view.bounds.width - 64, height: 200))

        let textLabel = UILabel(frame: CGRect(x: +15, y: 0, width: popoverView.bounds.width - 15, height: popoverView.bounds.height))

        textLabel.lineBreakMode = .byWordWrapping

        textLabel.numberOfLines = 0

        textLabel.textColor = .white

        textLabel.text = "Use neutral framing of the events rather than perceptually colored language. eg:\n\n____ event occured.\n____ person said: '____'.\n____ object was altered in ____ way."

        textLabel.textAlignment = .left

        popoverView.addSubview(textLabel)

        let options: [PopoverOption] = [

            .cornerRadius(25),

            .color(.systemTeal)

        ]

        let popover = Popover(options: options)

        popover.show(popoverView, point: originPoint)

    }