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

How can I change the position of ActionButton #17

Open
imadeit opened this issue Feb 9, 2016 · 3 comments
Open

How can I change the position of ActionButton #17

imadeit opened this issue Feb 9, 2016 · 3 comments

Comments

@imadeit
Copy link

imadeit commented Feb 9, 2016

Hi,

Thanks dude, you have created a nice tool!
I have read the source code that the position for ActionButton is fixed at bottom right of current screen, not be able to adjust the position, so if someone uses Action in a Tab pattern App., the ActionButton can be hidden by the Tab Controller.
So I guess whether you can add parameters in the initializer or create a helper method for changing the layout parameters.

I tried to change the init method to:
public init(attachedToView view: UIView, items: [ActionButtonItem]?, tailingOffset: CGFloat = 15.0, bottomOffset: CGFloat = 15.0) {
......
self.installConstraints(tailingOffset, bottomOffset: bottomOffset)
}

private func installConstraints(tailingOffset: CGFloat = 15.0, bottomOffset: CGFloat = 15.0) {
......
let trailingSpacing = NSLayoutConstraint.constraintsWithVisualFormat("V:[floatButton]-(tailingOffset)-|", options: NSLayoutFormatOptions.AlignAllCenterX, metrics: nil, views: views)
let bottomSpacing = NSLayoutConstraint.constraintsWithVisualFormat("H:[floatButton]-(bottomOffset)-|", options: NSLayoutFormatOptions.AlignAllCenterX, metrics: nil, views: views)
......
}

Hope you can change for some customization.

Thanks

Leon

@djdance
Copy link

djdance commented Jan 29, 2017

plus one to imadeit
screen shot 2017-01-29 at 12 21 07_cr

@djdance
Copy link

djdance commented Jan 29, 2017

two mistakes:

I got

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse constraint format: 
Encountered metric with name "tailingOffset", but value was not specified in metrics or views dictionaries 
V:[floatButton]-(tailingOffset)-| 
                              ^'

So,

  1. change "V:[floatButton]-(tailingOffset)-|" to "V:[floatButton]-(\(tailingOffset))-|" etc
  2. exchange to bottomOffset for V, and tailingOffset for H

@anudeep94
Copy link

@djdance

Could you share the changes.. ? cause i'm getting an error..

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

3 participants