kolyvan / kxmenu Goto Github PK
View Code? Open in Web Editor NEWKxMenu is a vertical popup menu for using in iOS applications
License: BSD 2-Clause "Simplified" License
KxMenu is a vertical popup menu for using in iOS applications
License: BSD 2-Clause "Simplified" License
I really like how the Popup-menu's are done, but I'm looking for a quick and easy way to get the same look-and-feel as the default UIActionSheet, that is: a white-backgroundcolor and black textColor.
Can you give some hints where I should make the changes, or perhaps make some methods with which I can easily adopt the iOS standard look-and-feel color-scheme regarding UIActionSheet?
Thanks in advance!
I already found the solution e.g.:
and to get the blueish button colors change in the mkContentView:
When compiling under iOS 7 I receive below warning:
/KxMenu.m:423:50: 'sizeWithFont:' is deprecated: first deprecated in iOS 7.0 - Use -sizeWithAttributes:
If Gesture Recognizer is enabled in the superview, the touchesEnded
event will not be fired in KxMenuOverlay
.
As a quick fix, add a gesture recognizer in KxMenuOverlay
:
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor clearColor];
self.opaque = YES;
UITapGestureRecognizer *singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTap:)];
[self addGestureRecognizer:singleFingerTap];
}
return self;
}
- (void)singleTap:(UITapGestureRecognizer *)recognizer
{
for (UIView *v in self.subviews) {
if ([v isKindOfClass:[KxMenuView class]] && [v respondsToSelector:@selector(dismissMenu:)]) {
[v performSelector:@selector(dismissMenu:) withObject:@(YES)];
}
}
}
I want to be able to do something in my implementation when the menu is dismissed. In my particular scenario, I'm changing the background color of a row when the button to display the menu is clicked and reverting the color when the menu is dismissed by tapping anywhere (seems to be the 'SingleTap' event). It's possible that this functionality is already available and maybe I'm missing something so let me know.
Let's say if more menu items can fit with one screen - consider to make it scrollable?
Currently, it'll show the last several items which can fit one screen
It's very useful if you add a property to set items height not only calculated with font size. Cheers!
Here
https://github.com/kolyvan/kxmenu/blob/master/Source/KxMenu.m#L323
KxMenuOverlay *overlay = [[KxMenuOverlay alloc] initWithFrame:view.bounds];
view.bounds has y negative during pull-to-refresh and therefore the menu is shown the height of the pull-to-refresh area too high. Its correct in that way that it covers the whole screen with the overlay so you can click everywhere to dismiss, but the actual menu will be displaced.
The solution if you don't care that the pull-to-refresh area will not be part of the dismiss area is this instead:
``KxMenuOverlay *overlay = [[KxMenuOverlay alloc] initWithFrame:CGRectMake(0, 0, view.frame.size.width, view.frame.size.height)];`
Or if you want the whole area to be dismiss area you can adjust the supplied rect for contentOffset (here: https://github.com/kolyvan/kxmenu/blob/master/Source/KxMenu.m#L316):
if([view isKindOfClass:[UIScrollView class]]) rect = CGRectMake(rect.origin.x, rect.origin.y-((UIScrollView*)view).contentOffset.y, rect.size.width, rect.size.height);
How do I set action on individual menu items in swift 3?
Maybe I have missed this, but it seems that I can not set max width for KxMenuItem. If my menu item text is too wide, then it will extend out of the screen. Is there better solution than manually manipulate the text set into the title property?
Thanks.
When I built it for iOS 8 in the Xcode 7, it will report some errors. After checking, the header file has been wrong. The Foundation is the kit for Mac OS X, but not for iOS. So the header file importing of KxMenu.h should be UIKit/UIKit.h.
#import <UIKit/UIKit.h>
And there is some warnings for iOS 7 and later. The first is [menuItem.title sizeWithFont:[UIFont systemFount]]
in -mkContentView. It can be used as const CGSize titleSize = [menuItem.title sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}];
The second is a dismissMenu warning. It can add a declaration in the KxMenuView like this @interface KxMenuView : UIView -(void) dismissMenu:(BOOL)animated; @end
to avoid this kind of building warning.
2 'dismissMenu' selector issues.
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UIView *touched = [[touches anyObject] view];
if (touched == self) {
for (UIView *v in self.subviews) {
if ([v isKindOfClass:[KxMenuView class]]
&& [v respondsToSelector:@selector(dismissMenu:)]) {
[v performSelector:@selector(dismissMenu:) withObject:@(YES)];
}
}
}
}
Thanks for your excellent control.Are you planning to develop an OSX version?
Thanks and regards,
The popup should stay on the screen when the orientation changes from Portrait to Landscape, or any other.
Great project by the way!
On OSX-Maverick with Xcode-6.1.1 I get the following compiler warning in KxMenu.m:
"Undeclared selector 'dismissMenu:'"
this can be fixed by adding the forward definition dismissMenu on line 48 in KxMenu.m:
@interface KxMenuView : UIView
- (void)dismissMenu:(BOOL) animated;
@end
[button setBackgroundImage:[UIImage imageNamed:@"menu_selected.png"] forState:UIControlStateSelected];
when i try to set like this my image not shown
i don't know why?
i need to set image in highlighted or selected state
How can I add list items dynamically ?
can u add retina support for image in KxMenuItem
i think it will have pretty present on retina device if we have this feature
Is it possible to change the popup black/gray gradient to white?
Thanks
Instead of having the menu flash hidden / shown if the menu is already on screen it would be nice to have an isVisible property / method so I can skip reshowing the already visible menu.
I tried doing a simple bit of code checking for _menuView != nil but since that is not set back to nil when the user clicks somewhere off the menu to cancel it this does not work.
Menu needs to track / be notified of being clicked off of so it can do _menuView = nil when that happens.
Tap on a menu and nothing happens. The selector doesn't get executed.
Glad to find your repo.
Could you do a git tag, so I can make a cocoapods spec.(github.com/CocoaPods/Specs)
Thank you!
In iOS7.1 the KxMenuView background gradinet is incorrect.
How to fix it ?
Check this out:
MenuA: imageA @"stringA".
MenuB: no image @"largeStringB_asdfasdfasdf"
Result: the MenuB's width have not added the image's width. It shows "largeStringB_as..."
Expert Result: the MenuB's width have added the image's width. It shows "largeStringB_asdfasdfasdf"
How do I display fetched items from web service ?
Is there a way to change size of Menu items?
Greetings,
Thank you for this, really cool, would be awesome if we can have a podspec for this,
take a look http://cocoapods.org/
Regards
I am using your KxMenu for my app development
I need to add scroll to KxMenu
how can I add scroll?
can you help me?
Regards.
Hi,
The images used in KxMenuItem are shown as blurred ones when the view is presented (presentViewController:). But the same images are displayed properly when the view is pushed (pushViewController:). Why is it so?
the items view why not use UIScrollView
Is there a way to change border color for the entire menu?
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.