Skip to content

Commit

Permalink
Updated sample app & README.
Browse files Browse the repository at this point in the history
Add a toggle button. Updated README.
  • Loading branch information
ddebin committed Aug 20, 2011
1 parent 4c9daa5 commit f6d39f7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
26 changes: 24 additions & 2 deletions DDExpandableButtonSample/SampleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ - (void)viewDidLoad

[[[self.view viewWithTag:10] layer] setBorderColor:[UIColor blackColor].CGColor];

DDExpandableButton *colorButton = [[[DDExpandableButton alloc] initWithPoint:CGPointMake(20.0f, 70.0f)
DDExpandableButton *colorButton = [[[DDExpandableButton alloc] initWithPoint:CGPointMake(20.0f, 65.0f)
leftTitle:@"Color"
buttons:[NSArray arrayWithObjects:@"Black", @"Red", @"Green", @"Blue", nil]] autorelease];
[[self view] addSubview:colorButton];
Expand All @@ -82,7 +82,7 @@ - (void)viewDidLoad
[[colorButton.labels objectAtIndex:2] setHighlightedTextColor:[UIColor greenColor]];
[[colorButton.labels objectAtIndex:3] setHighlightedTextColor:[UIColor blueColor]];

DDExpandableButton *borderButton = [[[DDExpandableButton alloc] initWithPoint:CGPointMake(20.0f, 120.0f)
DDExpandableButton *borderButton = [[[DDExpandableButton alloc] initWithPoint:CGPointMake(20.0f, 110.0f)
leftTitle:@"Border"
buttons:[NSArray arrayWithObjects:@"Thin", @"Medium", @"Thick", nil]] autorelease];
[[self view] addSubview:borderButton];
Expand All @@ -92,6 +92,16 @@ - (void)viewDidLoad
[borderButton setUnSelectedLabelFont:[UIFont systemFontOfSize:borderButton.labelFont.pointSize]];
[borderButton updateDisplay];
[borderButton setSelectedItem:1];

DDExpandableButton *toggleButton = [[[DDExpandableButton alloc] initWithPoint:CGPointMake(20.0f, 155.0f)
leftTitle:nil
buttons:[NSArray arrayWithObjects:@"HDR On", @"HDR Off", nil]] autorelease];
[[self view] addSubview:toggleButton];
[toggleButton addTarget:self action:@selector(toggleBkgd:) forControlEvents:UIControlEventValueChanged];
[toggleButton setToggleMode:YES];
[toggleButton setInnerBorderWidth:0];
[toggleButton setHorizontalPadding:6];
[toggleButton updateDisplay];
}

- (void)viewDidUnload
Expand Down Expand Up @@ -141,6 +151,18 @@ - (void)toggleWidth:(DDExpandableButton *)sender
break;
}
}
- (void)toggleBkgd:(DDExpandableButton *)sender
{
switch ([sender selectedItem])
{
case 0:
[self.view setBackgroundColor:[UIColor grayColor]];
break;
case 1:
[self.view setBackgroundColor:[UIColor lightGrayColor]];
break;
}
}

- (void)toggleFlashlight:(DDExpandableButton *)sender
{
Expand Down
4 changes: 4 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ A DDExpandableButton has the following properties:

Use animation during button state transitions.

- `@property (nonatomic,assign) BOOL toggleMode;`

Use button as a toggle (like "HDR On" / "HDR Off" button in camera app).

- `@property (nonatomic,assign) CGFloat timeout;`

To shrink the button after a timeout. Use `0` if you want to disable timeout.
Expand Down

0 comments on commit f6d39f7

Please sign in to comment.