Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ocrickard/OCExpandableButton
A Sparrow-like expanding toolbar button in CoreAnimation.
https://github.com/ocrickard/OCExpandableButton
Last synced: 3 months ago
JSON representation
A Sparrow-like expanding toolbar button in CoreAnimation.
- Host: GitHub
- URL: https://github.com/ocrickard/OCExpandableButton
- Owner: ocrickard
- License: mit
- Created: 2013-05-20T01:25:45.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-09-24T00:06:21.000Z (about 11 years ago)
- Last Synced: 2024-07-20T11:06:28.416Z (4 months ago)
- Language: Objective-C
- Size: 248 KB
- Stars: 401
- Watchers: 23
- Forks: 50
- Open Issues: 2
-
Metadata Files:
- Readme: readme.markdown
- License: LICENSE
Awesome Lists containing this project
- awesome - OCExpandableButton - A Sparrow-like expanding toolbar button in CoreAnimation. (etc)
- awesome - OCExpandableButton - A Sparrow-like expanding toolbar button in CoreAnimation. (etc)
README
#OCExpandableButton#
OCExpandableButton is a VERY simple component in native Objective C that mimics the behavior of the expanding menu in the Sparrow mail app. You give it an array of subviews, and it presents them when it's activated. It is a normal subview, so you're in charge of rotation, and anything extra.
##Usage##
Usage of the control is totally simple, it works just like any other UIView:
```objc
button = [[OCExpandableButton alloc] initWithFrame:CGRectMake(self.view.bounds.size.width - 57, self.view.bounds.size.height - 57, 37, 37) subviews:subviews];
[self.view addSubview:button];
```The array of subviews will be positioned and aligned upon opening of the control. The frame for the control should be a square region. The blue "arrow" button will be inset by 4 pixels from this initial rect.
If you want to manually open/close the component (say the screen rotates, or the user begins to scroll), then you can use the following methods:
```objc
//Opens the control if the control is currently closed. No effect if the button
// is already open.
- (void)open;//Closes the control if open. No effect if already closed.
- (void)close;
```You can make the component reveal with left or right alignment using:
```objc
button.alignment = OCExpandableButtonAlignmentLeft;
```
or
```objc
button.alignment = OCExpandableButtonAlignmentRight;
```You can use the delegate property in order to notify of the control's opening/closure.
@interface MyClass : NSObject
...
@end
@implementation MyClass
...
- (void)expandableButtonClosed:(OCExpandableButton*)button
{ ... }
- (void)expandableButtonOpened:(OCExpandableButton*)button
{ ... }TODO:
- Implement inner shadows like they have in Sparrow - Not sure what the right API looks like here. Maybe just letting user specify images, or maybe using masks and drawing inner shadows manually?
- Suggestions?