regexident / dlwidgetmenu Goto Github PK
View Code? Open in Web Editor NEWVersatile solution for displaying widget menus. Easily adjustable with custom layouts and/or animations.
License: Other
Versatile solution for displaying widget menus. Easily adjustable with custom layouts and/or animations.
License: Other
when using your demo, I moved the menu up and the menu items appear UNDER the sliders.
Hi, I have just tried to implement this and I could really do with some implementation instructions.
Whats the simplest way to add this to a view? I've looked at the demo but can't get it to work. I've added these from your demo.
In viewdidLoad:
CGRect frame = self.view.bounds;
id<DLWMMenuLayout> layout = [[DLWMRadialLayout alloc] initWithRadius:60.0 arc:DLWMFullCircle angle:0.0 minDistance:0.0];;
DLWMMenu *menu = [[DLWMMenu alloc] initWithMainItemView:self.view
dataSource:self
itemSource:self
delegate:self
itemDelegate:self
layout:layout
representedObject:self];
menu.openAnimationDelayBetweenItems = 0.01;
menu.closeAnimationDelayBetweenItems = 0.01;
menu.center = CGPointMake(CGRectGetMidX(frame), CGRectGetMaxY(frame) * 0.66);
self.menu = menu;
[self.view insertSubview:menu atIndex:0];
Then I add:
#pragma mark - DLWMMenuDataSource Protocol
- (NSUInteger)numberOfObjectsInMenu:(DLWMMenu *)menu {
return 5;
}
- (id)objectAtIndex:(NSUInteger)index inMenu:(DLWMMenu *)menu {
return @(index);
}
#pragma mark - DLWMMenuItemSource Protocol
+ (UIView *)menuItemView {
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 40.0, 40.0)];
view.layer.borderColor = [UIColor colorWithWhite:1.0 alpha:0.75].CGColor;
view.layer.borderWidth = 1.5;
view.layer.shadowColor = [UIColor blackColor].CGColor;
view.layer.shadowOffset = CGSizeMake(0.0, 1.5);
view.layer.shadowOpacity = 0.5;
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
gradientLayer.frame = view.layer.bounds;
gradientLayer.colors = @[(__bridge id)[UIColor colorWithWhite:1.0 alpha:0.5].CGColor,
(__bridge id)[UIColor colorWithWhite:1.0 alpha:0.1].CGColor,
(__bridge id)[UIColor colorWithWhite:1.0 alpha:0.0].CGColor,
(__bridge id)[UIColor colorWithWhite:1.0 alpha:0.2].CGColor];
gradientLayer.locations = @[@0.0, @0.49, @0.5, @1.0];
[view.layer addSublayer:gradientLayer];
return view;
}
- (UIView *)viewForMainItemInMenu:(DLWMMenu *)menu {
UIView *view = [[self class] menuItemView];
view.bounds = CGRectMake(0.0, 0.0, 50.0, 50.0);
view.backgroundColor = [UIColor lightGrayColor];
view.layer.cornerRadius = 25.0;
CAGradientLayer *gradientLayer = (CAGradientLayer *)view.layer.sublayers[0];
gradientLayer.cornerRadius = view.layer.cornerRadius;
gradientLayer.frame = view.layer.bounds;
return view;
}
- (UIView *)viewForObject:(id)object atIndex:(NSUInteger)index inMenu:(DLWMMenu *)menu {
UIView *view = [[self class] menuItemView];
view.bounds = CGRectMake(0.0, 0.0, 40.0, 40.0);
CGFloat hue = ((1.0 / [self numberOfObjectsInMenu:menu]) * index);
view.backgroundColor = [UIColor colorWithHue:hue saturation:1.0 brightness:1.0 alpha:1.0];
view.layer.cornerRadius = 20.0;
CAGradientLayer *gradientLayer = (CAGradientLayer *)view.layer.sublayers[0];
gradientLayer.cornerRadius = view.layer.cornerRadius;
gradientLayer.frame = view.layer.bounds;
return view;
}
When I run it, it runs really slow then eventually stops on the insertSubview
line, even when I have global breakpoints switched off.
Hello.
I'm trying to implement a radial menu where you could tap and hold the menu, which will open the menu and close it when the finger is lifted. The implementation works almost entirely, other than if you
lift your finger, while the menu is still opening, and immediately tap and hold the menu (and drag) it again. This results in the menu (or the mainItem of the menu) to bounce to the centre of the frame.
The following is my implementation. [self checkHitTarget] simply checks which item DLWMMenuItem is selected.
- (void)receivedPan:(UIPanGestureRecognizer *)recognizer onItem:(DLWMMenuItem *)item inMenu:(DLWMMenu *)menu {
switch (recognizer.state) {
case UIGestureRecognizerStateBegan:
if ([menu isClosedOrClosing]) {
[self.menu open];
}
break;
case UIGestureRecognizerStateChanged:
[self checkHitTarget];
case UIGestureRecognizerStateEnded:
case UIGestureRecognizerStateCancelled:
case UIGestureRecognizerStateFailed:
if ([menu isOpenedOrOpening]){
if (item == menu.mainItem){
[self.menu close];
} else {
[menu closeWithSpecialAnimator:[[DLWMSelectionMenuAnimator alloc]init] forItem:item];
}
}
break;
default:
break;
}
}
I've tried going through most of the DLWMMenu implementation dropping break points everywhere, but I still can't pinpoint the exact place it'll break. I'm guessing it's something to do with the state of the menu while the menu is animating (closing or opening)
The state is not examined in the recognizer so it fires on begin and end. I am using it as a toggle without closing the menu. My workaround code for now is to just fire on StateBegan:
- (void)receivedLongPress:(UILongPressGestureRecognizer *)recognizer {
if (!self.enabled) {
return;
}
if ([recognizer state] == UIGestureRecognizerStateBegan){
if ([self.delegate respondsToSelector:@selector(receivedLongPress:onItem:inMenu:)]) {
[self.delegate receivedLongPress:recognizer onItem:(DLWMMenuItem *)recognizer.view inMenu:self];
}
}
}
when I click on the main menu item, the time for the animation to start (expand,contract) is too long for my tastes. how can I shorten that duration?
not a bug, just not obvious where to change.
I am struggling to animate a long press touch from the delegate. The Animators require an index that is not readily available in the delegate for the long press. In your demo code you could show hiding it in a view Tag. I am using the represented object for my own data lookup.
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.