From 3c9fc11f2a6766fe2e7f03a6d90a3fbcd781bbe9 Mon Sep 17 00:00:00 2001 From: Zhang Yungui Date: Wed, 14 May 2014 11:20:54 +0800 Subject: [PATCH 1/8] iOS 7 Compiler warning fix for NSString drawing. Not call deprecated NSString additions methods for iOS 7. --- Brushes.xcodeproj/project.pbxproj | 6 ++++++ Classes/NSString+Drawing.h | 21 ++++++++++++++++++++ Classes/NSString+Drawing.m | 33 +++++++++++++++++++++++++++++++ Classes/WDBar.m | 9 +++++---- Classes/WDBlendModePicker.m | 6 ++++-- Classes/WDCanvasController.m | 10 +++++++--- Classes/WDMenu.m | 5 ++++- 7 files changed, 80 insertions(+), 10 deletions(-) create mode 100644 Classes/NSString+Drawing.h create mode 100644 Classes/NSString+Drawing.m diff --git a/Brushes.xcodeproj/project.pbxproj b/Brushes.xcodeproj/project.pbxproj index 2c2dc71..a26e91a 100755 --- a/Brushes.xcodeproj/project.pbxproj +++ b/Brushes.xcodeproj/project.pbxproj @@ -405,6 +405,7 @@ 6BF9986815A67C7100AFBB3A /* merge@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6BF9986615A67C7000AFBB3A /* merge@2x.png */; }; 6BF9986F15A776EC00AFBB3A /* WDCellSelectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BF9986E15A776EC00AFBB3A /* WDCellSelectionView.m */; }; 6BFA802C1249CEDB00D1749C /* WDLayerCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6BFA802B1249CEDB00D1749C /* WDLayerCell.m */; }; + AE815F8E19231421003D7056 /* NSString+Drawing.m in Sources */ = {isa = PBXBuildFile; fileRef = AE815F8D19231421003D7056 /* NSString+Drawing.m */; }; C01FCF5008A9545400542486 /* WDSynchronizer.m in Sources */ = {isa = PBXBuildFile; fileRef = C01FCF5008A9545400542485 /* WDSynchronizer.m */; }; C01FCF5008A954540054248D /* WDAddLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = C01FCF5008A954540054248C /* WDAddLayer.m */; }; C01FCF5008A9545400542490 /* WDDeleteLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = C01FCF5008A954540054248F /* WDDeleteLayer.m */; }; @@ -972,6 +973,8 @@ 6BF9986E15A776EC00AFBB3A /* WDCellSelectionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WDCellSelectionView.m; sourceTree = ""; }; 6BFA802A1249CEDB00D1749C /* WDLayerCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WDLayerCell.h; sourceTree = ""; }; 6BFA802B1249CEDB00D1749C /* WDLayerCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WDLayerCell.m; sourceTree = ""; }; + AE815F8C19231421003D7056 /* NSString+Drawing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Drawing.h"; sourceTree = ""; }; + AE815F8D19231421003D7056 /* NSString+Drawing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Drawing.m"; sourceTree = ""; }; C01FCF5008A9545400542484 /* WDSynchronizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WDSynchronizer.h; sourceTree = ""; }; C01FCF5008A9545400542485 /* WDSynchronizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WDSynchronizer.m; sourceTree = ""; }; C01FCF5008A9545400542487 /* WDDocumentChange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WDDocumentChange.h; sourceTree = ""; }; @@ -1591,6 +1594,8 @@ 6BCD535F1240001D002FCB27 /* Additions */ = { isa = PBXGroup; children = ( + AE815F8C19231421003D7056 /* NSString+Drawing.h */, + AE815F8D19231421003D7056 /* NSString+Drawing.m */, 5D1CF74B138C7BAB008979B3 /* DBMetadata+Additions.h */, 5D1CF74C138C7BAB008979B3 /* DBMetadata+Additions.m */, 6B40CD92181FCFFE00004FB2 /* NSArray+Additions.h */, @@ -2354,6 +2359,7 @@ 6B40CE3E181FD10F00004FB2 /* WDStampGenerator.m in Sources */, 6B5F0F5C1600289A00E44FB8 /* WDStylusController.m in Sources */, 6B5F0F611600447B00E44FB8 /* WDStylusManager.m in Sources */, + AE815F8E19231421003D7056 /* NSString+Drawing.m in Sources */, 6B966406160BF35700B9734A /* WDStylusTableCell.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Classes/NSString+Drawing.h b/Classes/NSString+Drawing.h new file mode 100644 index 0000000..5b02302 --- /dev/null +++ b/Classes/NSString+Drawing.h @@ -0,0 +1,21 @@ +// +// NSString+Drawing.h +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. +// +// Copyright (c) 2014 Zhang Yungui +// + +#ifndef __IPHONE_7_0 +#import + +@interface NSString (NSStringDrawing) + +- (CGSize)sizeWithAttributes:(NSDictionary *)attrs; +- (void)drawAtPoint:(CGPoint)point withAttributes:(NSDictionary *)attrs; +- (void)drawInRect:(CGRect)rect withAttributes:(NSDictionary *)attrs; + +@end +#endif diff --git a/Classes/NSString+Drawing.m b/Classes/NSString+Drawing.m new file mode 100644 index 0000000..0d43318 --- /dev/null +++ b/Classes/NSString+Drawing.m @@ -0,0 +1,33 @@ +// +// NSString+Drawing.m +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. +// +// Copyright (c) 2014 Zhang Yungui +// + +#ifndef __IPHONE_7_0 +#import "NSString+Drawing.h" + +@implementation NSString (NSStringDrawing) + +- (CGSize)sizeWithAttributes:(NSDictionary *)attrs { + return [self sizeWithFont:attrs[NSFontAttributeName]]; +} + +- (void)drawAtPoint:(CGPoint)point withAttributes:(NSDictionary *)attrs { + [self drawAtPoint:point withFont:attrs[NSFontAttributeName]]; +} + +- (void)drawInRect:(CGRect)rect withAttributes:(NSDictionary *)attrs { + NSParagraphStyle *paraStyle = attrs[NSParagraphStyleAttributeName]; + + [self drawInRect:rect withFont:attrs[NSFontAttributeName] + lineBreakMode:paraStyle.lineBreakMode + alignment:paraStyle.alignment]; +} + +@end +#endif diff --git a/Classes/WDBar.m b/Classes/WDBar.m index fcf8e6f..fa02aa1 100644 --- a/Classes/WDBar.m +++ b/Classes/WDBar.m @@ -11,6 +11,7 @@ #import "WDBar.h" #import "WDUtilities.h" +#import "NSString+Drawing.h" const NSUInteger kWDDefaultBarHeight = 44; const NSUInteger kWDLandscapePhoneBarHeight = 32; @@ -128,7 +129,7 @@ + (UIImage *) backImageWithTitle:(NSString *)string landscape:(BOOL)landscape if (WDUseModernAppearance()) { UIFont *font = [UIFont systemFontOfSize:17]; - CGSize textSize = [string sizeWithFont:font]; + CGSize textSize = [string sizeWithAttributes:@{NSFontAttributeName:font}]; CGSize size = textSize; float arrowSize = 9, arrowInset = 4; @@ -142,7 +143,7 @@ + (UIImage *) backImageWithTitle:(NSString *)string landscape:(BOOL)landscape CGPoint origin; origin.x = (size.width - textSize.width); // align right origin.y = (size.height - textSize.height) / 2.0f; // center vertically - [string drawAtPoint:origin withFont:font]; + [string drawAtPoint:origin withAttributes:@{NSFontAttributeName:font}]; // draw back arrow CGContextMoveToPoint(ctx, arrowInset + arrowSize, size.height / 2 - arrowSize); @@ -157,7 +158,7 @@ + (UIImage *) backImageWithTitle:(NSString *)string landscape:(BOOL)landscape UIGraphicsEndImageContext(); } else { UIFont *font = [UIFont boldSystemFontOfSize:(landscape ? 12 : 13)]; - CGSize textSize = [string sizeWithFont:font]; + CGSize textSize = [string sizeWithAttributes:@{NSFontAttributeName:font}]; CGSize size = textSize; UIImage *backImage = landscape ? [UIImage imageNamed:@"backButtonLandscape.png"] : [UIImage imageNamed:@"backButton.png"]; @@ -176,7 +177,7 @@ + (UIImage *) backImageWithTitle:(NSString *)string landscape:(BOOL)landscape CGPoint origin; origin.x = (size.width - textSize.width) / 2.0f + 2.0f; origin.y = (size.height - textSize.height) / 2.0f; - [string drawAtPoint:origin withFont:font]; + [string drawAtPoint:origin withAttributes:@{NSFontAttributeName:font}]; result = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); diff --git a/Classes/WDBlendModePicker.m b/Classes/WDBlendModePicker.m index 6db1766..4ec11e0 100644 --- a/Classes/WDBlendModePicker.m +++ b/Classes/WDBlendModePicker.m @@ -13,6 +13,7 @@ #import "WDBlendModePicker.h" #import "WDScrollView.h" #import "WDUtilities.h" +#import "NSString+Drawing.h" const float kScrollViewHeight = 41; const float kIndicatorBaseHeight = 48; @@ -232,9 +233,10 @@ - (void) buildTitleButtons { // iterate through the strings and find the longest one float width, totalWidth = 0.0f; + NSDictionary *attrs = @{NSFontAttributeName:self.font}; for (NSString *title in self.titles) { - width = [title sizeWithFont:self.font].width; + width = [title sizeWithAttributes:attrs].width; totalWidth += width + (kButtonOutset * 2); } @@ -249,7 +251,7 @@ - (void) buildTitleButtons for (NSString *title in self.titles) { button = [UIButton buttonWithType:UIButtonTypeCustom]; - buttonFrame.size.width = [title sizeWithFont:self.font].width + (kButtonOutset * 2); + buttonFrame.size.width = [title sizeWithAttributes:attrs].width + (kButtonOutset * 2); button.frame = buttonFrame; button.titleLabel.font = self.font; button.tag = index++; diff --git a/Classes/WDCanvasController.m b/Classes/WDCanvasController.m index c2f79f4..76c4ea7 100644 --- a/Classes/WDCanvasController.m +++ b/Classes/WDCanvasController.m @@ -45,6 +45,7 @@ #import "WDUndoChange.h" #import "WDUtilities.h" #import "WDUnlockView.h" +#import "NSString+Drawing.h" #define RESCALE_REPLAY 0 #define kNavBarFixedWidth 20 @@ -871,10 +872,13 @@ - (UIImage *) layerImage NSString *label = [NSString stringWithFormat:@"%lu", (unsigned long)index]; + NSMutableParagraphStyle *paraStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; + paraStyle.lineBreakMode = NSLineBreakByClipping; + paraStyle.alignment = NSTextAlignmentCenter; + [label drawInRect:CGRectOffset(layerBox, 0, 1) - withFont:[UIFont boldSystemFontOfSize:13] - lineBreakMode:UILineBreakModeClip - alignment:UITextAlignmentCenter]; + withAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:13], + NSParagraphStyleAttributeName:paraStyle}]; } UIImage *result = UIGraphicsGetImageFromCurrentImageContext(); diff --git a/Classes/WDMenu.m b/Classes/WDMenu.m index 0162979..824b545 100644 --- a/Classes/WDMenu.m +++ b/Classes/WDMenu.m @@ -12,6 +12,7 @@ #import "WDMenu.h" #import "WDUtilities.h" #import "WDMenuItem.h" +#import "NSString+Drawing.h" #define kMenuHeight 40 #define kSeparatorHeight 5 @@ -38,10 +39,12 @@ - (id) initWithItems:(NSArray *)items { float maxWidth = 0; float height = 0; + NSDictionary *attrs = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:kFontSize]}; for (WDMenuItem *item in items) { int imageWidth = [item imageWidth] ? [item imageWidth] + kImageBuffer : 0; - maxWidth = MAX(maxWidth, [item.title sizeWithFont:[UIFont boldSystemFontOfSize:kFontSize]].width + imageWidth); + CGSize size = [item.title sizeWithAttributes:attrs]; + maxWidth = MAX(maxWidth, size.width + imageWidth); height += (item.separator ? kSeparatorHeight : kMenuHeight); } From 1cc9f47972011aeac0414d1a7bd170295ed00ec4 Mon Sep 17 00:00:00 2001 From: Zhang Yungui Date: Wed, 14 May 2014 11:25:31 +0800 Subject: [PATCH 2/8] Fix compatibility problems for iOS 7 and ARC. --- Classes/WDCanvasController.m | 2 ++ Classes/WDDictionaryDecoder.m | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Classes/WDCanvasController.m b/Classes/WDCanvasController.m index 76c4ea7..361c8c8 100644 --- a/Classes/WDCanvasController.m +++ b/Classes/WDCanvasController.m @@ -81,7 +81,9 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil return nil; } +#ifndef __IPHONE_7_0 [self setWantsFullScreenLayout:YES]; +#endif return self; } diff --git a/Classes/WDDictionaryDecoder.m b/Classes/WDDictionaryDecoder.m index 7ff0aaa..372d7c3 100644 --- a/Classes/WDDictionaryDecoder.m +++ b/Classes/WDDictionaryDecoder.m @@ -39,6 +39,7 @@ - (id) initWithDictionary:(NSDictionary *)dict progress:(WDCodingProgress *)prog - (void) dealloc { +#ifndef OS_OBJECT_USE_OBJC if (dispatchQueue_) { dispatch_release(dispatchQueue_); } @@ -46,6 +47,7 @@ - (void) dealloc if (dispatchGroup_) { dispatch_release(dispatchGroup_); } +#endif } - (WDCodingProgress *) progress From cbc9a86b02337affd379848fdfa8db8913864a26 Mon Sep 17 00:00:00 2001 From: Zhang Yungui Date: Wed, 14 May 2014 11:27:06 +0800 Subject: [PATCH 3/8] Fix comments. --- Classes/WDColorAdjustmentController.h | 2 +- Classes/WDColorAdjustmentController.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/WDColorAdjustmentController.h b/Classes/WDColorAdjustmentController.h index 301a47d..dfe7bc2 100644 --- a/Classes/WDColorAdjustmentController.h +++ b/Classes/WDColorAdjustmentController.h @@ -1,5 +1,5 @@ // -// WDColorBalanceController.h +// WDColorAdjustmentController.h // Brushes // // This Source Code Form is subject to the terms of the Mozilla Public diff --git a/Classes/WDColorAdjustmentController.m b/Classes/WDColorAdjustmentController.m index d159b9e..b79fd27 100644 --- a/Classes/WDColorAdjustmentController.m +++ b/Classes/WDColorAdjustmentController.m @@ -1,5 +1,5 @@ // -// WDColorBalanceController.m +// WDColorAdjustmentController.m // Brushes // // This Source Code Form is subject to the terms of the Mozilla Public From 7fc1779d76f5b396eba4d8d475b8597201dcc945 Mon Sep 17 00:00:00 2001 From: Zhang Yungui Date: Wed, 14 May 2014 11:30:57 +0800 Subject: [PATCH 4/8] Fix @selector(dismissViewController:) not found warning for delegate. --- Classes/WDBrushesController.m | 2 ++ Classes/WDColorPickerController.m | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Classes/WDBrushesController.m b/Classes/WDBrushesController.m index cc3c376..234054f 100644 --- a/Classes/WDBrushesController.m +++ b/Classes/WDBrushesController.m @@ -49,6 +49,8 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil return self; } +- (void) dismissViewController:(UIViewController *)viewController {} // for delegate + - (void) done:(id)sender { if (self.delegate && [self.delegate respondsToSelector:@selector(dismissViewController:)]) { diff --git a/Classes/WDColorPickerController.m b/Classes/WDColorPickerController.m index 8e135db..7e7143b 100644 --- a/Classes/WDColorPickerController.m +++ b/Classes/WDColorPickerController.m @@ -34,6 +34,8 @@ @implementation WDColorPickerController @synthesize secondCell; @synthesize matrix; +- (void) dismissViewController:(UIViewController *)viewController {} // for delegate + - (IBAction)dismiss:(id)sender { [[self presentingViewController] dismissViewControllerAnimated:NO completion:nil]; From 335e270af8b2491d74a3adb3c5cc4bab0b44aa24 Mon Sep 17 00:00:00 2001 From: Zhang Yungui Date: Wed, 14 May 2014 11:33:08 +0800 Subject: [PATCH 5/8] iOS 7 Compiler warning fix for contentSizeForViewInPopover. --- Brushes_Prefix.pch | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Brushes_Prefix.pch b/Brushes_Prefix.pch index 0d8fa15..5353823 100644 --- a/Brushes_Prefix.pch +++ b/Brushes_Prefix.pch @@ -7,3 +7,7 @@ #import #import #endif + +#ifdef __IPHONE_7_0 +#define contentSizeForViewInPopover preferredContentSize +#endif From 90b8e63f8093ca64dfa3669b828532daf0a2e274 Mon Sep 17 00:00:00 2001 From: Zhang Yungui Date: Wed, 14 May 2014 11:36:36 +0800 Subject: [PATCH 6/8] iOS7 compiler warning fix for NSTextAlignment. --- Classes/WDActionNameView.m | 4 ++-- Classes/WDBar.m | 4 ++-- Classes/WDBarSlider.m | 2 +- Classes/WDBrushSizeOverlay.m | 2 +- Classes/WDCanvas.m | 2 +- Classes/WDThumbnailView.m | 2 +- Classes/WDUnlockSlider.m | 2 +- Classes/WDUnlockView.m | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Classes/WDActionNameView.m b/Classes/WDActionNameView.m index de147ae..da4050d 100644 --- a/Classes/WDActionNameView.m +++ b/Classes/WDActionNameView.m @@ -41,7 +41,7 @@ - (id)initWithFrame:(CGRect)frame frame.size.height /= 2; self.titleLabel = [[UILabel alloc] initWithFrame:frame]; titleLabel.font = [UIFont boldSystemFontOfSize:20.0f]; - titleLabel.textAlignment = UITextAlignmentCenter; + titleLabel.textAlignment = NSTextAlignmentCenter; titleLabel.backgroundColor = nil; titleLabel.opaque = NO; titleLabel.textColor = [UIColor whiteColor]; @@ -52,7 +52,7 @@ - (id)initWithFrame:(CGRect)frame frame = CGRectOffset(frame, 0, CGRectGetHeight(frame)); self.messageLabel = [[UILabel alloc] initWithFrame:frame]; messageLabel.font = [UIFont systemFontOfSize:17.0f]; - messageLabel.textAlignment = UITextAlignmentCenter; + messageLabel.textAlignment = NSTextAlignmentCenter; messageLabel.backgroundColor = nil; messageLabel.opaque = NO; messageLabel.textColor = [UIColor whiteColor]; diff --git a/Classes/WDBar.m b/Classes/WDBar.m index fa02aa1..6df71ca 100644 --- a/Classes/WDBar.m +++ b/Classes/WDBar.m @@ -501,8 +501,8 @@ - (void) setTitle:(NSString *)title label.backgroundColor = nil; label.opaque = NO; label.textColor = [UIColor whiteColor]; - label.textAlignment = UITextAlignmentCenter; - label.lineBreakMode = UILineBreakModeMiddleTruncation; + label.textAlignment = NSTextAlignmentCenter; + label.lineBreakMode = NSLineBreakByTruncatingMiddle; label.font = [self portraitFont]; label.autoresizingMask = UIViewAutoresizingFlexibleWidth; diff --git a/Classes/WDBarSlider.m b/Classes/WDBarSlider.m index f1dfdb3..0495fe5 100644 --- a/Classes/WDBarSlider.m +++ b/Classes/WDBarSlider.m @@ -59,7 +59,7 @@ - (id) initWithFrame:(CGRect)frame label.opaque = NO; label.backgroundColor = nil; label.font = [UIFont boldSystemFontOfSize:13]; - label.textAlignment = UITextAlignmentCenter; + label.textAlignment = NSTextAlignmentCenter; label.textColor = [UIColor whiteColor]; CALayer *layer = self.layer; diff --git a/Classes/WDBrushSizeOverlay.m b/Classes/WDBrushSizeOverlay.m index feddf1f..205335a 100644 --- a/Classes/WDBrushSizeOverlay.m +++ b/Classes/WDBrushSizeOverlay.m @@ -35,7 +35,7 @@ - (void) configureTitle label.opaque = NO; label.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:19.0f]; label.textColor = [UIColor whiteColor]; - label.textAlignment = UITextAlignmentCenter; + label.textAlignment = NSTextAlignmentCenter; label.text = @"512 px"; label.shadowColor = [UIColor blackColor]; label.shadowOffset = CGSizeMake(0, 1); diff --git a/Classes/WDCanvas.m b/Classes/WDCanvas.m index bbacb2e..1ecf1b2 100644 --- a/Classes/WDCanvas.m +++ b/Classes/WDCanvas.m @@ -1161,7 +1161,7 @@ - (void) showMessage:(NSString *)message autoHide:(BOOL)autoHide position:(CGPoi messageLabel_ = [[WDLabel alloc] initWithFrame:CGRectInset(CGRectMake(0,0,100,40), -8, -8)]; messageLabel_.textColor = [UIColor whiteColor]; messageLabel_.font = [UIFont boldSystemFontOfSize:24.0f]; - messageLabel_.textAlignment = UITextAlignmentCenter; + messageLabel_.textAlignment = NSTextAlignmentCenter; messageLabel_.opaque = NO; messageLabel_.backgroundColor = nil; messageLabel_.alpha = 0; diff --git a/Classes/WDThumbnailView.m b/Classes/WDThumbnailView.m index d1c7280..2e8d8cb 100644 --- a/Classes/WDThumbnailView.m +++ b/Classes/WDThumbnailView.m @@ -189,7 +189,7 @@ - (void) setFilename:(NSString *)filename CGRect frame = CGRectMake(0, 0, self.bounds.size.width, self.titleFieldHeight); titleField_ = [[UITextField alloc] initWithFrame:frame]; - titleField_.textAlignment = UITextAlignmentCenter; + titleField_.textAlignment = NSTextAlignmentCenter; titleField_.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; titleField_.delegate = self; titleField_.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:([self runningOnPhone] ? 16 : 20)]; diff --git a/Classes/WDUnlockSlider.m b/Classes/WDUnlockSlider.m index 465e134..e56478c 100644 --- a/Classes/WDUnlockSlider.m +++ b/Classes/WDUnlockSlider.m @@ -54,7 +54,7 @@ - (id) initWithFrame:(CGRect)frame label.backgroundColor = nil; label.text = NSLocalizedString(@"slide to edit", @"slide to edit"); label.font = [UIFont systemFontOfSize:24.0]; - label.textAlignment = UITextAlignmentCenter; + label.textAlignment = NSTextAlignmentCenter; label.textColor = [UIColor whiteColor]; label.layer.shadowColor = [UIColor blackColor].CGColor; diff --git a/Classes/WDUnlockView.m b/Classes/WDUnlockView.m index 1015a34..7f6fe37 100644 --- a/Classes/WDUnlockView.m +++ b/Classes/WDUnlockView.m @@ -45,7 +45,7 @@ - (id) initWithFrame:(CGRect)frame label.backgroundColor = nil; label.text = NSLocalizedString(@"swipe here to paint", @"swipe here to paint"); label.font = [UIFont systemFontOfSize:22.0]; - label.textAlignment = UITextAlignmentCenter; + label.textAlignment = NSTextAlignmentCenter; label.textColor = [UIColor whiteColor]; label.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; From 29229d12cdbb3bde4536afa87bec87d317823580 Mon Sep 17 00:00:00 2001 From: Zhang Yungui Date: Wed, 14 May 2014 11:41:40 +0800 Subject: [PATCH 7/8] iOS 7 Compiler warning fix for CGBitmapContextCreate. --- Brushes_Prefix.pch | 10 ++++++++++ Classes/UIImage+Additions.m | 2 +- Classes/WDBrushPreview.m | 2 +- Classes/WDColorSlider.m | 2 +- Classes/WDColorWheel.m | 2 +- Classes/WDHueShifter.m | 2 +- Classes/WDLayer.m | 2 +- Classes/WDPainting.m | 4 ++-- Classes/WDStampGenerator.m | 6 +++--- Classes/WDTexture.m | 2 +- 10 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Brushes_Prefix.pch b/Brushes_Prefix.pch index 5353823..7f14a03 100644 --- a/Brushes_Prefix.pch +++ b/Brushes_Prefix.pch @@ -11,3 +11,13 @@ #ifdef __IPHONE_7_0 #define contentSizeForViewInPopover preferredContentSize #endif + +#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1 +#define kImageAlphaNone (CGBitmapInfo)kCGImageAlphaNone +#define kImageAlphaPremultipliedFirst (CGBitmapInfo)kCGImageAlphaPremultipliedFirst +#define kImageAlphaPremultipliedLast (CGBitmapInfo)kCGImageAlphaPremultipliedLast +#else +#define kImageAlphaNone kCGImageAlphaNone +#define kImageAlphaPremultipliedFirst kCGImageAlphaPremultipliedFirst +#define kImageAlphaPremultipliedLast kCGImageAlphaPremultipliedLast +#endif diff --git a/Classes/UIImage+Additions.m b/Classes/UIImage+Additions.m index 7ece5a8..5abe937 100644 --- a/Classes/UIImage+Additions.m +++ b/Classes/UIImage+Additions.m @@ -116,7 +116,7 @@ - (BOOL) reallyHasAlpha UInt8 *data = malloc(height * rowByteSize); CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); - CGContextRef context = CGBitmapContextCreate(data, width, height, 8, rowByteSize, colorSpaceRef, kCGImageAlphaPremultipliedLast); + CGContextRef context = CGBitmapContextCreate(data, width, height, 8, rowByteSize, colorSpaceRef, kImageAlphaPremultipliedLast); CGContextSetBlendMode(context, kCGBlendModeCopy); CGContextDrawImage(context, CGRectMake(0, 0, width, height), image); CGContextRelease(context); diff --git a/Classes/WDBrushPreview.m b/Classes/WDBrushPreview.m index a473fb8..8447592 100644 --- a/Classes/WDBrushPreview.m +++ b/Classes/WDBrushPreview.m @@ -189,7 +189,7 @@ - (void) setup:(CGSize)size CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); cgContext = CGBitmapContextCreate(pixels, backingWidth, backingHeight, 8, backingWidth * 4, - colorSpaceRef, kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedLast); + colorSpaceRef, kCGBitmapByteOrderDefault | kImageAlphaPremultipliedLast); CGColorSpaceRelease(colorSpaceRef); if (self.path) { diff --git a/Classes/WDColorSlider.m b/Classes/WDColorSlider.m index d3877db..6663686 100644 --- a/Classes/WDColorSlider.m +++ b/Classes/WDColorSlider.m @@ -396,7 +396,7 @@ - (void) p_buildHueImage } CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); - CGContextRef ctx = CGBitmapContextCreate(data, width, height, 8, bpr, colorSpace, kCGImageAlphaPremultipliedFirst); + CGContextRef ctx = CGBitmapContextCreate(data, width, height, 8, bpr, colorSpace, kImageAlphaPremultipliedFirst); CGColorSpaceRelease(colorSpace); hueImage_ = CGBitmapContextCreateImage(ctx); diff --git a/Classes/WDColorWheel.m b/Classes/WDColorWheel.m index 389300a..884d379 100755 --- a/Classes/WDColorWheel.m +++ b/Classes/WDColorWheel.m @@ -202,7 +202,7 @@ - (void) p_buildWheelImage } CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); - CGContextRef ctx = CGBitmapContextCreate(data, diameter, diameter, 8, bpr, colorSpace, kCGImageAlphaPremultipliedFirst); + CGContextRef ctx = CGBitmapContextCreate(data, diameter, diameter, 8, bpr, colorSpace, kImageAlphaPremultipliedFirst); CGColorSpaceRelease(colorSpace); wheelImage_ = CGBitmapContextCreateImage(ctx); diff --git a/Classes/WDHueShifter.m b/Classes/WDHueShifter.m index 265df24..fb9e622 100644 --- a/Classes/WDHueShifter.m +++ b/Classes/WDHueShifter.m @@ -268,7 +268,7 @@ - (void) p_buildHueImage } CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); - CGContextRef ctx = CGBitmapContextCreate(data, width, height, 8, bpr, colorSpace, kCGImageAlphaPremultipliedFirst); + CGContextRef ctx = CGBitmapContextCreate(data, width, height, 8, bpr, colorSpace, kImageAlphaPremultipliedFirst); CGColorSpaceRelease(colorSpace); hueImage_ = CGBitmapContextCreateImage(ctx); diff --git a/Classes/WDLayer.m b/Classes/WDLayer.m index bba6f51..bd3ed40 100644 --- a/Classes/WDLayer.m +++ b/Classes/WDLayer.m @@ -460,7 +460,7 @@ - (UIImage *) thumbnail CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); CGContextRef ctx = CGBitmapContextCreate(pixels, width, height, 8, width*4, - colorSpaceRef, kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedLast); + colorSpaceRef, kCGBitmapByteOrderDefault | kImageAlphaPremultipliedLast); CGImageRef imageRef = CGBitmapContextCreateImage(ctx); thumbnail_ = [[UIImage alloc] initWithCGImage:imageRef scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]; diff --git a/Classes/WDPainting.m b/Classes/WDPainting.m index 81b6a96..7dac7b9 100644 --- a/Classes/WDPainting.m +++ b/Classes/WDPainting.m @@ -414,7 +414,7 @@ - (UIImage *) imageForData:(NSData *)data size:(CGSize)size CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); CGContextRef ctx = CGBitmapContextCreate((void *) data.bytes, width, height, 8, width*4, - colorSpaceRef, kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedLast); + colorSpaceRef, kCGBitmapByteOrderDefault | kImageAlphaPremultipliedLast); CGImageRef imageRef = CGBitmapContextCreateImage(ctx); UIImage *result = [UIImage imageWithCGImage:imageRef]; @@ -617,7 +617,7 @@ - (UIImage *) thumbnailImage if (!thumbnail) { // OpenGL isn't working, generate a blank image as a placeholder CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); - CGContextRef context = CGBitmapContextCreate(NULL, width, height, 8, 0, colorSpace, kCGImageAlphaPremultipliedLast); + CGContextRef context = CGBitmapContextCreate(NULL, width, height, 8, 0, colorSpace, kImageAlphaPremultipliedLast); CGContextSetRGBFillColor(context, (CGFloat)0.0, (CGFloat)0.0, (CGFloat)0.0, (CGFloat)1.0 ); CGImageRef cgImage = CGBitmapContextCreateImage(context); CGColorSpaceRelease(colorSpace); diff --git a/Classes/WDStampGenerator.m b/Classes/WDStampGenerator.m index 1d51f58..9257468 100644 --- a/Classes/WDStampGenerator.m +++ b/Classes/WDStampGenerator.m @@ -120,7 +120,7 @@ - (UIImage *) generateStamp void *data = calloc(sizeof(UInt8), width * height); CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceGray(); - CGContextRef context = CGBitmapContextCreate(data, width, height, 8, rowByteSize, colorspace, kCGImageAlphaNone); + CGContextRef context = CGBitmapContextCreate(data, width, height, 8, rowByteSize, colorspace, kImageAlphaNone); CGColorSpaceRelease(colorspace); // make our bitmap context the current context @@ -205,7 +205,7 @@ - (UIImage *) previewWithImage:(UIImage *)imageMask brightness:(float)brightness size_t height = imageMask.size.height; CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); - CGContextRef ctx = CGBitmapContextCreate(NULL, width, height, 8, width*4, colorspace, kCGImageAlphaPremultipliedLast); + CGContextRef ctx = CGBitmapContextCreate(NULL, width, height, 8, width*4, colorspace, kImageAlphaPremultipliedLast); CGColorSpaceRelease(colorspace); CGContextClipToMask(ctx, CGRectMake(0, 0, width, height), imageMask.CGImage); @@ -342,7 +342,7 @@ - (CGImageRef) radialFadeWithHardness:(float)hardness } CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceGray(); - CGContextRef ctx = CGBitmapContextCreate(NULL, self.size.width, self.size.height, 8, self.size.width, colorspace, kCGImageAlphaNone); + CGContextRef ctx = CGBitmapContextCreate(NULL, self.size.width, self.size.height, 8, self.size.width, colorspace, kImageAlphaNone); NSArray *colors = @[(__bridge id) [UIColor whiteColor].CGColor, (__bridge id) [UIColor blackColor].CGColor]; const CGFloat locations[] = {0.0, 1.0}; diff --git a/Classes/WDTexture.m b/Classes/WDTexture.m index 159dff6..50f3a30 100644 --- a/Classes/WDTexture.m +++ b/Classes/WDTexture.m @@ -137,7 +137,7 @@ - (void) loadTextureFromImage:(CGImageRef)image forceRGB:(BOOL)forceRGB CGColorSpaceRef colorSpaceRef = isAlpha ? CGColorSpaceCreateDeviceGray() : CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(data_, width_, height_, 8, rowByteSize_, colorSpaceRef, - (isAlpha ? kCGImageAlphaNone : kCGImageAlphaPremultipliedLast)); + (isAlpha ? kImageAlphaNone : kImageAlphaPremultipliedLast)); CGContextSetBlendMode(context, kCGBlendModeCopy); CGContextDrawImage(context, CGRectMake(0.0, 0.0, width_, height_), image); CGContextRelease(context); From 7de885d61bdcc557f8f577202d1f30020164a4a1 Mon Sep 17 00:00:00 2001 From: Zhang Yungui Date: Wed, 14 May 2014 12:25:22 +0800 Subject: [PATCH 8/8] Fix FRAMEWORK_SEARCH_PATHS. --- Brushes.xcodeproj/project.pbxproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Brushes.xcodeproj/project.pbxproj b/Brushes.xcodeproj/project.pbxproj index a26e91a..2f0a582 100755 --- a/Brushes.xcodeproj/project.pbxproj +++ b/Brushes.xcodeproj/project.pbxproj @@ -2389,7 +2389,6 @@ FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)", - /Users/sprang/Development/Brushes, ); GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -2423,7 +2422,6 @@ FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)", - /Users/sprang/Development/Brushes, ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = Brushes_Prefix.pch; @@ -2476,7 +2474,6 @@ FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)", - /Users/sprang/Development/Brushes, ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = Brushes_Prefix.pch; @@ -2533,7 +2530,6 @@ FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)", - /Users/sprang/Development/Brushes, ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = Brushes_Prefix.pch;