tangdixi / dcpathbutton Goto Github PK
View Code? Open in Web Editor NEWA menu button like Path for iOS
Home Page: https://github.com/Tangdixi/DCPathButton
A menu button like Path for iOS
Home Page: https://github.com/Tangdixi/DCPathButton
Hello,
I try to integrate the DCPathButton into a tabbbar of a tabbarcontroller.
There is always something hidden (DCPathButton or tabbar).
I can do it with a viewvontroller and one extra tabbar, but then I have to copy the tabbar and all the segues to every involved view controller. The code turns into chaos...
How could I fit that?
Hello,
Do you have the swift code version of the same?
Cheers,
thecrazy
import UIKit
class TabController: UITabBarController, DCPathButtonDelegate{
override func viewDidLoad() {
super.viewDidLoad()
configureDCButton()
let testObject = PFObject(className: "TestObject")
testObject["foo"] = "bar"
testObject.saveInBackgroundWithBlock { (success: Bool, error: NSError?) -> Void in
println("Object has been saved.")
}
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func configureDCButton() {
// Configure center button
//
var dcPathButton: DCPathButton = DCPathButton(centerImage: UIImage(named: "chooser-button-tab"), highlightedImage: UIImage(named: "chooser-button-tab-highlighted"))
dcPathButton.delegate = self
// Configure item buttons
//
var itemButton_0: DCPathItemButton = DCPathItemButton(image: UIImage(named: "drink"), highlightedImage: UIImage(named: "drink"), backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted"))
var itemButton_1: DCPathItemButton = DCPathItemButton(image: UIImage(named: "food"), highlightedImage: UIImage(named: "food"), backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted"))
var itemButton_2: DCPathItemButton = DCPathItemButton(image: UIImage(named: "weight"), highlightedImage: UIImage(named: "weight"), backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted"))
var itemButton_3: DCPathItemButton = DCPathItemButton(image: UIImage(named: "fitness"), highlightedImage: UIImage(named: "fitness"), backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted"))
var itemButton_4: DCPathItemButton = DCPathItemButton(image: UIImage(named: "love"), highlightedImage: UIImage(named: "love"), backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted"))
var itemButton_5: DCPathItemButton = DCPathItemButton(image: UIImage(named: "time"), highlightedImage: UIImage(named: "time"), backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted"))
// Add the item button into the center button
//
dcPathButton.addPathItems([itemButton_0, itemButton_1, itemButton_2, itemButton_3, itemButton_4, itemButton_5])
// Change the bloom radius
dcPathButton.bloomRadius = 120.0
// Change the DCButton's center
dcPathButton.dcButtonCenter = CGPointMake(self.view.bounds.size.width / 2, self.view.bounds.size.height - 35.5)
self.view.addSubview(dcPathButton)
}
func itemButtonTappedAtIndex(index: UInt) {
println("You tap at index : \(index)")
}
}
Error 1: Type 'TabController' does not conform to protocol 'DCPathButtonDelegat'
Error 2: dcPathButton.delegate = self => Cannot assign a value of type 'TabControler' to a value of type 'DCPathButtonDelegate!'
This is the method of the example project:
How can I fix it?
From d723afd, the author does some enhancement on DCPathButton, however, all the working are done in Examples folder, could you fix it and update cocoapods accordingly?
如何获取pathbutton被点击的事件,我在你的类里写了通知,但是会出bug,点击后不会消失 点一下按钮就多一堆 点一下多一堆
The delegates willDismissDCPathButtonItems:
and didDismissDCPathButtonItems:
are not fired unless you tap on the center button to dismiss. I would think they also get fired when tapping on one of the button items.
Currently there is no way to trigger an action after the dismiss animation, because pathButton:clickItemButtonAtIndex:
happens on tap.
As an improvement, I suggest either:
How to increase touch area for DCPathButton?
See the below image
I'm able to implement DCPathButton in my app, thanks !! But I'm only able to show menu if my user taps on ( + ) button [see image]. Is there a way to increase touch area?
I tried, with this code that increase the area but I'm only able to touch ( + ) area.
Hi
Awesome work....
I am just wondering when you will be releasing the Swift 2.0 version.?
Thanks
I have attached a movie to show, but essentially everything sets up and looks great. There are currently two problems I have:
func setupDC(){
var img = UIImage(named: "box")
var pathButton = DCPathButton(centerImage: img, hilightedImage: img)
//pathButton.bloomRadius = 150.0
var pathHeight = pathButton.frame.height
var pathWidth = pathButton.frame.width
var pathButtonX = self.view.frame.width / 2 - pathWidth/2
var pathButtonY = CGRectGetMaxY(self.view.frame) - pathHeight
self.view.addSubview(pathButton)
var buttitem1 = DCPathItemButton(image: img, highlightedImage: img, backgroundImage: img, backgroundHighlightedImage: img)
var buttitem2 = DCPathItemButton(image: img, highlightedImage: img, backgroundImage: img, backgroundHighlightedImage: img)
var buttitem3 = DCPathItemButton(image: img, highlightedImage: img, backgroundImage: img, backgroundHighlightedImage: img)
pathButton.center = CGPointMake(pathButtonX, pathButtonY)
pathButton.frame = CGRectMake(pathButtonX, pathButtonY, pathWidth, pathHeight)
pathButton.addPathItems([buttitem1, buttitem2, buttitem3])
}
Hi there! Great work! However, I keep running into an issue when I use your lib in my swift project. I was hoping you can help?
__ERROR
/.../FoodStoryVC.swift:11:1: Type 'FStoryVC' does not conform to protocol 'DCPathButtonDelegate'
__ HEADER of my Swift file
import UIKit
class FStoryVC: UIViewController, UITableViewDelegate, UITextFieldDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UITextInputTraits, UIActionSheetDelegate, DCPathButtonDelegate { ...
__ IMPLEMENTATION
// MARK: Delegate
func itemButtonTappedAtIndex(index: Int)
{
println("You tap at index : (index)")
}
override func preferredStatusBarStyle()->(UIStatusBarStyle)
{
return UIStatusBarStyle.LightContent
}
// MARK: Buttons
func ConfigureDCPathButton() {
// Configure center button
//
var dcPathButton: DCPathButton = DCPathButton(centerImage: UIImage(named: "chooser-button-tab"), hilightedImage: UIImage(named: "hooser-button-tab-highlighted"))
dcPathButton.delegate = self
// Configure item buttons
//
var itemButton_1: DCPathItemButton = DCPathItemButton(image: UIImage(named: "chooser-moment-icon-music"), highlightedImage: UIImage(named: "chooser-moment-icon-music-highlighted"), backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted"))
var itemButton_2: DCPathItemButton = DCPathItemButton(image: UIImage(named: "chooser-moment-icon-place"), highlightedImage: UIImage(named: "chooser-moment-icon-place-highlighted"), backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted"))
var itemButton_3: DCPathItemButton = DCPathItemButton(image: UIImage(named: "chooser-moment-icon-camera"), highlightedImage: UIImage(named: "chooser-moment-icon-camera-highlighted"), backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted"))
var itemButton_4: DCPathItemButton = DCPathItemButton(image: UIImage(named: "chooser-moment-icon-thought"), highlightedImage: UIImage(named: "chooser-moment-icon-thought-highlighted"), backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted"))
var itemButton_5: DCPathItemButton = DCPathItemButton(image: UIImage(named: "chooser-moment-icon-sleep"), highlightedImage: UIImage(named: "chooser-moment-icon-sleep-highlighted"), backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted"))
// Add the item button into the center button
//
dcPathButton.addPathItems([itemButton_1, itemButton_2, itemButton_3, itemButton_4, itemButton_5])
// Change the bloom radius
dcPathButton.bloomRadius = 120.0
// Change the DCButton's center
dcPathButton.dcButtonCenter = CGPointMake(self.view.bounds.size.width / 2, self.view.bounds.size.height - 25.5)
self.view.addSubview(dcPathButton)
}
Is there a way to instantiate this from within a view controller?.
When I put it in mine It seems the alignment is way off or there is another view interfering... see the two screen shots below.. the dark overlay is the issue.
My setup is as follows:
How can I disable the sounds?
Thank you
I've found the rotation of the icons a little distracting on tap.
I was wondering if you could add a configuration option to disable rotation.
Hi,
I have a controller that implements DCPathButtonDelegate.
The number of DCPathItemButtons in it is dynamically changes.
I need to know one of the button's position (center \ origin).
Is there any getPosition method for the DCPathItemButton?
Thanks!
Here is my code :
DCPathButton *centerButton = [[DCPathButton alloc] initWithCenterImage:[UIImage imageNamed:@"dot_off"] hilightedImage:[UIImage imageNamed:@"dot_off"]];
DCPathItemButton *cameraButton = [[DCPathItemButton alloc] initWithImage:[UIImage imageNamed:@"dot_on"]];
DCPathItemButton *importButton = [[DCPathItemButton alloc] initWithImage:[UIImage imageNamed:@"dot_off"]];
[centerButton addPathItems:@[cameraButton, importButton]];
[self.view addSubview:centerButton];
It shows perfectly but when I tap a button, it even dont jump to delegate function (by breakpoint & nslog)
When push ViewControllers,how to hide or hide with tabbarcontroller together,such as "VC.hidesBottomBarWhenPushed = YES;"
Will there be a swift 3 version of this? Love this but when I upgraded to swift 3 it broke. :(
Example-Swift build fails with error <unknown>:0: error: bridging header '/Users/Tangdixi/Desktop/Example-Swift/Example-Swift-Bridging-Header.h' does not exist
I'm relatively new to swift and can't figure out what could be the problem.
Saw in your example you have DCPathButton.bottomViewColor
exposed as something that can bet set.
以上是我的粗略测试。
Would it be possible to add titles above/below/around the buttons please? :)
Thanks for this great plugin, this saved a lot of time to setup.
Could you add a property to customize the background color of the bottomView? I see the bottomview is a private property, i have no luck to change it.
Do you recommend
thanks.
So I decided to put the control into a UIToolBar. Everything seems to be as expected, but I get a really strange frame when I click the DCPathButton (currently in the centre of the view below)
Here is the code:
func createToolBar(){
var img = UIImage(named: "box")
bar.frame = CGRectMake(0, self.view.frame.height-60, self.view.frame.size.width, 60)
bar.backgroundColor = UIColor.blueColor()
var endspace = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FixedSpace, target: nil, action: nil)
endspace.width = 10
var flexspace = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: nil, action: nil)
var leftitem = UIBarButtonItem(image: img, style: UIBarButtonItemStyle.Plain, target: self, action: "mainMenu")
var rightitem = UIBarButtonItem(image: img, style: UIBarButtonItemStyle.Plain, target: self, action: "mainMenu")
//Get the view for DCPathButton
var pathView = pathMenu()
var centeritem = UIBarButtonItem(customView: pathView)
bar.setItems([endspace,leftitem,flexspace, centeritem, flexspace,rightitem, endspace], animated: true)
self.view.addSubview(bar)
}
func pathMenu()->DCPathButton{
var pathButton = DCPathButton()
var img = UIImage(named: "box")
pathButton = DCPathButton(centerImage: img, hilightedImage: img)
var buttitem1 = DCPathItemButton(image: img, highlightedImage: img, backgroundImage: img, backgroundHighlightedImage: img)
var buttitem2 = DCPathItemButton(image: img, highlightedImage: img, backgroundImage: img, backgroundHighlightedImage: img)
var buttitem3 = DCPathItemButton(image: img, highlightedImage: img, backgroundImage: img, backgroundHighlightedImage: img)
pathButton.addPathItems([buttitem1, buttitem2, buttitem3])
pathButton.delegate = self
return pathButton
}
By default, the bloom's direction is at the top of the button. What if i want to let the bloom at other direction of the button? thanks.
What do you think of letting user disabling sound if they'd like to and/or change the default sounds?
Hi there, awesome code! Quick problem, when it is used with Storyboard + UINavbar , when button is tabbed the Modal overlay is not covering the NavBar.. Autolayout issues?
Hello there,
Is there any way to expand the buttons vertically up??
For my use case this menu is going to be used regularly by power users.
As a result I'd like to speed up the animation of the menu open / close.
Could you help me the situation that one of tab in tabbar has pushed and hide the tabbar but the DCButton still there (because it added on the tabbar controller)? Do I have a solution that add the view into tabbar so when the tabbar hides, the dcbutton will hide?
Thanks in advance!
dcButtonCenter property is not found in the classes,i just add classes to pod,but property is not there
I have something like this
self.navigationItem.rightBarButtonItem = dcPathButton
When I press a button, navigation tittle and dcPathButton disappear.
I am using this control as described. but its not working. As fas as design concerns, its working but when i click on any buttonItem, it doesnot call its delegate. i am using btn.delegate = self. and adding the delegate and delegate actions as well.... plzzzz help me.
Hi,
I really loved this library! But I kinda stuck on this particular issue, I want to add this button on a tab bar instead on view (as in example) but If i had it on the Tab Bar , the DCPathItemButton seems to be unclickable, any solution to these?
CGFloat heightDifference = buttonImage.size.height - self.tabBar.frame.size.height;
CGPoint center = self.tabBar.center;
center.y = center.y - self.tabBar.frame.origin.y - heightDifference/2.0 - 8;
button.dcButtonCenter = center;
// Setting the DCButton appearance
button.allowSounds = YES;
button.allowCenterButtonRotation = NO;
button.bottomViewColor = [UIColor grayColor];
button.bloomDirection = kDCPathButtonBloomDirectionTop;
[self.tabBar addSubview:button];
Hi Tangdixi,
I really love your work on DCPathButton! However, there is a small issue: when I set hidesBottomBarWhenPushed=true before push a UIViewController to a UINavigationController, the tabBar is hidden, but DCPathButton still shows up there. Is there anyway to hide DCPathButton when hidesBottomBarWhenPushed=true?
I have set up a sample project in https://www.dropbox.com/sh/9kfbh3i0pxm3yoz/AABb-2arK7WeChkm9e8SJtY7a?dl=0. In the controller, if you click the "click me" button, the tabBar will be hide except the DCPathButton. If we pop the view, then DCPathButton disappear in the tabBar.
Thanks!
Hi,
I'm trying to use this control in my app but I'm facin some issues 👍
I tried to put the button in my view controller above a mapView, positioned with autolayout constraints
Result : the button is not clickable
I tried to put the button in a view above the mapView, I appear to be a the right place if I set it's frame to, say CGRectMake(0,0,35,35).
Result : the button is clickable but once expanded, the items are not clickable. Moreover the button goes far away from it's superview just after selecting the center button to cancel action.
Do you have any clue on how to use it properly in a storyboard app using auto layout ?
Thanks for your work anyway.
i try to make sample using DCPathButton but i found this error, i following guide on readme
I launch in Xcode 7.0.1 with IOS9 on latest OSX (El Capitan) and simulator for iPhone 6s. Portrait works fine but all other orientations the button disappears as noted in #39 and when tapping on button, the background does not shade.
pathCenterButtonBloom后,画面整体下移
currently it has:
would you help add methods for willFold and didFold? thanks man.
How to invoke DCPathButton programmtically? Is there a way to open menu programmatically.
Hi
i used your button in GMSMapview not in tap bar and delegate method - (void)itemButtonTappedAtIndex:(NSUInteger)index not called in touch event on DCPathButtonItem occurred. when debuted the code only method - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event of DCPathbutton called.
so what do you think?
Can you support button with images and text together? Currently its working good without text (title) but what if I want to show a title too. I dig into your code and have no luck to achieve this on my self.
What you think?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.