friend-lga / lgplusbuttonsview Goto Github PK
View Code? Open in Web Editor NEWiOS implementation of Floating Action Button (Google Plus Button, fab), that shows more options
License: MIT License
iOS implementation of Floating Action Button (Google Plus Button, fab), that shows more options
License: MIT License
Hi! I love how simple your library is. My issue is that I'm not using the button for a menu, but just as an appearing and disappearing floating button. I would like to have it bottom-centered, but because of the set ENUM, I can't figure out how to center it. Would this just need to have a new case for bottom center or is there something I can do without modifying the code?
how to show buttons horizontally
Try to set Shadow offset to non-centered value on Y scale, e.g.
UIImage *circleImageNormal = [LGDrawer drawEllipseWithImageSize:
....
shadowOffset:CGPointMake(0, 2);
shadowBlur:shadowBlur];
[_plusButtonsView setButtonsImage:circleImageNormal forState:UIControlStateNormal];
When Plus button is pressed the shadow rotates 45 degrees with it:
Therefore button graphics shadow works only if it's perfectly centered.
Shadow needs to be property of LGPlusButtonsView, not part of button graphics.
e.g.
_plusButtonsView.shadowOffset=
_plusButtonsView.shadowColor=
_plusButtonsView.shadowBlur=
Hi,
I want to add a floating button somewhere in the view. There are only 4 options.
-LGPlusButtonsViewPositionBottomRight
-LGPlusButtonsViewPositionBottomLeft
-LGPlusButtonsViewPositionTopRight
-LGPlusButtonsViewPositionTopLeft
I need to add button at the point-for example : CGPointMake(100, 100)-.Is there any
solition for this situation.
Best Regards,
Yigit.
As the coding written now,
I need to scroll for a short distance in order to show/hide the button
Is there any method to change the sensitivity of the button
(just like the offsetY swipe for 5.0f to hide/show)
Thank You
There is a UX issue when your scroll view content size is smaller or equal to viewport.
For example Table view with no rows or only couple of rows. User pulls the Scroll/Table view and view bounces, scroll event fires and button disappears.
Plus button in this case must stay on screen to allow user to add items.
I try to add plus button on the bottom-right like demo code.
When I tap on plus button or any where, the buttons will be dismiss.
But on iPhone X doesn't work, just show log with index = 0.
How can I use LGPlusButtonsView
as simple button without any rotation, showing buttons on tap? Something like that is needed: bernikowich-cedoni@7f72119
If button 0 is not larger than other buttons, unwanted offset is introduced.
How to reproduce:
Do not set larger size for buttonAtIndex:0
comment out in Demo project PlusViewController.m:84
[_plusButtonsViewMain setButtonAtIndex:0 size:CGSizeMake(56.f, 56.f)
to
// [_plusButtonsViewMain setButtonAtIndex:0 size:CGSizeMake(56.f, 56.f)
Result : buttons 1-3 have unwanted offset left relative to button 0:
Hi all, I inherited an Objective-C project which uses LGPlusButtons.
It behaves like this: there is a main button which, once tapped, reveals two sub-buttons, so user can choose between a couple of actions.
But there is one problem: The whole hotspot area is active, even where the sub-buttons will be, but before main button is tapped and these sub-buttons are visible, which makes a much bigger tappable area when that area should still be not active, leading to unwanted behavior.
I have read docs and class ref. and I can't find a property to be able to set or a way to control that behavior.
Thanks a lot for any help.
I'm trying to implement this in my project, but when I use it with UIView the buttons paper in the topright corner his is correct but I need to display them under the toprightcorner
How can I inset or change the position of the buttons programmatically? (one way is to create a uview with size 1x1 and link it to that but that's not pretty)
I can't really access the source
I have a LGPlusButtonsView in the navigation rightBarButtonItem.
when I call the method [_plusButtonsViewNavBar hideAnimated:YES completionHandler:nil];
but touch the position of button also can actionHandler then log the title, description, index .
Then I download the sample code also have same problem ..
now I just remove the LGPlusButtonsView when I call the method [_plusButtonsViewNavBar hideAnimated:YES completionHandler:nil];
and initialize when I use them , I think this's not make sense way ><
I was trying to implement blur effect for overlay, but it seems like it may require significant refactoring of initialization.
Header:
@property (assign, nonatomic) BOOL useCoverBlurEffect;
@property (assign, nonatomic) UIBlurEffectStyle coverBlurEffect;
init:
- (instancetype)initWithNumberOfButtons:(NSUInteger)numberOfButtons
firstButtonIsPlusButton:(BOOL)firstButtonIsPlusButton
showAfterInit:(BOOL)showAfterInit
useCoverBlurEffect:(BOOL)useCoverBlurEffect
{
self = [super init];
if (self)
{
.....
_coverView = [UIView new];
if (useCoverBlurEffect) {
self.useCoverBlurEffect=useCoverBlurEffect;
UIBlurEffect * effect = [UIBlurEffect effectWithStyle:_coverBlurEffect];
_coverView = [[UIVisualEffectView alloc] initWithEffect:effect];
}
_coverView.backgroundColor = [UIColor clearColor];
_coverView.userInteractionEnabled = YES;
[self addSubview:_coverView];
this works if we pass yet another parameter to init and its gets really messy. maybe we can move inititlization of drawing to another method and call it after event moveToSuperView
or something like that?
Like in Material design it's essential have option to have app screen covered with transparent white or blur overlay when button is tapped. (https://www.google.com/design/spec/components/buttons-floating-action-button.html)
This lets user easily focus on buttons and separate buttons from content.
Tapping on overlay hides the buttons and overlay.
XCode 7 says that there is no umbrella header.
No matter what I try buttons always come up with blank face without assigned images.
[_plusButtonsView setButtonsImages:@[[UIImage imageNamed:@"add-symbol"],[UIImage imageNamed:@"calendar-1"],[UIImage imageNamed:@"calendar-1"],[UIImage imageNamed:@"calendar-1"]] forState:UIControlStateNormal];
Are there any special requirements about images, like they have to be particular dimensions?
Will be great if we ca have Demo to include some example with images.
how can I achieve this?
for button in plusButtonView.buttons
{
switch plusButtonView.descriptions
{
case "Current Location": button.setImage(UIImage(named: "currentLocation"), forState: UIControlState.Normal)
case "Global": button.setImage(UIImage(named: "global"), forState: UIControlState.Normal)
case "Friends": button.setImage(UIImage(named: "friends"), forState: UIControlState.Normal)
default: println("something went wrong along the way");
}
}
this didn't do anything at all
It is possible to close the menu dynamically but the first button remains in "cross" state. How can I make it return "plus" state?
pls)
Looks like accidentally removed in 1.0.7
How do I set the icon/image inside each button in Objective-C? Cannot seem to get it to work :(
The button does not collapse on scroll. The opened buttons stay open. I could not find how to make them hide. Am I missing something?
If it's not built-in function, this is a significant UX problem. Nobody ever need those buttons stay open while parent view is scrolling. I think such functionality should be part of LGPlusButtons rather than coding manually hooking up to scroll event.
Guys, sorry, but now I totally don't have enough time to support my repositories. If somebody want to participate I will glad to add him.
And one more thing. If you really want to collaborate, prove your interesting in this library. Star it, fork it, make some issues, pull request. Show me that you understand how it works inside. Or if you do not create any pull request, but really want to improve this library, show me some your ios code and let me see your level.
I would like to add tap feature on the description label.
So that I can either click the button or label to trigger the function.
But as if I add the UITapGestureRecognizer on the description, it is not working
Would you mind help me have a check for the method?
- (void)setDescriptionsTap
{
for (NSUInteger i=0; i<_descriptionsArray.count; i++)
{
[_descriptionsArray[i] setUserInteractionEnabled:true];
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(buttonActionForTap:)];
tapGesture.delegate = self;
[tapGesture.view setTag:i];
[_descriptionsArray[i] addGestureRecognizer:tapGesture];
}
}
Very nice implementation of "Floating Action Button (fab)". You should make it easier to find.
When it's added to TabBar, the scrollview extends under tab bar but it's scrollbars inset is within the viewport above TabBar.
Scrollbar does not extend under the TabBar. Scrollable area inset is known, PlusButton is expected to appear in that inset area.
Yes, we could fix it by setting:
self.plusButtonsView.offset = CGPointMake(0.f, -50.f);
But this is merely a workaround and may be broken in the future when different device and tabBar sizes introduced.
Expected: PlusButtons adjust inset according to observed scroll views scroll insets:
Hey, I really like your project!
I experienced a bug when trying to add the demo code to my project here (the commented part):
LGPlusButtonsView *buttonTwo;
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
buttonTwo = [LGPlusButtonsView plusButtonsViewWithNumberOfButtons:4
firstButtonIsPlusButton:YES
showAfterInit:YES
actionHandler:^(LGPlusButtonsView *plusButtonView, NSString *title, NSString *description, NSUInteger index)
{
NSLog(@"actionHandler | title: %@, description: %@, index: %lu", title, description, (long unsigned)index);
//if (index == 0)
//[buttonTwo hideAnimated:YES completionHandler:nil];
}];
If i uncomment the code then the plus button shows up on the bottom right but disappears once you click it.
Change the code to something like this, to add less confusion:
LGPlusButtonsView *buttonTwo;
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
buttonTwo = [LGPlusButtonsView plusButtonsViewWithNumberOfButtons:4
firstButtonIsPlusButton:YES
showAfterInit:YES
actionHandler:^(LGPlusButtonsView *plusButtonView, NSString *title, NSString *description, NSUInteger index)
{
//This will log the button click for the Floating Button
//NSLog(@"actionHandler | title: %@, description: %@, index: %lu", title, description, (long unsigned)index);
if (index == 0){
//[buttonTwo hideAnimated:YES completionHandler:nil];
}else if (index == 1){
}else if (index == 2){
}else if (index == 3){
}else if (index == 4){
}else if (index == 5){
}else if (index == 6){
}
}];
I want the user to enter a value into a UITextField after the + button is clicked,
I tried to implement methods that are similar to setting the setButtonsImages
I wrote the following methods in the Demo :
//in LGPlusButtonsView.m
- (void)setTextsField:(UITextField *)field forState:(UIControlState)state forOrientation:(LGPlusButtonsViewOrientation)orientation
{
for (LGPlusButton *button in _buttonsArray)
[button setTextField:field forState:state forOrientation:orientation];
[self setNeedsLayout];
}
- (void)setTextsFields:(NSArray *)fields forState:(UIControlState)state
forOrientation:(LGPlusButtonsViewOrientation)orientation
{
NSAssert(_buttonsArray.count == fields.count, kLGPlusButtonsViewAssertionWarning(@"fields"));
for (NSUInteger i=0; i<_buttonsArray.count; i++)
if ([fields[i] isKindOfClass:[UITextField class]])
[_buttonsArray[i] setTextField:fields[i] forState:state forOrientation:orientation];
[self setNeedsLayout];
}
// in LGPlusButton.m
@property (strong, nonatomic) NSMutableDictionary *fieldsDictionary;
- (void)setTextField:(UITextField *)field forState:(UIControlState)state forOrientation:(LGPlusButtonsViewOrientation)orientation
{
[_fieldsDictionary setObject:field forKey:[LGPlusButtonsViewShared stringFromState:state andOrientation:orientation]];
if (orientation == LGPlusButtonsViewOrientationAll)
{
[_fieldsDictionary setObject:field forKey:[LGPlusButtonsViewShared stringFromState:state andOrientation:LGPlusButtonsViewOrientationPortrait]];
[_fieldsDictionary setObject:field forKey:[LGPlusButtonsViewShared stringFromState:state andOrientation:LGPlusButtonsViewOrientationLandscape]];
}
[self setNeedsLayout];
}
this is how I used them
//in PlusScrollViewController.m
UITextField *uit=[UITextField alloc];
uit.text=@"Enter Mobile Number";
uit.minimumFontSize=20;
[_plusButtonsViewMain setTextsField:uit
forState:UIControlStateNormal
forOrientation:LGPlusButtonsViewOrientationAll];
the app runs but I don't see the label at all
can you please help me out? if it can be done in another way such as in opening up another View please provide the instructions
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.