Skip to content

Commit

Permalink
Improvements for maintaining backward compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryhjones committed Sep 3, 2013
1 parent d1a1c24 commit 9ea96f9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion SMPageControl.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ typedef NS_ENUM(NSUInteger, SMPageControlStyleDefaults) {
SMPageControlDefaultStyleModern
};

static SMPageControlStyleDefaults _defaultStyleForSystemVersion;

@interface SMPageControl ()
@property (strong, readonly, nonatomic) NSMutableDictionary *pageNames;
@property (strong, readonly, nonatomic) NSMutableDictionary *pageImages;
Expand Down Expand Up @@ -61,15 +63,28 @@ @implementation SMPageControl
@synthesize pageImageMasks = _pageImageMasks;
@synthesize cgImageMasks = _cgImageMasks;

+ (void)initialize
{
NSString *reqSysVer = @"7.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending) {
_defaultStyleForSystemVersion = SMPageControlDefaultStyleModern;
} else {
_defaultStyleForSystemVersion = SMPageControlDefaultStyleClassic;
}
}

- (void)_initialize
{
_numberOfPages = 0;
_tapBehavior = SMPageControlTapBehaviorStep;

self.backgroundColor = [UIColor clearColor];

// If the app wasn't linked against iOS 7 or newer, always use the classic style
// otherwise, use the style of the current OS.
#ifdef __IPHONE_7_0
[self setStyleWithDefaults:SMPageControlDefaultStyleModern];
[self setStyleWithDefaults:_defaultStyleForSystemVersion];
#else
[self setStyleWithDefaults:SMPageControlDefaultStyleClassic];
#endif
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SMPageControl has a variety of simple (yet powerful) areas of customization, and
* Extended Support for UIAccessibility
* iOS 7 Ready

![Screenshot](http://spacemanlabs.com/github/SMPageControl-2.2.png)
![Screenshot](http://spacemanlabs.com/github/SMPageControl-4.png) ![Screenshot](http://spacemanlabs.com/github/SMPageControl-5.png)

## Example Usage

Expand Down

0 comments on commit 9ea96f9

Please sign in to comment.