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 do I set the size of the first icon? #56

Closed
perbrondum opened this issue May 8, 2020 · 4 comments
Closed

How do I set the size of the first icon? #56

perbrondum opened this issue May 8, 2020 · 4 comments

Comments

@perbrondum
Copy link

No description provided.

@shipinev
Copy link
Member

shipinev commented Jul 2, 2020

Hey @perbrondum. Sorry for the late response. Could you please provide more details or code related to your issue. Thanks!

@perbrondum
Copy link
Author

In the below I create a 3 item fan menu. The radius sets the span of the menu, but the original Button to activate the menu is too big on SE. How do I set the size of that item?

Thanks,

private func createFanMenu() {
fanMenu.button = FanMenuButton(
id: "main",
image: UIImage(systemName: "plus"), //"plus",
color: Color(val: 0x007AFF)
)
// position the view
// Create the leading and trailing margin constraints as always using the layoutMarginsGuide of the root view
// Use code as IB does not support connecting this declaratively
fanMenu.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
fanMenu.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 70),
// fanMenu.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 100.0),
fanMenu.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 80),
fanMenu.widthAnchor.constraint(equalToConstant: 240),
fanMenu.heightAnchor.constraint(equalToConstant: 240)
])
// Set menu items
if !GLOBAL.server {
fanMenu.items = [
FanMenuButton(
id: buttonMenu.NewEvent.rawValue,
image: UIImage(named: "eventSymbol.png"),
color: Color.clear,
title: "",
titleColor : Color.black,
titlePosition: FanMenuButtonTitlePosition.bottom
),
FanMenuButton(
id: buttonMenu.AccPlan.rawValue,
image: UIImage(named: "accSymbol.png"),
color: Color.clear
),
FanMenuButton(
id: buttonMenu.OppPlan.rawValue,
image: UIImage(named: "oppSymbol.png"),
color: Color.clear
)
]
} else {
fanMenu.items = [
FanMenuButton(
id: buttonMenu.NewEvent.rawValue,
image: UIImage(named: "eventSymbol.png"),
color: Color.clear,
title: "",
titleColor : Color.black,
titlePosition: FanMenuButtonTitlePosition.bottom
)
]
}
// Add an event handler
// call before animation
fanMenu.onItemDidClick = { button in
switch button.id {
case buttonMenu.NewEvent.rawValue:
if let vc = UIStoryboard(name: "createEvent", bundle: nil).instantiateViewController(withIdentifier: "addEvent") as? addEventViewController {
vc.completionBlock = {[weak self] dataReturned in
//Data is returned **Do anything with it **
print(dataReturned)
print("SFDC refresh was run from addEvent")
self!.eventSFDataAutoRefresh()
}
self.navigationController?.pushViewController(vc, animated:true)
}
case buttonMenu.AccPlan.rawValue:
if let vc = UIStoryboard(name: "AccPlan", bundle: nil).instantiateViewController(withIdentifier: "AccPlanViewController") as? AccPlanViewController {
self.navigationController?.pushViewController(vc, animated:true)
}
break
case buttonMenu.OppPlan.rawValue:
if let vc = UIStoryboard(name: "OppPlan", bundle: nil).instantiateViewController(withIdentifier: "OppPlanViewController") as? OppPlanViewController {
self.navigationController?.pushViewController(vc, animated:true)
}
break
default:
break
}
}
// optionally call after animation
// fanMenu.onItemWillClick = { button in
// print("ItemWillClick: (button.id)")
// }
//Configure optional parameters
// distance between button and items
fanMenu.menuRadius = 90.0
// animation duration
fanMenu.duration = 0.35
// menu opening delay
fanMenu.delay = 0.02
// Start at -90 (-Dpi/2), go to 180 (-Dpi)
fanMenu.interval = (-Double.pi/2, -Double.pi)
fanMenu.menuBackground = Color.clear
fanMenu.backgroundColor = nil
fanMenu.needsUpdateConstraints()
}

@shipinev
Copy link
Member

shipinev commented Jul 3, 2020

You can set button size by changing radius value:

fanMenu.radius = 50

But this value affects all menu items. If you want to change only the main button size, you need to subclass FanMenuScene or create a custom scene. You can take a look at CustomViewController in our example project.

@perbrondum
Copy link
Author

perbrondum commented Jul 3, 2020 via email

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