exyte / fan-menu

Menu with a circular layout based on Macaw
MIT License
728 stars 58 forks source link

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

Closed perbrondum closed 4 years ago

shipinev commented 4 years ago

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

perbrondum commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Thanks.

Per

On Jul 3, 2020, at 1:29 PM, Dmitry Shipinev notifications@github.com wrote:

 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.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.