Skip to content

Commit

Permalink
custom 'add' button
Browse files Browse the repository at this point in the history
  • Loading branch information
luugiathuy committed May 15, 2013
1 parent 77160d7 commit 852879f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 16 deletions.
Binary file removed .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
*.xcuserdatad
7 changes: 6 additions & 1 deletion AwesomeMenu/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

NSArray *menus = [NSArray arrayWithObjects:starMenuItem1, starMenuItem2, starMenuItem3, starMenuItem4, starMenuItem5, starMenuItem6, starMenuItem7,starMenuItem8,starMenuItem9, nil];

AwesomeMenu *menu = [[AwesomeMenu alloc] initWithFrame:self.window.bounds menus:menus];
AwesomeMenuItem *startItem = [[AwesomeMenuItem alloc] initWithImage:[UIImage imageNamed:@"bg-addbutton.png"]
highlightedImage:[UIImage imageNamed:@"bg-addbutton-highlighted.png"]
ContentImage:[UIImage imageNamed:@"icon-plus.png"]
highlightedContentImage:[UIImage imageNamed:@"icon-plus-highlighted.png"]];

AwesomeMenu *menu = [[AwesomeMenu alloc] initWithFrame:self.window.bounds AndStartItem:startItem AndMenus:menus];

// customize menu
/*
Expand Down
2 changes: 1 addition & 1 deletion AwesomeMenu/AwesomeMenu/AwesomeMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@property (nonatomic, assign) CGFloat expandRotation;
@property (nonatomic, assign) CGFloat closeRotation;

- (id)initWithFrame:(CGRect)frame menus:(NSArray *)aMenusArray;
- (id)initWithFrame:(CGRect)frame AndStartItem:(AwesomeMenuItem*)startItem AndMenus:(NSArray *)aMenusArray;
@end

@protocol AwesomeMenuDelegate <NSObject>
Expand Down
9 changes: 3 additions & 6 deletions AwesomeMenu/AwesomeMenu/AwesomeMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ @implementation AwesomeMenu
@synthesize menusArray = _menusArray;

#pragma mark - initialization & cleaning up
- (id)initWithFrame:(CGRect)frame menus:(NSArray *)aMenusArray
- (id)initWithFrame:(CGRect)frame AndStartItem:(AwesomeMenuItem *)startItem AndMenus:(NSArray *)aMenusArray
{
self = [super initWithFrame:frame];
if (self) {
Expand All @@ -63,11 +63,8 @@ - (id)initWithFrame:(CGRect)frame menus:(NSArray *)aMenusArray

self.menusArray = aMenusArray;

// add the "Add" Button.
_addButton = [[AwesomeMenuItem alloc] initWithImage:[UIImage imageNamed:@"bg-addbutton.png"]
highlightedImage:[UIImage imageNamed:@"bg-addbutton-highlighted.png"]
ContentImage:[UIImage imageNamed:@"icon-plus.png"]
highlightedContentImage:[UIImage imageNamed:@"icon-plus-highlighted.png"]];
// assign startItem to "Add" Button.
_addButton = startItem;
_addButton.delegate = self;
_addButton.center = self.startPoint;
[self addSubview:_addButton];
Expand Down
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### DO NOT USE IT TO COPY PATH!
### DO NOT USE IT TO COPY PATH!

---

Expand All @@ -15,17 +15,23 @@ Create the menu by setting up the menu items:
UIImage *storyMenuItemImagePressed = [UIImage imageNamed:@"bg-menuitem-highlighted.png"];
UIImage *starImage = [UIImage imageNamed:@"icon-star.png"];
AwesomeMenuItem *starMenuItem1 = [[AwesomeMenuItem alloc] initWithImage:storyMenuItemImage
highlightedImage:storyMenuItemImagePressed
ContentImage:starImage
highlightedImage:storyMenuItemImagePressed
ContentImage:starImage
highlightedContentImage:nil];
AwesomeMenuItem *starMenuItem2 = [[AwesomeMenuItem alloc] initWithImage:storyMenuItemImage
highlightedImage:storyMenuItemImagePressed
ContentImage:starImage
highlightedImage:storyMenuItemImagePressed
ContentImage:starImage
highlightedContentImage:nil];

// the start item (similar to add button of Path)
AwesomeMenuItem *startItem = [[AwesomeMenuItem alloc] initWithImage:[UIImage imageNamed:@"bg-addbutton.png"]
highlightedImage:[UIImage imageNamed:@"bg-addbutton-highlighted.png"]
ContentImage:[UIImage imageNamed:@"icon-plus.png"]
highlightedContentImage:[UIImage imageNamed:@"icon-plus-highlighted.png"]];

Then, setup the menu and options:

AwesomeMenu *menu = [[AwesomeMenu alloc] initWithFrame:self.window.bounds [NSArray arrayWithObjects:starMenuItem1, starMenuItem2]];
AwesomeMenu *menu = [[AwesomeMenu alloc] initWithFrame:self.window.bounds AndStartItem:startItem AndMenus:[NSArray arrayWithObjects:starMenuItem1, starMenuItem2]];
menu.delegate = self;
[self.window addSubview:menu];

Expand Down Expand Up @@ -58,9 +64,9 @@ to set the distance between the "Add" button and Menu Items:

---

Twitter: [@LeveyZhu](https://twitter.com/#!/LeveyZhu)
Twitter: [@LeveyZhu](https://twitter.com/#!/LeveyZhu)

Sina Weibo: [@LeveyZhu](http://weibo.com/leveyzhu)
Sina Weibo: [@LeveyZhu](http://weibo.com/leveyzhu)

Thanks for [pashields](https://github.com/pashields) providing the [youtube demo](http://www.youtube.com/watch?v=vddaYMtETjo) :)

Expand Down

0 comments on commit 852879f

Please sign in to comment.