OCExpandableButton
A Sparrow-like expanding toolbar button in CoreAnimation.
Install / Use
/learn @ocrickard/OCExpandableButtonREADME
#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.
<p align="center"><img src="https://raw.github.com/rnystrom/OCExpandableButton/master/animation.gif"/></p>##Usage##
Usage of the control is totally simple, it works just like any other UIView:
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:
//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:
button.alignment = OCExpandableButtonAlignmentLeft;
or
button.alignment = OCExpandableButtonAlignmentRight;
You can use the delegate property in order to notify of the control's opening/closure.
@interface MyClass : NSObject <OCExpandableButtonDelegate>
...
@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?
Related Skills
node-connect
335.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
82.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
335.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
82.5kCommit, push, and open a PR
