diff --git a/README.md b/README.md index 5a1af81..4217b96 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ To optimize the file and make it smaller, try [`PDFShaver.app`](https://github.c Usage ----- -Download the [`PDFImage.framework`](Xcode/PDFImage.framework.zip?raw=true) and link it with your project. +Download the [`PDFImage.framework`](../../releases/latest) and link it with your project. Add the following line to import the required classes. @@ -69,7 +69,7 @@ A tintColor can also be specified to change the entire color, useful for reusing PDFImageView* imageView = ...; [imageView setTintColor:[UIColor redColor]]; -See the included headers of the [`PDFImage.framework`](Xcode/PDFImage.framework.zip?raw=true) for the full API interface. +See the included headers of the [`PDFImage.framework`](../../releases/latest) for the full API interface. See the `PDFImageDemo` target in `PDFImage.xcodeproj` for more examples. @@ -79,6 +79,6 @@ Details `PDFImage` is thread safe. Obviously this does not extend to the view subclasses included. -`PDFImage` uses ARC, however if you use the precompiled [`PDFImage.framework`](Xcode/PDFImage.framework.zip?raw=true) it is fully compatible with MRC projects and does not require any additional compiler flags. +`PDFImage` uses ARC, however if you use the precompiled [`PDFImage.framework`](../../releases/latest) it is fully compatible with MRC projects and does not require any additional compiler flags. For optimal performance, `NSCache` is used to memory-cache both bundled PDF files as well as generated `UIImages`. These are automatically purged when the device runs low on memory, or if the App is terminated. diff --git a/Xcode/PDFImage.framework.zip b/Xcode/PDFImage.framework.zip deleted file mode 100644 index 7a28573..0000000 Binary files a/Xcode/PDFImage.framework.zip and /dev/null differ diff --git a/Xcode/PDFImage.xcodeproj/project.pbxproj b/Xcode/PDFImage.xcodeproj/project.pbxproj index a9678dd..7b0ed2a 100644 --- a/Xcode/PDFImage.xcodeproj/project.pbxproj +++ b/Xcode/PDFImage.xcodeproj/project.pbxproj @@ -423,7 +423,6 @@ C3995278187694E100221C8A /* Resources */, C3995279187694E100221C8A /* ShellScript */, C399527A187694E100221C8A /* ShellScript */, - C3F2DD97187708EE00B30628 /* ShellScript */, ); buildRules = ( ); @@ -607,19 +606,6 @@ shellPath = /bin/sh; shellScript = "set -e\n\nset +u\nif [[ $UFW_MASTER_SCRIPT_RUNNING ]]\nthen\n # Nothing for the slave script to do\n exit 0\nfi\nset -u\nexport UFW_MASTER_SCRIPT_RUNNING=1\n\n\n# Functions\n\n## List files in the specified directory, storing to the specified array.\n#\n# @param $1 The path to list\n# @param $2 The name of the array to fill\n#\n##\nlist_files ()\n{\n filelist=$(ls \"$1\")\n while read line\n do\n eval \"$2[\\${#$2[*]}]=\\\"\\$line\\\"\"\n done <<< \"$filelist\"\n}\n\n\n# Sanity check\n\nif [[ ! -f \"${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}\" ]]\nthen\n echo \"Framework target \\\"${TARGET_NAME}\\\" had no source files to build from. Make sure your source files have the correct target membership\"\n exit 1\nfi\n\n\n# Gather information\n\nif [[ \"$SDK_NAME\" =~ ([A-Za-z]+) ]]\nthen\n UFW_SDK_PLATFORM=${BASH_REMATCH[1]}\nelse\n echo \"Could not find platform name from SDK_NAME: $SDK_NAME\"\n exit 1\nfi\n\nif [[ \"$SDK_NAME\" =~ ([0-9]+.*$) ]]\nthen\n UFW_SDK_VERSION=${BASH_REMATCH[1]}\nelse\n echo \"Could not find sdk version from SDK_NAME: $SDK_NAME\"\n exit 1\nfi\n\nif [[ \"$UFW_SDK_PLATFORM\" = \"iphoneos\" ]]\nthen\n UFW_OTHER_PLATFORM=iphonesimulator\nelse\n UFW_OTHER_PLATFORM=iphoneos\nfi\n\nif [[ \"$BUILT_PRODUCTS_DIR\" =~ (.*)$UFW_SDK_PLATFORM$ ]]\nthen\n UFW_OTHER_BUILT_PRODUCTS_DIR=\"${BASH_REMATCH[1]}${UFW_OTHER_PLATFORM}\"\nelse\n echo \"Could not find $UFW_SDK_PLATFORM in $BUILT_PRODUCTS_DIR\"\n exit 1\nfi\n\nONLY_ACTIVE_PLATFORM=${ONLY_ACTIVE_PLATFORM:-$ONLY_ACTIVE_ARCH}\n\n# Short-circuit if all binaries are up to date.\n# We already checked the other platform in the prerun script.\n\nif [[ -f \"${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}\" ]] && [[ -f \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.embeddedframework/${EXECUTABLE_PATH}\" ]] && [[ ! \"${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}\" -nt \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.embeddedframework/${EXECUTABLE_PATH}\" ]]\nthen\n exit 0\nfi\n\nif [ \"${ONLY_ACTIVE_PLATFORM}\" == \"YES\" ]\nthen\n echo \"ONLY_ACTIVE_PLATFORM=${ONLY_ACTIVE_PLATFORM}: Skipping other platform build\"\nelse\n # Make sure the other platform gets built\n \n echo \"Build other platform\"\n \n echo xcodebuild -project \"${PROJECT_FILE_PATH}\" -target \"${TARGET_NAME}\" -configuration \"${CONFIGURATION}\" -sdk ${UFW_OTHER_PLATFORM}${UFW_SDK_VERSION} BUILD_DIR=\"${BUILD_DIR}\" CONFIGURATION_TEMP_DIR=\"${PROJECT_TEMP_DIR}/${CONFIGURATION}-${UFW_OTHER_PLATFORM}\" $ACTION\n xcodebuild -project \"${PROJECT_FILE_PATH}\" -target \"${TARGET_NAME}\" -configuration \"${CONFIGURATION}\" -sdk ${UFW_OTHER_PLATFORM}${UFW_SDK_VERSION} BUILD_DIR=\"${BUILD_DIR}\" CONFIGURATION_TEMP_DIR=\"${PROJECT_TEMP_DIR}/${CONFIGURATION}-${UFW_OTHER_PLATFORM}\" $ACTION\n \n \n # Build the fat static library binary\n \n echo \"Create universal static library\"\n \necho \"Xcode version: $XCODE_VERSION_MAJOR\"\n\nif [[ \"$XCODE_VERSION_MAJOR\" == \"0500\" ]]\nthen\n echo \"$DT_TOOLCHAIN_DIR/usr/bin/libtool\" -static \"${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}\" \"${UFW_OTHER_BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}\" -o \"${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}.temp\"\n \"$DT_TOOLCHAIN_DIR/usr/bin/libtool\" -static \"${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}\" \"${UFW_OTHER_BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}\" -o \"${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}.temp\"\nelse\n echo \"$PLATFORM_DEVELOPER_BIN_DIR/libtool\" -static \"${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}\" \"${UFW_OTHER_BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}\" -o \"${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}.temp\"\n \"$PLATFORM_DEVELOPER_BIN_DIR/libtool\" -static \"${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}\" \"${UFW_OTHER_BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}\" -o \"${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}.temp\"\nfi \n echo mv \"${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}.temp\" \"${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}\"\n mv \"${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}.temp\" \"${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}\"\nfi\n\n# Build embedded framework structure\n\necho \"Build Embedded Framework\"\n\necho rm -rf \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.embeddedframework\"\nrm -rf \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.embeddedframework\"\necho mkdir -p \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.embeddedframework/Resources\"\nmkdir -p \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.embeddedframework/Resources\"\necho cp -a \"${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}\" \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.embeddedframework/\"\ncp -a \"${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}\" \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.embeddedframework/\"\n\ndeclare -a UFW_FILE_LIST\nlist_files \"${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}\" UFW_FILE_LIST\nfor filename in \"${UFW_FILE_LIST[@]}\"\ndo\n if [[ \"${filename}\" != \"Info.plist\" ]] && [[ ! \"${filename}\" =~ .*\\.lproj$ ]]\n then\n echo ln -sfh \"../${WRAPPER_NAME}/Resources/${filename}\" \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.embeddedframework/Resources/${filename}\"\n ln -sfh \"../${WRAPPER_NAME}/Resources/${filename}\" \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.embeddedframework/Resources/${filename}\"\n fi\ndone\n\n\nif [ \"${ONLY_ACTIVE_PLATFORM}\" != \"YES\" ]\nthen\n # Replace other platform's framework with a copy of this one (so that both have the same universal binary)\n \n echo \"Copy from $UFW_SDK_PLATFORM to $UFW_OTHER_PLATFORM\"\n \n echo rm -rf \"${BUILD_DIR}/${CONFIGURATION}-${UFW_OTHER_PLATFORM}\"\n rm -rf \"${BUILD_DIR}/${CONFIGURATION}-${UFW_OTHER_PLATFORM}\"\n echo cp -a \"${BUILD_DIR}/${CONFIGURATION}-${UFW_SDK_PLATFORM}\" \"${BUILD_DIR}/${CONFIGURATION}-${UFW_OTHER_PLATFORM}\"\n cp -a \"${BUILD_DIR}/${CONFIGURATION}-${UFW_SDK_PLATFORM}\" \"${BUILD_DIR}/${CONFIGURATION}-${UFW_OTHER_PLATFORM}\"\nfi\n"; }; - C3F2DD97187708EE00B30628 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "# Package framework to zip if we're compiling the framework\n\nif [ \"${CONFIGURATION}\" == \"Release\" ]\nthen\n\n ZIP_PATH=\"${SRCROOT}/PDFImage.framework.zip\"\n -rm $ZIP_PATH #silent rm\n cd \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.framework/\"\n zip -r $ZIP_PATH *\n\nfi"; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -865,7 +851,6 @@ "$(inherited)", "$(DEVELOPER_FRAMEWORKS_DIR)", "${BUILT_PRODUCTS_DIR}", - "$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/PDFImage-dsswrlcyowqtxbasgqxvmkeoojqz/Build/Products/Debug-iphoneos", ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "PDFImageDemo/PDFImageDemo-Prefix.pch"; @@ -889,7 +874,6 @@ "$(inherited)", "$(DEVELOPER_FRAMEWORKS_DIR)", "${BUILT_PRODUCTS_DIR}", - "$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/PDFImage-dsswrlcyowqtxbasgqxvmkeoojqz/Build/Products/Debug-iphoneos", ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "PDFImageDemo/PDFImageDemo-Prefix.pch"; diff --git a/Xcode/PDFImage/PDFImage.m b/Xcode/PDFImage/PDFImage.m index 90982d7..e210185 100644 --- a/Xcode/PDFImage/PDFImage.m +++ b/Xcode/PDFImage/PDFImage.m @@ -170,7 +170,7 @@ - (UIImage*) imageWithOptions:(PDFImageOptions*) options UIColor* tintColor = [options.tintColor copy]; const CGSize containerSize = options.size; - NSString* cacheKey = [NSString stringWithFormat:@"%@-%0.2f-%@-%@", NSStringFromCGRect(rect), options.scale, tintColor.description, NSStringFromCGSize(containerSize)]; + NSString* cacheKey = [NSString stringWithFormat:@"%@-%0.2f-%@-%@", NSStringFromCGRect(rect), scale, tintColor.description, NSStringFromCGSize(containerSize)]; dispatch_once(&imageCacheOnceToken, ^{ imageCache = [[NSCache alloc] init]; diff --git a/Xcode/PDFImage/PDFImageView.m b/Xcode/PDFImage/PDFImageView.m index 1f0f633..f02d0e1 100644 --- a/Xcode/PDFImage/PDFImageView.m +++ b/Xcode/PDFImage/PDFImageView.m @@ -115,6 +115,15 @@ - (void) setContentMode:(UIViewContentMode)contentMode [self setNeedsDisplay]; } +- (void) willMoveToWindow:(UIWindow *)newWindow +{ + [super willMoveToWindow:newWindow]; + + // Set the scale to that of the window's screen + // The scale would only change if the image view is added to an external UIScreen + [options setScale:newWindow.screen.scale]; +} + + (Class) layerClass { return [PDFImageViewLayer class]; diff --git a/Xcode/PDFImageDemoTests/PDFImageDemoTests.m b/Xcode/PDFImageDemoTests/PDFImageDemoTests.m index cf239d9..1600474 100644 --- a/Xcode/PDFImageDemoTests/PDFImageDemoTests.m +++ b/Xcode/PDFImageDemoTests/PDFImageDemoTests.m @@ -111,43 +111,43 @@ - (void) testPDFImageOptionsContentMode [options setSize:containerSize]; [options setContentMode:UIViewContentModeScaleToFill]; - XCTAssertEqual(CGRectMake(0, 0, 20, 20), [options contentBoundsForContentSize:contentSize], @"Wrong content mode bounds"); + XCTAssertTrue(CGRectEqualToRect(CGRectMake(0, 0, 20, 20), [options contentBoundsForContentSize:contentSize]), @"Wrong content mode bounds"); [options setContentMode:UIViewContentModeScaleAspectFit]; - XCTAssertEqual(CGRectMake(5, 0, 10, 20), [options contentBoundsForContentSize:contentSize], @"Wrong content mode bounds"); + XCTAssertTrue(CGRectEqualToRect(CGRectMake(5, 0, 10, 20), [options contentBoundsForContentSize:contentSize]), @"Wrong content mode bounds"); [options setContentMode:UIViewContentModeScaleAspectFill]; - XCTAssertEqual(CGRectMake(0, -10, 20, 40), [options contentBoundsForContentSize:contentSize], @"Wrong content mode bounds"); + XCTAssertTrue(CGRectEqualToRect(CGRectMake(0, -10, 20, 40), [options contentBoundsForContentSize:contentSize]), @"Wrong content mode bounds"); [options setContentMode:UIViewContentModeRedraw]; - XCTAssertEqual(CGRectMake(0, 0, 20, 20), [options contentBoundsForContentSize:contentSize], @"Wrong content mode bounds"); + XCTAssertTrue(CGRectEqualToRect(CGRectMake(0, 0, 20, 20), [options contentBoundsForContentSize:contentSize]), @"Wrong content mode bounds"); [options setContentMode:UIViewContentModeCenter]; - XCTAssertEqual(CGRectMake(7, 5, 5, 10), [options contentBoundsForContentSize:contentSize], @"Wrong content mode bounds"); + XCTAssertTrue(CGRectEqualToRect(CGRectMake(7, 5, 5, 10), [options contentBoundsForContentSize:contentSize]), @"Wrong content mode bounds"); [options setContentMode:UIViewContentModeTop]; - XCTAssertEqual(CGRectMake(7, 0, 5, 10), [options contentBoundsForContentSize:contentSize], @"Wrong content mode bounds"); + XCTAssertTrue(CGRectEqualToRect(CGRectMake(7, 0, 5, 10), [options contentBoundsForContentSize:contentSize]), @"Wrong content mode bounds"); [options setContentMode:UIViewContentModeBottom]; - XCTAssertEqual(CGRectMake(7, 10, 5, 10), [options contentBoundsForContentSize:contentSize], @"Wrong content mode bounds"); + XCTAssertTrue(CGRectEqualToRect(CGRectMake(7, 10, 5, 10), [options contentBoundsForContentSize:contentSize]), @"Wrong content mode bounds"); [options setContentMode:UIViewContentModeLeft]; - XCTAssertEqual(CGRectMake(0, 5, 5, 10), [options contentBoundsForContentSize:contentSize], @"Wrong content mode bounds"); + XCTAssertTrue(CGRectEqualToRect(CGRectMake(0, 5, 5, 10), [options contentBoundsForContentSize:contentSize]), @"Wrong content mode bounds"); [options setContentMode:UIViewContentModeRight]; - XCTAssertEqual(CGRectMake(15, 5, 5, 10), [options contentBoundsForContentSize:contentSize], @"Wrong content mode bounds"); + XCTAssertTrue(CGRectEqualToRect(CGRectMake(15, 5, 5, 10), [options contentBoundsForContentSize:contentSize]), @"Wrong content mode bounds"); [options setContentMode:UIViewContentModeTopLeft]; - XCTAssertEqual(CGRectMake(0, 0, 5, 10), [options contentBoundsForContentSize:contentSize], @"Wrong content mode bounds"); + XCTAssertTrue(CGRectEqualToRect(CGRectMake(0, 0, 5, 10), [options contentBoundsForContentSize:contentSize]), @"Wrong content mode bounds"); [options setContentMode:UIViewContentModeTopRight]; - XCTAssertEqual(CGRectMake(15, 0, 5, 10), [options contentBoundsForContentSize:contentSize], @"Wrong content mode bounds"); + XCTAssertTrue(CGRectEqualToRect(CGRectMake(15, 0, 5, 10), [options contentBoundsForContentSize:contentSize]), @"Wrong content mode bounds"); [options setContentMode:UIViewContentModeBottomLeft]; - XCTAssertEqual(CGRectMake(0, 10, 5, 10), [options contentBoundsForContentSize:contentSize], @"Wrong content mode bounds"); + XCTAssertTrue(CGRectEqualToRect(CGRectMake(0, 10, 5, 10), [options contentBoundsForContentSize:contentSize]), @"Wrong content mode bounds"); [options setContentMode:UIViewContentModeBottomRight]; - XCTAssertEqual(CGRectMake(15, 10, 5, 10), [options contentBoundsForContentSize:contentSize], @"Wrong content mode bounds"); + XCTAssertTrue(CGRectEqualToRect(CGRectMake(15, 10, 5, 10), [options contentBoundsForContentSize:contentSize]), @"Wrong content mode bounds"); } - (void) testPDFImageWholeProportionalFit @@ -158,21 +158,21 @@ - (void) testPDFImageWholeProportionalFit [options setSize:containerSize]; // Scaling up - XCTAssertEqual(CGSizeMake(28, 28), [options wholeProportionalFitForContentSize:CGSizeMake(14, 14)], @"Wrong proportional fit"); - XCTAssertEqual(CGSizeMake(20, 14), [options wholeProportionalFitForContentSize:CGSizeMake(20, 14)], @"Wrong proportional fit"); - XCTAssertEqual(CGSizeMake(24, 28), [options wholeProportionalFitForContentSize:CGSizeMake(12, 14)], @"Wrong proportional fit"); - XCTAssertEqual(CGSizeMake(28, 14), [options wholeProportionalFitForContentSize:CGSizeMake(2, 1)], @"Wrong proportional fit"); - XCTAssertEqual(CGSizeMake(27, 27), [options wholeProportionalFitForContentSize:CGSizeMake(3, 3)], @"Wrong proportional fit"); - XCTAssertEqual(CGSizeMake(24, 12), [options wholeProportionalFitForContentSize:CGSizeMake(6, 3)], @"Wrong proportional fit"); + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(28, 28), [options wholeProportionalFitForContentSize:CGSizeMake(14, 14)]), @"Wrong proportional fit"); + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(20, 14), [options wholeProportionalFitForContentSize:CGSizeMake(20, 14)]), @"Wrong proportional fit"); + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(24, 28), [options wholeProportionalFitForContentSize:CGSizeMake(12, 14)]), @"Wrong proportional fit"); + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(28, 14), [options wholeProportionalFitForContentSize:CGSizeMake(2, 1)]), @"Wrong proportional fit"); + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(27, 27), [options wholeProportionalFitForContentSize:CGSizeMake(3, 3)]), @"Wrong proportional fit"); + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(24, 12), [options wholeProportionalFitForContentSize:CGSizeMake(6, 3)]), @"Wrong proportional fit"); // Scaling down - XCTAssertEqual(CGSizeMake(28, 28), [options wholeProportionalFitForContentSize:CGSizeMake(28, 28)], @"Wrong proportional fit"); - XCTAssertEqual(CGSizeMake(28, 28), [options wholeProportionalFitForContentSize:CGSizeMake(56, 56)], @"Wrong proportional fit"); - XCTAssertEqual(CGSizeMake(28, 14), [options wholeProportionalFitForContentSize:CGSizeMake(56, 28)], @"Wrong proportional fit"); - XCTAssertEqual(CGSizeMake(26, 10), [options wholeProportionalFitForContentSize:CGSizeMake(52, 20)], @"Wrong proportional fit"); - XCTAssertEqual(CGSizeMake(25, 7.5), [options wholeProportionalFitForContentSize:CGSizeMake(100, 30)], @"Wrong proportional fit"); - XCTAssertEqual(CGSizeMake(25, 18.75), [options wholeProportionalFitForContentSize:CGSizeMake(200, 150)], @"Wrong proportional fit"); - XCTAssertEqual(CGSizeMake(14.5, 14.5), [options wholeProportionalFitForContentSize:CGSizeMake(29, 29)], @"Wrong proportional fit"); + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(28, 28), [options wholeProportionalFitForContentSize:CGSizeMake(28, 28)]), @"Wrong proportional fit"); + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(28, 28), [options wholeProportionalFitForContentSize:CGSizeMake(56, 56)]), @"Wrong proportional fit"); + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(28, 14), [options wholeProportionalFitForContentSize:CGSizeMake(56, 28)]), @"Wrong proportional fit"); + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(26, 10), [options wholeProportionalFitForContentSize:CGSizeMake(52, 20)]), @"Wrong proportional fit"); + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(25, 7.5), [options wholeProportionalFitForContentSize:CGSizeMake(100, 30)]), @"Wrong proportional fit"); + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(25, 18.75), [options wholeProportionalFitForContentSize:CGSizeMake(200, 150)]), @"Wrong proportional fit"); + XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(14.5, 14.5), [options wholeProportionalFitForContentSize:CGSizeMake(29, 29)]), @"Wrong proportional fit"); } - (void) testPDFImageView @@ -188,7 +188,7 @@ - (void) testPDFImageView [keyWindow addSubview:imageView]; XCTAssertNotNil(imageView.currentUIImage, @"Has PDFImage, current UIImage should not be nil"); - XCTAssertEqual(imageView.currentUIImage.size, imageView.frame.size, @"Current UIImage should be same size as PDFImageView"); + XCTAssertTrue(CGSizeEqualToSize(imageView.currentUIImage.size, imageView.frame.size), @"Current UIImage should be same size as PDFImageView"); UIImageView* privateImageView = [imageView.subviews objectAtIndex:0]; @@ -218,7 +218,7 @@ - (void) testPDFBarButtonItem PDFBarButtonItem* item = [[PDFBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:nil action:nil]; XCTAssertNotNil(item.image, @"Bar button item should have image"); - XCTAssertNotEqual(item.image.size, CGSizeZero, @"Bar button image should have non zero size"); + XCTAssertFalse(CGSizeEqualToSize(item.image.size, CGSizeZero), @"Bar button image should have non zero size"); } #pragma mark -