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

Flash of the last button. #4

Open
HarishHary opened this issue Dec 18, 2016 · 3 comments
Open

Flash of the last button. #4

HarishHary opened this issue Dec 18, 2016 · 3 comments

Comments

@HarishHary
Copy link

Hello, I am using your framework to create a spread button. But seem like you have an issue with the buttons. When I spread-in the buttons, there is a flash of the last added button on the left-up corner, just below the status bar.
Do you know why ?

Here is the code that I used like you did.

`func setup_spread_button()
{
let btn1 = SpreadSubButton(backgroundImage: UIImage(named: "edit"), highlightImage: UIImage(named: "edit")) { (index, sender) -> Void in
print("first")
}

    let btn2 = SpreadSubButton(backgroundImage: UIImage(named: "delete_user"), highlightImage: UIImage(named: "delete_user")) { (index, sender) -> Void in
        print("second")
    }
    
    let btn3 = SpreadSubButton(backgroundImage: UIImage(named: "blocked"), highlightImage: UIImage(named: "blocked")) { (index, sender) -> Void in
        print("third")
    }
    
    let btn4 = SpreadSubButton(backgroundImage: UIImage(named: "share"), highlightImage: UIImage(named: "share")) { (index, sender) -> Void in
        print("four")
    }
    
    let btn5 = SpreadSubButton(backgroundImage: UIImage(named: "logout"), highlightImage: UIImage(named: "logout")) { (index, sender) -> Void in
        print("five")
    }

    

    let spreadButton = SpreadButton(image: UIImage(named: "setting"),
                                    highlightImage: UIImage(named: "setting"),
                                    position: CGPoint(x: 40, y: UIScreen.main.bounds.height - 40))
    self.spreadButton = spreadButton
    
    spreadButton?.setSubButtons([btn1, btn2, btn3, btn4, btn5])
    spreadButton?.mode = SpreadMode.spreadModeFlowerSpread
    spreadButton?.direction = SpreadDirection.spreadDirectionLeftDown
    spreadButton?.radius = 100
    spreadButton?.positionMode = SpreadPositionMode.spreadPositionModeTouchBorder
    
    /*  and you can assign a newValue to change the default
     spreadButton?.animationDuring = 0.2
     spreadButton?.animationDuringClose = 0.25
     spreadButton?.radius = 180
     spreadButton?.coverAlpha = 0.3
     spreadButton?.coverColor = UIColor.yellowColor()
     spreadButton?.touchBorderMargin = 10.0
     */

    
    if spreadButton != nil {
        self.view.addSubview(spreadButton!)
    }
}

`

Regards,

Hary

@shirakaba
Copy link

I'm still having the same problem as you; using liuzhiyi1992's source code:
我到现在还是存在和你一样的问题。用liuzhiyi1992的源码

func runWithObjcCode(){
    let zySpreadButton = ZYSpreadButton(backgroundImage: UIImage(named: "powerButton"), highlight: UIImage(named: "powerButton_highlight"), position: CGPoint(x: 40, y: UIScreen.main.bounds.height - 40))
    
    let btn1 = ZYSpreadSubButton(backgroundImage: UIImage(named: "clock"), highlight: UIImage(named: "clock_highlight")) { (index, sender) -> Void in
        print("first button be clicked!!!")
    }
    let btn2 = ZYSpreadSubButton(backgroundImage: UIImage(named: "pencil"), highlight: UIImage(named: "pencil_highlight")) { (index, sender) -> Void in
        print("second button be clicked!!!")
    }
    
    zySpreadButton?.subButtons = [btn1, btn2]
    zySpreadButton?.mode = SpreadModeSickleSpread
    zySpreadButton?.direction = SpreadDirectionRightUp
    zySpreadButton?.radius = 45
    zySpreadButton?.positionMode = SpreadPositionModeTouchBorder
    
    zySpreadButton?.buttonWillSpreadBlock = { print("\($0?.frame.maxY) will spread") }
    zySpreadButton?.buttonDidSpreadBlock = { _ in print("did spread") }
    zySpreadButton?.buttonWillCloseBlock = { _ in print("will closed") }
    zySpreadButton?.buttonDidCloseBlock = { _ in print("did closed") }
    
    if zySpreadButton != nil {
        self.view.addSubview(zySpreadButton!)
    }
}

When I click the main button of an 'open' Spreadbutton, as the SpreadButton contracts, the first subSpreadButton added to the SpreadButton will briefly flash in the top-left corner of the screen. Notably, however, when clicking any of the subSpreadButtons to close it, no flashing is experienced (this may be due to stevomit's commit).
在我点击主体按钮时,当它收缩隐藏的时候,我第一次加入的子按钮的初始形状会在屏幕左上方出现一瞬间;
但当我点击子按钮的时候,却没有出现这样的问题。

@shirakaba
Copy link

(It looks like stevomit's fix hasn't been pulled into the main branch – that might be all that's needed to close this issue)!

@shirakaba
Copy link

I can confirm now that stevomit's commit above DOES solve the problem for my supplied code. I'll ask if he can submit a pull request.

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

No branches or pull requests

2 participants