Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding default location of GodEye button #17

Closed
headcrash13 opened this issue Mar 16, 2017 · 1 comment
Closed

Overriding default location of GodEye button #17

headcrash13 opened this issue Mar 16, 2017 · 1 comment

Comments

@headcrash13
Copy link

I've got a quick patch to be able to specify (override) the default location of the GodEye button:

GodEye/Classes/Configuration/Configuration.swift

Add:

open class Configuration: NSObject {
    open private(set) var command = CommandConfiguration()
    /// default switch configuration
    open private(set) var defaultSwitch = SwitchConfiguration()
    open var location:CGPoint? // Override default location of the GodEye button
}

GodEye/Classes/UIWindow+GodEye.swift

extension UIWindow {
    
    func makeEye(with configuration:Configuration) {
        GodEyeController.shared.configuration = configuration
                .
                .
                .

Replace:

        let rect = CGRect(x: self.frame.size.width - 48, y: self.frame.size.height - 160, width: 48, height: 48)

With:

        var rect = CGRect(x: self.frame.size.width - 48, y: self.frame.size.height - 160, width: 48, height: 48)

        if let location = configuration.location {
            rect.origin = location
        }

Usage:

       let configuration = Configuration()
        configuration.location = CGPoint(x: 40.0, y: 40.0)
        GodEye.makeEye(with: self.window!, configuration: configuration)

There are cleaner ways of doing this, of course (e.g. put defaults in header, then just overwrite the x: and y: values), but I wanted to be the least intrusive as possible. :)

@zixun
Copy link
Owner

zixun commented Mar 17, 2017

Good job! GodEye button should be specify~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants