Custom Switch
I ended up create this class due to the fact that I could not change the graphics on switch, well in truth you can but god it looked like a lot of work rather than spend ten minutes rolling your own.
#import <UIKit/UIKit.h>
// --------------------------------------------
// Custom switch object
// --------------------------------------------
@interface CustomSwitch : UIView
{
@private
UIImageView * background;
UIImageView * button;
UILabel * activeText;
UILabel * inactiveText;
CGPoint activeCenter;
CGPoint inactiveCenter;
Boolean active;
id delegate;
SEL selector;
CGPoint touch;
}
@property Boolean active;
@property (nonatomic, copy) NSString * textActive;
@property (nonatomic, copy) NSString * textInactive;
@property (nonatomic, retain) UIFont * font;
@property (nonatomic, retain) UIColor * textColor;
@property (nonatomic, retain) UIColor * textHighlightedColor;
@property (nonatomic, retain) UIColor * textShadowColor;
@property (nonatomic) CGSize textShadowOffset;
@property (nonatomic, retain) UIImage * backgroundImage;
@property (nonatomic, retain) UIImage * buttonImage;
- (void) setDelegate:(id)_delegate WithSelector:(SEL)_selector;
@end
// --------------------------------------------
This implementation could be improved by deriving the main class off a UIImageView this would save the need to create the background image object, saves on implementation and the need for adding another sub view. At the time I was not really worried about it and this is a first and only implementation I’ve done.
Source Code : CustomSwitch.h, CustomSwitch.m


