Skip to content

@henrik /AKSingleSegmentedControl.h
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
An iPhone (Cocoa) segment control that acts like a single toggle button.
// AKSingleSegmentedControl.h
// By Henrik Nyh <http://henrik.nyh.se> 2010-05-14 under the MIT license.
// http://gist.github.com/401670
//
// A segment control that acts like a single toggle button.
#import <UIKit/UIKit.h>
@interface AKSingleSegmentedControl : UISegmentedControl {
}
- (id)initWithItem:(id)item;
@end
#import "AKSingleSegmentedControl.h"
@implementation AKSingleSegmentedControl
- (id)initWithItem:(id)item {
NSArray *a = [NSArray arrayWithObject:item];
return [super initWithItems:a];
}
- (void)setSelectedSegmentIndex:(NSInteger)toValue {
NSInteger newValue = self.selectedSegmentIndex==0 ? -1 : 0;
[super setSelectedSegmentIndex:newValue];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.