Skip to content
This repository has been archived by the owner on Feb 16, 2019. It is now read-only.

Commit

Permalink
Fix deprecation warnings in iOS 6.
Browse files Browse the repository at this point in the history
  • Loading branch information
jyap808 committed Oct 6, 2012
1 parent 4554f2c commit bdb7f74
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 1 deletion.
11 changes: 11 additions & 0 deletions SSToolkit/SSBadgeView.h
Expand Up @@ -10,6 +10,16 @@
Options for aligning the badge horizontally.
*/
typedef enum {
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0
/** Align badge along the left edge. */
SSBadgeViewAlignmentLeft = NSTextAlignmentLeft,

/** Align badge equally along both sides of the center line. */
SSBadgeViewAlignmentCenter = NSTextAlignmentCenter,

/** Align badge along the right edge. */
SSBadgeViewAlignmentRight = NSTextAlignmentRight
#else
/** Align badge along the left edge. */
SSBadgeViewAlignmentLeft = UITextAlignmentLeft,

Expand All @@ -18,6 +28,7 @@ typedef enum {

/** Align badge along the right edge. */
SSBadgeViewAlignmentRight = UITextAlignmentRight
#endif
} SSBadgeViewAlignment;

@class SSLabel;
Expand Down
4 changes: 4 additions & 0 deletions SSToolkit/SSBadgeView.m
Expand Up @@ -169,7 +169,11 @@ - (void)_initialize {
_textLabel.textColor = [UIColor whiteColor];
_textLabel.highlightedTextColor = [UIColor colorWithRed:0.125f green:0.369f blue:0.871f alpha:1.0f];
_textLabel.font = [UIFont boldSystemFontOfSize:16.0f];
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0
_textLabel.textAlignment = NSTextAlignmentCenter;
#else
_textLabel.textAlignment = UITextAlignmentCenter;
#endif

self.badgeColor = [[self class] defaultBadgeColor];
self.highlightedBadgeColor = [UIColor whiteColor];
Expand Down
10 changes: 9 additions & 1 deletion SSToolkit/SSCollectionViewItem.m
Expand Up @@ -115,12 +115,20 @@ - (id)initWithStyle:(SSCollectionViewItemStyle)style reuseIdentifier:(NSString *
if (_style != SSCollectionViewItemStyleBlank) {
if (_style == SSCollectionViewItemStyleSubtitle) {
_detailTextLabel = [[SSLabel alloc] initWithFrame:CGRectZero];
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0
_detailTextLabel.textAlignment = NSTextAlignmentCenter;
#else
_detailTextLabel.textAlignment = UITextAlignmentCenter;
#endif
[self addSubview:_detailTextLabel];
}

_textLabel = [[SSLabel alloc] initWithFrame:CGRectZero];
_textLabel.textAlignment = UITextAlignmentCenter;
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0
_textLabel.textAlignment = NSTextAlignmentCenter;
#else
_textLabel.textAlignment = UITextAlignmentCenter;
#endif
[self addSubview:_textLabel];

_imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
Expand Down
9 changes: 9 additions & 0 deletions SSToolkit/SSHUDView.m
Expand Up @@ -111,7 +111,11 @@ - (void)drawRect:(CGRect)rect {
CGRect dingbatRect = CGRectMake(roundf((_hudSize.width - dingbatSize.width) / 2.0f),
roundf((_hudSize.height - dingbatSize.height) / 2.0f),
dingbatSize.width, dingbatSize.height);
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0
[dingbat drawInRect:dingbatRect withFont:dingbatFont lineBreakMode:NSLineBreakByClipping alignment:NSTextAlignmentCenter];
#else
[dingbat drawInRect:dingbatRect withFont:dingbatFont lineBreakMode:UILineBreakModeClip alignment:UITextAlignmentCenter];
#endif
}
}

Expand Down Expand Up @@ -156,8 +160,13 @@ - (id)initWithTitle:(NSString *)aTitle loading:(BOOL)isLoading {
_textLabel.textColor = [UIColor whiteColor];
_textLabel.shadowColor = [UIColor colorWithWhite:0.0f alpha:0.7f];
_textLabel.shadowOffset = CGSizeMake(0.0f, 1.0f);
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0
_textLabel.textAlignment = NSTextAlignmentCenter;
_textLabel.lineBreakMode = NSLineBreakByTruncatingTail;
#else
_textLabel.textAlignment = UITextAlignmentCenter;
_textLabel.lineBreakMode = UILineBreakModeTailTruncation;
#endif
_textLabel.text = aTitle ? aTitle : SSToolkitLocalizedString(@"Loading...");
[self addSubview:_textLabel];

Expand Down
5 changes: 5 additions & 0 deletions SSToolkit/SSLoadingView.m
Expand Up @@ -50,8 +50,13 @@ - (void)drawRect:(CGRect)rect {
CGSize maxSize = CGSizeMake(frame.size.width - (interiorPadding * 2.0f) - indicatorSize - indicatorRightMargin,
indicatorSize);

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0
CGSize textSize = [_textLabel.text sizeWithFont:_textLabel.font constrainedToSize:maxSize
lineBreakMode:NSLineBreakByWordWrapping];
#else
CGSize textSize = [_textLabel.text sizeWithFont:_textLabel.font constrainedToSize:maxSize
lineBreakMode:UILineBreakModeWordWrap];
#endif

// Calculate position
CGFloat totalWidth = textSize.width + indicatorSize + indicatorRightMargin;
Expand Down
4 changes: 4 additions & 0 deletions SSToolkit/SSRatingPicker.m
Expand Up @@ -162,7 +162,11 @@ - (void)_initialize {
_textLabel.backgroundColor = [UIColor clearColor];
_textLabel.text = @"Tap a Star to Rate";
_textLabel.font = [UIFont boldSystemFontOfSize:10.0f];
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0
_textLabel.textAlignment = NSTextAlignmentCenter;
#else
_textLabel.textAlignment = UITextAlignmentCenter;
#endif
[self addSubview:_textLabel];
}

Expand Down
4 changes: 4 additions & 0 deletions SSToolkit/SSTextField.m
Expand Up @@ -74,7 +74,11 @@ - (void)drawPlaceholderInRect:(CGRect)rect {
}

[_placeholderTextColor setFill];
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0
[self.placeholder drawInRect:rect withFont:self.font lineBreakMode:NSLineBreakByTruncatingTail alignment:self.textAlignment];
#else
[self.placeholder drawInRect:rect withFont:self.font lineBreakMode:UILineBreakModeTailTruncation alignment:self.textAlignment];
#endif
}


Expand Down

0 comments on commit bdb7f74

Please sign in to comment.