├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── bf ├── bf.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── bf.xcscheme ├── bf │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ └── Main.storyboard │ ├── BetterFaceClass │ │ ├── UIImage+BetterFace.h │ │ ├── UIImage+BetterFace.m │ │ ├── UIImageView+BetterFace.h │ │ └── UIImageView+BetterFace.m │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── LaunchImage.launchimage │ │ │ └── Contents.json │ ├── Images │ │ ├── landscape │ │ │ ├── l1.jpg │ │ │ ├── l2.jpg │ │ │ ├── l3.jpg │ │ │ └── l4.jpg │ │ ├── multiple │ │ │ ├── m1.jpg │ │ │ └── m2.jpg │ │ └── up │ │ │ ├── up1.jpg │ │ │ ├── up2.jpg │ │ │ ├── up3.jpg │ │ │ └── up4.jpg │ ├── Launch Screen.storyboard │ ├── ViewController.h │ ├── ViewController.m │ ├── bf-Info.plist │ ├── bf-Prefix.pch │ ├── en.lproj │ │ └── InfoPlist.strings │ └── main.m └── bfTests │ ├── bfTests-Info.plist │ ├── bfTests.m │ └── en.lproj │ └── InfoPlist.strings └── doc └── preview.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | */build/* 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | profile 14 | *.moved-aside 15 | DerivedData 16 | .idea/ 17 | *.hmap 18 | *.xccheckout 19 | 20 | #CocoaPods 21 | Pods 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode7.3 3 | before_script: 4 | script: 5 | - xctool -project bf/bf.xcodeproj -scheme bf -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Croath Liu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/croath/UIImageView-BetterFace.svg)](https://travis-ci.org/croath/UIImageView-BetterFace) 2 | 3 | UIImageView-BetterFace 4 | ====================== 5 | 6 | A UIImageView extension to let the picture-cutting with faces showing better 7 | 8 | Last update in v0.2_stable : add a UIImage+BetterFace category, so clipping images becomes possible(clap!) 9 | 10 | Looking for an Android version? Check this! [https://github.com/beartung/tclip-android] 11 | 12 | ##Why? 13 | 14 | - Have problems showing the resized image previews? 15 | - People in the preview only have chins but not faces? 16 | - A group photo doesn't look well? 17 | 18 | Try UIImageView-BetterFace! 19 | 20 | Like this: 21 | 22 | ![preview](https://raw.github.com/croath/UIImageView-BetterFace/master/doc/preview.png) 23 | 24 | ##How? 25 | 26 | 1. Drag `UIImageView+BetterFace.h` and `UIImageView+BetterFace.m` to your project 27 | 2. Add CoreImage.framework to your project 28 | 3. Import the .h file 29 | 4. Add this:`[anImageView setNeedsBetterFace:YES];` 30 | 5. If you want all `setImage:` methods do the magic: Add `hack_uiimageview_bf();` to your `main` function; Otherwise call `setBetterFaceImage:` for every image you want to make the face detection. 31 | 6. Done 32 | 7. Still have problems? clone the project and see the demo. 33 | 34 | ##Too slow? 35 | 36 | try set the `fast` property to `YES` to get the faster speed(lower accuracy) 37 | 38 | ##Known issues 39 | 40 | - ~~it will be slow to render large-size images, and showing the strange animation~~ 41 | - ~~it may take a lot of memory while reusing the UIImageView~~ 42 | 43 | ##Who use BetterFace? 44 | 45 | - App of http://getprix.com 46 | 47 | If you're building your applications using UIImageView-BetterFace, please let me know! (add your application name & App Store link here and pullreuqest this README~ 48 | 49 | ##Debugging 50 | Add `BF_DEBUG` to your pre compile macros or `#define BF_DEBUG` to your `prefix.pch` file in order to see turn ON debugging logs on the console. 51 | 52 | ##Other 53 | 54 | Any issue and pull request is welcome. 55 | -------------------------------------------------------------------------------- /bf/bf.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 2783FDEA181697D200F3F6E9 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2783FDE9181697D200F3F6E9 /* Foundation.framework */; }; 11 | 2783FDEC181697D200F3F6E9 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2783FDEB181697D200F3F6E9 /* CoreGraphics.framework */; }; 12 | 2783FDEE181697D200F3F6E9 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2783FDED181697D200F3F6E9 /* UIKit.framework */; }; 13 | 2783FDF4181697D200F3F6E9 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2783FDF2181697D200F3F6E9 /* InfoPlist.strings */; }; 14 | 2783FDF6181697D200F3F6E9 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2783FDF5181697D200F3F6E9 /* main.m */; }; 15 | 2783FDFA181697D200F3F6E9 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2783FDF9181697D200F3F6E9 /* AppDelegate.m */; }; 16 | 2783FDFD181697D200F3F6E9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2783FDFB181697D200F3F6E9 /* Main.storyboard */; }; 17 | 2783FE00181697D200F3F6E9 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2783FDFF181697D200F3F6E9 /* ViewController.m */; }; 18 | 2783FE02181697D200F3F6E9 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2783FE01181697D200F3F6E9 /* Images.xcassets */; }; 19 | 2783FE09181697D200F3F6E9 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2783FE08181697D200F3F6E9 /* XCTest.framework */; }; 20 | 2783FE0A181697D200F3F6E9 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2783FDE9181697D200F3F6E9 /* Foundation.framework */; }; 21 | 2783FE0B181697D200F3F6E9 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2783FDED181697D200F3F6E9 /* UIKit.framework */; }; 22 | 2783FE13181697D300F3F6E9 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2783FE11181697D300F3F6E9 /* InfoPlist.strings */; }; 23 | 2783FE15181697D300F3F6E9 /* bfTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2783FE14181697D300F3F6E9 /* bfTests.m */; }; 24 | 2783FE1F1816990100F3F6E9 /* CoreImage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2783FE1E1816990100F3F6E9 /* CoreImage.framework */; }; 25 | 2783FE231816995F00F3F6E9 /* UIImageView+BetterFace.m in Sources */ = {isa = PBXBuildFile; fileRef = 2783FE221816995F00F3F6E9 /* UIImageView+BetterFace.m */; }; 26 | 2783FE331816ADF600F3F6E9 /* l1.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 2783FE261816ADF600F3F6E9 /* l1.jpg */; }; 27 | 2783FE341816ADF600F3F6E9 /* l2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 2783FE271816ADF600F3F6E9 /* l2.jpg */; }; 28 | 2783FE351816ADF600F3F6E9 /* l3.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 2783FE281816ADF600F3F6E9 /* l3.jpg */; }; 29 | 2783FE361816ADF600F3F6E9 /* m1.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 2783FE2A1816ADF600F3F6E9 /* m1.jpg */; }; 30 | 2783FE371816ADF600F3F6E9 /* up1.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 2783FE2C1816ADF600F3F6E9 /* up1.jpg */; }; 31 | 2783FE381816ADF600F3F6E9 /* up2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 2783FE2D1816ADF600F3F6E9 /* up2.jpg */; }; 32 | 2783FE391816ADF600F3F6E9 /* up3.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 2783FE2E1816ADF600F3F6E9 /* up3.jpg */; }; 33 | 2783FE3E1816B80000F3F6E9 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2783FE3D1816B80000F3F6E9 /* QuartzCore.framework */; }; 34 | 27A3C2681D5D5DA100EF6666 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 27A3C2671D5D5DA100EF6666 /* Launch Screen.storyboard */; }; 35 | 27C77B4F181707E300F3F073 /* up4.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 27C77B4E181707E300F3F073 /* up4.jpg */; }; 36 | 27C77B51181708BF00F3F073 /* l4.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 27C77B50181708BF00F3F073 /* l4.jpg */; }; 37 | 27C77B53181709F000F3F073 /* m2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 27C77B52181709F000F3F073 /* m2.jpg */; }; 38 | 75D56B911842F39B00D87BCD /* UIImage+BetterFace.m in Sources */ = {isa = PBXBuildFile; fileRef = 75D56B901842F39B00D87BCD /* UIImage+BetterFace.m */; }; 39 | /* End PBXBuildFile section */ 40 | 41 | /* Begin PBXContainerItemProxy section */ 42 | 2783FE0C181697D300F3F6E9 /* PBXContainerItemProxy */ = { 43 | isa = PBXContainerItemProxy; 44 | containerPortal = 2783FDDE181697D200F3F6E9 /* Project object */; 45 | proxyType = 1; 46 | remoteGlobalIDString = 2783FDE5181697D200F3F6E9; 47 | remoteInfo = bf; 48 | }; 49 | /* End PBXContainerItemProxy section */ 50 | 51 | /* Begin PBXFileReference section */ 52 | 2783FDE6181697D200F3F6E9 /* bf.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = bf.app; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 2783FDE9181697D200F3F6E9 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 54 | 2783FDEB181697D200F3F6E9 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 55 | 2783FDED181697D200F3F6E9 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 56 | 2783FDF1181697D200F3F6E9 /* bf-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "bf-Info.plist"; sourceTree = ""; }; 57 | 2783FDF3181697D200F3F6E9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 58 | 2783FDF5181697D200F3F6E9 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 59 | 2783FDF7181697D200F3F6E9 /* bf-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "bf-Prefix.pch"; sourceTree = ""; }; 60 | 2783FDF8181697D200F3F6E9 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 61 | 2783FDF9181697D200F3F6E9 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 62 | 2783FDFC181697D200F3F6E9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 63 | 2783FDFE181697D200F3F6E9 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 64 | 2783FDFF181697D200F3F6E9 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 65 | 2783FE01181697D200F3F6E9 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 66 | 2783FE07181697D200F3F6E9 /* bfTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = bfTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 67 | 2783FE08181697D200F3F6E9 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 68 | 2783FE10181697D300F3F6E9 /* bfTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "bfTests-Info.plist"; sourceTree = ""; }; 69 | 2783FE12181697D300F3F6E9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 70 | 2783FE14181697D300F3F6E9 /* bfTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = bfTests.m; sourceTree = ""; }; 71 | 2783FE1E1816990100F3F6E9 /* CoreImage.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreImage.framework; path = System/Library/Frameworks/CoreImage.framework; sourceTree = SDKROOT; }; 72 | 2783FE211816995F00F3F6E9 /* UIImageView+BetterFace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+BetterFace.h"; sourceTree = ""; }; 73 | 2783FE221816995F00F3F6E9 /* UIImageView+BetterFace.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+BetterFace.m"; sourceTree = ""; }; 74 | 2783FE261816ADF600F3F6E9 /* l1.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = l1.jpg; sourceTree = ""; }; 75 | 2783FE271816ADF600F3F6E9 /* l2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = l2.jpg; sourceTree = ""; }; 76 | 2783FE281816ADF600F3F6E9 /* l3.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = l3.jpg; sourceTree = ""; }; 77 | 2783FE2A1816ADF600F3F6E9 /* m1.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = m1.jpg; sourceTree = ""; }; 78 | 2783FE2C1816ADF600F3F6E9 /* up1.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = up1.jpg; sourceTree = ""; }; 79 | 2783FE2D1816ADF600F3F6E9 /* up2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = up2.jpg; sourceTree = ""; }; 80 | 2783FE2E1816ADF600F3F6E9 /* up3.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = up3.jpg; sourceTree = ""; }; 81 | 2783FE3D1816B80000F3F6E9 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 82 | 27A3C2671D5D5DA100EF6666 /* Launch Screen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = ""; }; 83 | 27C77B4E181707E300F3F073 /* up4.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = up4.jpg; sourceTree = ""; }; 84 | 27C77B50181708BF00F3F073 /* l4.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = l4.jpg; sourceTree = ""; }; 85 | 27C77B52181709F000F3F073 /* m2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = m2.jpg; sourceTree = ""; }; 86 | 75D56B8F1842F39B00D87BCD /* UIImage+BetterFace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+BetterFace.h"; sourceTree = ""; }; 87 | 75D56B901842F39B00D87BCD /* UIImage+BetterFace.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+BetterFace.m"; sourceTree = ""; }; 88 | /* End PBXFileReference section */ 89 | 90 | /* Begin PBXFrameworksBuildPhase section */ 91 | 2783FDE3181697D200F3F6E9 /* Frameworks */ = { 92 | isa = PBXFrameworksBuildPhase; 93 | buildActionMask = 2147483647; 94 | files = ( 95 | 2783FE3E1816B80000F3F6E9 /* QuartzCore.framework in Frameworks */, 96 | 2783FE1F1816990100F3F6E9 /* CoreImage.framework in Frameworks */, 97 | 2783FDEC181697D200F3F6E9 /* CoreGraphics.framework in Frameworks */, 98 | 2783FDEE181697D200F3F6E9 /* UIKit.framework in Frameworks */, 99 | 2783FDEA181697D200F3F6E9 /* Foundation.framework in Frameworks */, 100 | ); 101 | runOnlyForDeploymentPostprocessing = 0; 102 | }; 103 | 2783FE04181697D200F3F6E9 /* Frameworks */ = { 104 | isa = PBXFrameworksBuildPhase; 105 | buildActionMask = 2147483647; 106 | files = ( 107 | 2783FE09181697D200F3F6E9 /* XCTest.framework in Frameworks */, 108 | 2783FE0B181697D200F3F6E9 /* UIKit.framework in Frameworks */, 109 | 2783FE0A181697D200F3F6E9 /* Foundation.framework in Frameworks */, 110 | ); 111 | runOnlyForDeploymentPostprocessing = 0; 112 | }; 113 | /* End PBXFrameworksBuildPhase section */ 114 | 115 | /* Begin PBXGroup section */ 116 | 2783FDDD181697D200F3F6E9 = { 117 | isa = PBXGroup; 118 | children = ( 119 | 2783FDEF181697D200F3F6E9 /* bf */, 120 | 2783FE0E181697D300F3F6E9 /* bfTests */, 121 | 2783FDE8181697D200F3F6E9 /* Frameworks */, 122 | 2783FDE7181697D200F3F6E9 /* Products */, 123 | ); 124 | sourceTree = ""; 125 | }; 126 | 2783FDE7181697D200F3F6E9 /* Products */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | 2783FDE6181697D200F3F6E9 /* bf.app */, 130 | 2783FE07181697D200F3F6E9 /* bfTests.xctest */, 131 | ); 132 | name = Products; 133 | sourceTree = ""; 134 | }; 135 | 2783FDE8181697D200F3F6E9 /* Frameworks */ = { 136 | isa = PBXGroup; 137 | children = ( 138 | 2783FE3D1816B80000F3F6E9 /* QuartzCore.framework */, 139 | 2783FE1E1816990100F3F6E9 /* CoreImage.framework */, 140 | 2783FDE9181697D200F3F6E9 /* Foundation.framework */, 141 | 2783FDEB181697D200F3F6E9 /* CoreGraphics.framework */, 142 | 2783FDED181697D200F3F6E9 /* UIKit.framework */, 143 | 2783FE08181697D200F3F6E9 /* XCTest.framework */, 144 | ); 145 | name = Frameworks; 146 | sourceTree = ""; 147 | }; 148 | 2783FDEF181697D200F3F6E9 /* bf */ = { 149 | isa = PBXGroup; 150 | children = ( 151 | 2783FE201816993800F3F6E9 /* BetterFaceClass */, 152 | 2783FE241816ADF600F3F6E9 /* Images */, 153 | 2783FDF8181697D200F3F6E9 /* AppDelegate.h */, 154 | 2783FDF9181697D200F3F6E9 /* AppDelegate.m */, 155 | 2783FDFB181697D200F3F6E9 /* Main.storyboard */, 156 | 27A3C2671D5D5DA100EF6666 /* Launch Screen.storyboard */, 157 | 2783FDFE181697D200F3F6E9 /* ViewController.h */, 158 | 2783FDFF181697D200F3F6E9 /* ViewController.m */, 159 | 2783FE01181697D200F3F6E9 /* Images.xcassets */, 160 | 2783FDF0181697D200F3F6E9 /* Supporting Files */, 161 | ); 162 | path = bf; 163 | sourceTree = ""; 164 | }; 165 | 2783FDF0181697D200F3F6E9 /* Supporting Files */ = { 166 | isa = PBXGroup; 167 | children = ( 168 | 2783FDF1181697D200F3F6E9 /* bf-Info.plist */, 169 | 2783FDF2181697D200F3F6E9 /* InfoPlist.strings */, 170 | 2783FDF5181697D200F3F6E9 /* main.m */, 171 | 2783FDF7181697D200F3F6E9 /* bf-Prefix.pch */, 172 | ); 173 | name = "Supporting Files"; 174 | sourceTree = ""; 175 | }; 176 | 2783FE0E181697D300F3F6E9 /* bfTests */ = { 177 | isa = PBXGroup; 178 | children = ( 179 | 2783FE14181697D300F3F6E9 /* bfTests.m */, 180 | 2783FE0F181697D300F3F6E9 /* Supporting Files */, 181 | ); 182 | path = bfTests; 183 | sourceTree = ""; 184 | }; 185 | 2783FE0F181697D300F3F6E9 /* Supporting Files */ = { 186 | isa = PBXGroup; 187 | children = ( 188 | 2783FE10181697D300F3F6E9 /* bfTests-Info.plist */, 189 | 2783FE11181697D300F3F6E9 /* InfoPlist.strings */, 190 | ); 191 | name = "Supporting Files"; 192 | sourceTree = ""; 193 | }; 194 | 2783FE201816993800F3F6E9 /* BetterFaceClass */ = { 195 | isa = PBXGroup; 196 | children = ( 197 | 2783FE211816995F00F3F6E9 /* UIImageView+BetterFace.h */, 198 | 2783FE221816995F00F3F6E9 /* UIImageView+BetterFace.m */, 199 | 75D56B8F1842F39B00D87BCD /* UIImage+BetterFace.h */, 200 | 75D56B901842F39B00D87BCD /* UIImage+BetterFace.m */, 201 | ); 202 | path = BetterFaceClass; 203 | sourceTree = ""; 204 | }; 205 | 2783FE241816ADF600F3F6E9 /* Images */ = { 206 | isa = PBXGroup; 207 | children = ( 208 | 2783FE251816ADF600F3F6E9 /* landscape */, 209 | 2783FE291816ADF600F3F6E9 /* multiple */, 210 | 2783FE2B1816ADF600F3F6E9 /* up */, 211 | ); 212 | path = Images; 213 | sourceTree = ""; 214 | }; 215 | 2783FE251816ADF600F3F6E9 /* landscape */ = { 216 | isa = PBXGroup; 217 | children = ( 218 | 2783FE261816ADF600F3F6E9 /* l1.jpg */, 219 | 2783FE271816ADF600F3F6E9 /* l2.jpg */, 220 | 2783FE281816ADF600F3F6E9 /* l3.jpg */, 221 | 27C77B50181708BF00F3F073 /* l4.jpg */, 222 | ); 223 | path = landscape; 224 | sourceTree = ""; 225 | }; 226 | 2783FE291816ADF600F3F6E9 /* multiple */ = { 227 | isa = PBXGroup; 228 | children = ( 229 | 2783FE2A1816ADF600F3F6E9 /* m1.jpg */, 230 | 27C77B52181709F000F3F073 /* m2.jpg */, 231 | ); 232 | path = multiple; 233 | sourceTree = ""; 234 | }; 235 | 2783FE2B1816ADF600F3F6E9 /* up */ = { 236 | isa = PBXGroup; 237 | children = ( 238 | 2783FE2C1816ADF600F3F6E9 /* up1.jpg */, 239 | 2783FE2D1816ADF600F3F6E9 /* up2.jpg */, 240 | 2783FE2E1816ADF600F3F6E9 /* up3.jpg */, 241 | 27C77B4E181707E300F3F073 /* up4.jpg */, 242 | ); 243 | path = up; 244 | sourceTree = ""; 245 | }; 246 | /* End PBXGroup section */ 247 | 248 | /* Begin PBXNativeTarget section */ 249 | 2783FDE5181697D200F3F6E9 /* bf */ = { 250 | isa = PBXNativeTarget; 251 | buildConfigurationList = 2783FE18181697D300F3F6E9 /* Build configuration list for PBXNativeTarget "bf" */; 252 | buildPhases = ( 253 | 2783FDE2181697D200F3F6E9 /* Sources */, 254 | 2783FDE3181697D200F3F6E9 /* Frameworks */, 255 | 2783FDE4181697D200F3F6E9 /* Resources */, 256 | ); 257 | buildRules = ( 258 | ); 259 | dependencies = ( 260 | ); 261 | name = bf; 262 | productName = bf; 263 | productReference = 2783FDE6181697D200F3F6E9 /* bf.app */; 264 | productType = "com.apple.product-type.application"; 265 | }; 266 | 2783FE06181697D200F3F6E9 /* bfTests */ = { 267 | isa = PBXNativeTarget; 268 | buildConfigurationList = 2783FE1B181697D300F3F6E9 /* Build configuration list for PBXNativeTarget "bfTests" */; 269 | buildPhases = ( 270 | 2783FE03181697D200F3F6E9 /* Sources */, 271 | 2783FE04181697D200F3F6E9 /* Frameworks */, 272 | 2783FE05181697D200F3F6E9 /* Resources */, 273 | ); 274 | buildRules = ( 275 | ); 276 | dependencies = ( 277 | 2783FE0D181697D300F3F6E9 /* PBXTargetDependency */, 278 | ); 279 | name = bfTests; 280 | productName = bfTests; 281 | productReference = 2783FE07181697D200F3F6E9 /* bfTests.xctest */; 282 | productType = "com.apple.product-type.bundle.unit-test"; 283 | }; 284 | /* End PBXNativeTarget section */ 285 | 286 | /* Begin PBXProject section */ 287 | 2783FDDE181697D200F3F6E9 /* Project object */ = { 288 | isa = PBXProject; 289 | attributes = { 290 | LastUpgradeCheck = 0730; 291 | ORGANIZATIONNAME = Croath; 292 | TargetAttributes = { 293 | 2783FE06181697D200F3F6E9 = { 294 | TestTargetID = 2783FDE5181697D200F3F6E9; 295 | }; 296 | }; 297 | }; 298 | buildConfigurationList = 2783FDE1181697D200F3F6E9 /* Build configuration list for PBXProject "bf" */; 299 | compatibilityVersion = "Xcode 3.2"; 300 | developmentRegion = English; 301 | hasScannedForEncodings = 0; 302 | knownRegions = ( 303 | en, 304 | Base, 305 | ); 306 | mainGroup = 2783FDDD181697D200F3F6E9; 307 | productRefGroup = 2783FDE7181697D200F3F6E9 /* Products */; 308 | projectDirPath = ""; 309 | projectRoot = ""; 310 | targets = ( 311 | 2783FDE5181697D200F3F6E9 /* bf */, 312 | 2783FE06181697D200F3F6E9 /* bfTests */, 313 | ); 314 | }; 315 | /* End PBXProject section */ 316 | 317 | /* Begin PBXResourcesBuildPhase section */ 318 | 2783FDE4181697D200F3F6E9 /* Resources */ = { 319 | isa = PBXResourcesBuildPhase; 320 | buildActionMask = 2147483647; 321 | files = ( 322 | 27C77B53181709F000F3F073 /* m2.jpg in Resources */, 323 | 2783FE351816ADF600F3F6E9 /* l3.jpg in Resources */, 324 | 2783FE361816ADF600F3F6E9 /* m1.jpg in Resources */, 325 | 2783FE341816ADF600F3F6E9 /* l2.jpg in Resources */, 326 | 2783FE381816ADF600F3F6E9 /* up2.jpg in Resources */, 327 | 2783FE02181697D200F3F6E9 /* Images.xcassets in Resources */, 328 | 27A3C2681D5D5DA100EF6666 /* Launch Screen.storyboard in Resources */, 329 | 27C77B51181708BF00F3F073 /* l4.jpg in Resources */, 330 | 2783FE371816ADF600F3F6E9 /* up1.jpg in Resources */, 331 | 2783FDF4181697D200F3F6E9 /* InfoPlist.strings in Resources */, 332 | 2783FE331816ADF600F3F6E9 /* l1.jpg in Resources */, 333 | 27C77B4F181707E300F3F073 /* up4.jpg in Resources */, 334 | 2783FE391816ADF600F3F6E9 /* up3.jpg in Resources */, 335 | 2783FDFD181697D200F3F6E9 /* Main.storyboard in Resources */, 336 | ); 337 | runOnlyForDeploymentPostprocessing = 0; 338 | }; 339 | 2783FE05181697D200F3F6E9 /* Resources */ = { 340 | isa = PBXResourcesBuildPhase; 341 | buildActionMask = 2147483647; 342 | files = ( 343 | 2783FE13181697D300F3F6E9 /* InfoPlist.strings in Resources */, 344 | ); 345 | runOnlyForDeploymentPostprocessing = 0; 346 | }; 347 | /* End PBXResourcesBuildPhase section */ 348 | 349 | /* Begin PBXSourcesBuildPhase section */ 350 | 2783FDE2181697D200F3F6E9 /* Sources */ = { 351 | isa = PBXSourcesBuildPhase; 352 | buildActionMask = 2147483647; 353 | files = ( 354 | 75D56B911842F39B00D87BCD /* UIImage+BetterFace.m in Sources */, 355 | 2783FE00181697D200F3F6E9 /* ViewController.m in Sources */, 356 | 2783FDFA181697D200F3F6E9 /* AppDelegate.m in Sources */, 357 | 2783FDF6181697D200F3F6E9 /* main.m in Sources */, 358 | 2783FE231816995F00F3F6E9 /* UIImageView+BetterFace.m in Sources */, 359 | ); 360 | runOnlyForDeploymentPostprocessing = 0; 361 | }; 362 | 2783FE03181697D200F3F6E9 /* Sources */ = { 363 | isa = PBXSourcesBuildPhase; 364 | buildActionMask = 2147483647; 365 | files = ( 366 | 2783FE15181697D300F3F6E9 /* bfTests.m in Sources */, 367 | ); 368 | runOnlyForDeploymentPostprocessing = 0; 369 | }; 370 | /* End PBXSourcesBuildPhase section */ 371 | 372 | /* Begin PBXTargetDependency section */ 373 | 2783FE0D181697D300F3F6E9 /* PBXTargetDependency */ = { 374 | isa = PBXTargetDependency; 375 | target = 2783FDE5181697D200F3F6E9 /* bf */; 376 | targetProxy = 2783FE0C181697D300F3F6E9 /* PBXContainerItemProxy */; 377 | }; 378 | /* End PBXTargetDependency section */ 379 | 380 | /* Begin PBXVariantGroup section */ 381 | 2783FDF2181697D200F3F6E9 /* InfoPlist.strings */ = { 382 | isa = PBXVariantGroup; 383 | children = ( 384 | 2783FDF3181697D200F3F6E9 /* en */, 385 | ); 386 | name = InfoPlist.strings; 387 | sourceTree = ""; 388 | }; 389 | 2783FDFB181697D200F3F6E9 /* Main.storyboard */ = { 390 | isa = PBXVariantGroup; 391 | children = ( 392 | 2783FDFC181697D200F3F6E9 /* Base */, 393 | ); 394 | name = Main.storyboard; 395 | sourceTree = ""; 396 | }; 397 | 2783FE11181697D300F3F6E9 /* InfoPlist.strings */ = { 398 | isa = PBXVariantGroup; 399 | children = ( 400 | 2783FE12181697D300F3F6E9 /* en */, 401 | ); 402 | name = InfoPlist.strings; 403 | sourceTree = ""; 404 | }; 405 | /* End PBXVariantGroup section */ 406 | 407 | /* Begin XCBuildConfiguration section */ 408 | 2783FE16181697D300F3F6E9 /* Debug */ = { 409 | isa = XCBuildConfiguration; 410 | buildSettings = { 411 | ALWAYS_SEARCH_USER_PATHS = NO; 412 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 413 | CLANG_CXX_LIBRARY = "libc++"; 414 | CLANG_ENABLE_MODULES = YES; 415 | CLANG_ENABLE_OBJC_ARC = YES; 416 | CLANG_WARN_BOOL_CONVERSION = YES; 417 | CLANG_WARN_CONSTANT_CONVERSION = YES; 418 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 419 | CLANG_WARN_EMPTY_BODY = YES; 420 | CLANG_WARN_ENUM_CONVERSION = YES; 421 | CLANG_WARN_INT_CONVERSION = YES; 422 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 423 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 424 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 425 | COPY_PHASE_STRIP = NO; 426 | ENABLE_TESTABILITY = YES; 427 | GCC_C_LANGUAGE_STANDARD = gnu99; 428 | GCC_DYNAMIC_NO_PIC = NO; 429 | GCC_OPTIMIZATION_LEVEL = 0; 430 | GCC_PREPROCESSOR_DEFINITIONS = ( 431 | "DEBUG=1", 432 | "$(inherited)", 433 | ); 434 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 435 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 436 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 437 | GCC_WARN_UNDECLARED_SELECTOR = YES; 438 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 439 | GCC_WARN_UNUSED_FUNCTION = YES; 440 | GCC_WARN_UNUSED_VARIABLE = YES; 441 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 442 | ONLY_ACTIVE_ARCH = YES; 443 | SDKROOT = iphoneos; 444 | }; 445 | name = Debug; 446 | }; 447 | 2783FE17181697D300F3F6E9 /* Release */ = { 448 | isa = XCBuildConfiguration; 449 | buildSettings = { 450 | ALWAYS_SEARCH_USER_PATHS = NO; 451 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 452 | CLANG_CXX_LIBRARY = "libc++"; 453 | CLANG_ENABLE_MODULES = YES; 454 | CLANG_ENABLE_OBJC_ARC = YES; 455 | CLANG_WARN_BOOL_CONVERSION = YES; 456 | CLANG_WARN_CONSTANT_CONVERSION = YES; 457 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 458 | CLANG_WARN_EMPTY_BODY = YES; 459 | CLANG_WARN_ENUM_CONVERSION = YES; 460 | CLANG_WARN_INT_CONVERSION = YES; 461 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 462 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 463 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 464 | COPY_PHASE_STRIP = YES; 465 | ENABLE_NS_ASSERTIONS = NO; 466 | GCC_C_LANGUAGE_STANDARD = gnu99; 467 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 468 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 469 | GCC_WARN_UNDECLARED_SELECTOR = YES; 470 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 471 | GCC_WARN_UNUSED_FUNCTION = YES; 472 | GCC_WARN_UNUSED_VARIABLE = YES; 473 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 474 | SDKROOT = iphoneos; 475 | VALIDATE_PRODUCT = YES; 476 | }; 477 | name = Release; 478 | }; 479 | 2783FE19181697D300F3F6E9 /* Debug */ = { 480 | isa = XCBuildConfiguration; 481 | buildSettings = { 482 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 483 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 484 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 485 | GCC_PREFIX_HEADER = "bf/bf-Prefix.pch"; 486 | INFOPLIST_FILE = "bf/bf-Info.plist"; 487 | PRODUCT_BUNDLE_IDENTIFIER = "com.croath.${PRODUCT_NAME:rfc1034identifier}"; 488 | PRODUCT_NAME = "$(TARGET_NAME)"; 489 | WRAPPER_EXTENSION = app; 490 | }; 491 | name = Debug; 492 | }; 493 | 2783FE1A181697D300F3F6E9 /* Release */ = { 494 | isa = XCBuildConfiguration; 495 | buildSettings = { 496 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 497 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 498 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 499 | GCC_PREFIX_HEADER = "bf/bf-Prefix.pch"; 500 | INFOPLIST_FILE = "bf/bf-Info.plist"; 501 | PRODUCT_BUNDLE_IDENTIFIER = "com.croath.${PRODUCT_NAME:rfc1034identifier}"; 502 | PRODUCT_NAME = "$(TARGET_NAME)"; 503 | WRAPPER_EXTENSION = app; 504 | }; 505 | name = Release; 506 | }; 507 | 2783FE1C181697D300F3F6E9 /* Debug */ = { 508 | isa = XCBuildConfiguration; 509 | buildSettings = { 510 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/bf.app/bf"; 511 | FRAMEWORK_SEARCH_PATHS = ( 512 | "$(SDKROOT)/Developer/Library/Frameworks", 513 | "$(inherited)", 514 | "$(DEVELOPER_FRAMEWORKS_DIR)", 515 | ); 516 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 517 | GCC_PREFIX_HEADER = "bf/bf-Prefix.pch"; 518 | GCC_PREPROCESSOR_DEFINITIONS = ( 519 | "DEBUG=1", 520 | "$(inherited)", 521 | ); 522 | INFOPLIST_FILE = "bfTests/bfTests-Info.plist"; 523 | PRODUCT_BUNDLE_IDENTIFIER = "com.croath.${PRODUCT_NAME:rfc1034identifier}"; 524 | PRODUCT_NAME = "$(TARGET_NAME)"; 525 | TEST_HOST = "$(BUNDLE_LOADER)"; 526 | WRAPPER_EXTENSION = xctest; 527 | }; 528 | name = Debug; 529 | }; 530 | 2783FE1D181697D300F3F6E9 /* Release */ = { 531 | isa = XCBuildConfiguration; 532 | buildSettings = { 533 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/bf.app/bf"; 534 | FRAMEWORK_SEARCH_PATHS = ( 535 | "$(SDKROOT)/Developer/Library/Frameworks", 536 | "$(inherited)", 537 | "$(DEVELOPER_FRAMEWORKS_DIR)", 538 | ); 539 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 540 | GCC_PREFIX_HEADER = "bf/bf-Prefix.pch"; 541 | INFOPLIST_FILE = "bfTests/bfTests-Info.plist"; 542 | PRODUCT_BUNDLE_IDENTIFIER = "com.croath.${PRODUCT_NAME:rfc1034identifier}"; 543 | PRODUCT_NAME = "$(TARGET_NAME)"; 544 | TEST_HOST = "$(BUNDLE_LOADER)"; 545 | WRAPPER_EXTENSION = xctest; 546 | }; 547 | name = Release; 548 | }; 549 | /* End XCBuildConfiguration section */ 550 | 551 | /* Begin XCConfigurationList section */ 552 | 2783FDE1181697D200F3F6E9 /* Build configuration list for PBXProject "bf" */ = { 553 | isa = XCConfigurationList; 554 | buildConfigurations = ( 555 | 2783FE16181697D300F3F6E9 /* Debug */, 556 | 2783FE17181697D300F3F6E9 /* Release */, 557 | ); 558 | defaultConfigurationIsVisible = 0; 559 | defaultConfigurationName = Release; 560 | }; 561 | 2783FE18181697D300F3F6E9 /* Build configuration list for PBXNativeTarget "bf" */ = { 562 | isa = XCConfigurationList; 563 | buildConfigurations = ( 564 | 2783FE19181697D300F3F6E9 /* Debug */, 565 | 2783FE1A181697D300F3F6E9 /* Release */, 566 | ); 567 | defaultConfigurationIsVisible = 0; 568 | defaultConfigurationName = Release; 569 | }; 570 | 2783FE1B181697D300F3F6E9 /* Build configuration list for PBXNativeTarget "bfTests" */ = { 571 | isa = XCConfigurationList; 572 | buildConfigurations = ( 573 | 2783FE1C181697D300F3F6E9 /* Debug */, 574 | 2783FE1D181697D300F3F6E9 /* Release */, 575 | ); 576 | defaultConfigurationIsVisible = 0; 577 | defaultConfigurationName = Release; 578 | }; 579 | /* End XCConfigurationList section */ 580 | }; 581 | rootObject = 2783FDDE181697D200F3F6E9 /* Project object */; 582 | } 583 | -------------------------------------------------------------------------------- /bf/bf.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bf/bf.xcodeproj/xcshareddata/xcschemes/bf.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /bf/bf/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // bf 4 | // 5 | // Created by croath on 13-10-22. 6 | // Copyright (c) 2013年 Croath. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /bf/bf/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // bf 4 | // 5 | // Created by croath on 13-10-22. 6 | // Copyright (c) 2013年 Croath. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @implementation AppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | // Override point for customization after application launch. 16 | return YES; 17 | } 18 | 19 | - (void)applicationWillResignActive:(UIApplication *)application 20 | { 21 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 22 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 23 | } 24 | 25 | - (void)applicationDidEnterBackground:(UIApplication *)application 26 | { 27 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | - (void)applicationWillEnterForeground:(UIApplication *)application 32 | { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | - (void)applicationDidBecomeActive:(UIApplication *)application 37 | { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application 42 | { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /bf/bf/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 96 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /bf/bf/BetterFaceClass/UIImage+BetterFace.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+BetterFace.h 3 | // bf 4 | // 5 | // Created by liuyan on 13-11-25. 6 | // Copyright (c) 2013年 Croath. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSUInteger, BFAccuracy) { 12 | kBFAccuracyLow = 0, 13 | kBFAccuracyHigh, 14 | }; 15 | 16 | @interface UIImage (BetterFace) 17 | 18 | - (UIImage *)betterFaceImageForSize:(CGSize)size 19 | accuracy:(BFAccuracy)accurary; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /bf/bf/BetterFaceClass/UIImage+BetterFace.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+BetterFace.m 3 | // bf 4 | // 5 | // Created by liuyan on 13-11-25. 6 | // Copyright (c) 2013年 Croath. All rights reserved. 7 | // 8 | 9 | #import "UIImage+BetterFace.h" 10 | 11 | #define GOLDEN_RATIO (0.618) 12 | 13 | #ifdef BF_DEBUG 14 | #define BFLog(format...) NSLog(format) 15 | #else 16 | #define BFLog(format...) 17 | #endif 18 | 19 | @implementation UIImage (BetterFace) 20 | 21 | - (UIImage *)betterFaceImageForSize:(CGSize)size 22 | accuracy:(BFAccuracy)accurary; 23 | { 24 | NSArray *features = [UIImage _faceFeaturesInImage:self accuracy:accurary]; 25 | 26 | if ([features count]==0) { 27 | BFLog(@"no faces"); 28 | return nil; 29 | } else { 30 | BFLog(@"succeed %lu faces", (unsigned long)[features count]); 31 | return [self _subImageForFaceFeatures:features 32 | size:size]; 33 | } 34 | } 35 | 36 | - (UIImage *)_subImageForFaceFeatures:(NSArray *)faceFeatures size:(CGSize)size 37 | { 38 | CGRect fixedRect = CGRectMake(MAXFLOAT, MAXFLOAT, 0, 0); 39 | CGFloat rightBorder = 0, bottomBorder = 0; 40 | CGSize imageSize = self.size; 41 | 42 | for (CIFaceFeature * faceFeature in faceFeatures){ 43 | CGRect oneRect = faceFeature.bounds; 44 | // Mirror the frame of the feature 45 | oneRect.origin.y = imageSize.height - oneRect.origin.y - oneRect.size.height; 46 | 47 | // Always get the minimum x & y 48 | fixedRect.origin.x = MIN(oneRect.origin.x, fixedRect.origin.x); 49 | fixedRect.origin.y = MIN(oneRect.origin.y, fixedRect.origin.y); 50 | 51 | // Calculate the faces rectangle 52 | rightBorder = MAX(oneRect.origin.x + oneRect.size.width, rightBorder); 53 | bottomBorder = MAX(oneRect.origin.y + oneRect.size.height, bottomBorder); 54 | } 55 | 56 | // Calculate the size of rectangle of faces 57 | fixedRect.size.width = rightBorder - fixedRect.origin.x; 58 | fixedRect.size.height = bottomBorder - fixedRect.origin.y; 59 | 60 | CGPoint fixedCenter = CGPointMake(fixedRect.origin.x + fixedRect.size.width / 2.0, 61 | fixedRect.origin.y + fixedRect.size.height / 2.0); 62 | CGPoint offset = CGPointZero; 63 | CGSize finalSize = imageSize; 64 | if (imageSize.width / imageSize.height > size.width / size.height) { 65 | //move horizonal 66 | finalSize.height = size.height; 67 | finalSize.width = imageSize.width/imageSize.height * finalSize.height; 68 | 69 | // Scale the fixed center with image scale(scale image to adjust image view) 70 | fixedCenter.x = finalSize.width/imageSize.width * fixedCenter.x; 71 | fixedCenter.y = finalSize.width/imageSize.width * fixedCenter.y; 72 | 73 | offset.x = fixedCenter.x - size.width * 0.5; 74 | if (offset.x < 0) { 75 | // Move outside left 76 | offset.x = 0; 77 | } else if (offset.x + size.width > finalSize.width) { 78 | // Move outside right 79 | offset.x = finalSize.width - size.width; 80 | } 81 | 82 | // If you want the final image is fit to the image view, you should set the width adjust the image view. 83 | finalSize.width = size.width; 84 | } else { 85 | //move vertical 86 | finalSize.width = size.width; 87 | finalSize.height = imageSize.height/imageSize.width * finalSize.width; 88 | 89 | // Scale the fixed center with image scale(scale image to adjust image view) 90 | fixedCenter.x = finalSize.width/imageSize.width * fixedCenter.x; 91 | fixedCenter.y = finalSize.width/imageSize.width * fixedCenter.y; 92 | 93 | offset.y = fixedCenter.y - size.height * (1 - GOLDEN_RATIO); 94 | if (offset.y < 0) { 95 | // Move outside top 96 | offset.y = 0; 97 | } else if (offset.y + size.height > finalSize.height){ 98 | // Move outside bottom 99 | // offset.y = finalSize.height = size.height; 100 | offset.y = finalSize.height - size.height; 101 | } 102 | 103 | // If you want the final image is fit to the image view, you should set the height adjust the image view. 104 | finalSize.height = size.height; 105 | } 106 | 107 | // The finalSize is just fit the image view now, so we should scale the frame to the image size. 108 | CGFloat scale = imageSize.width/finalSize.width; 109 | CGAffineTransform transform = CGAffineTransformMakeScale(scale, scale); 110 | // Get the final image rect 111 | CGRect finalRect = CGRectApplyAffineTransform(CGRectMake(offset.x, offset.y, finalSize.width, finalSize.height),transform); 112 | // Creat image 113 | CGImageRef imageRef = CGImageCreateWithImageInRect([self CGImage], finalRect); 114 | UIImage *subImage = [UIImage imageWithCGImage:imageRef scale:self.scale orientation:self.imageOrientation]; 115 | CGImageRelease(imageRef); 116 | 117 | return subImage; 118 | } 119 | 120 | #pragma mark - Util 121 | 122 | + (NSArray *)_faceFeaturesInImage:(UIImage *)image accuracy:(BFAccuracy)accurary 123 | { 124 | CIImage *ciImage = [CIImage imageWithCGImage:image.CGImage]; 125 | NSString *accuraryStr = (accurary == kBFAccuracyLow) ? CIDetectorAccuracyLow : CIDetectorAccuracyHigh; 126 | 127 | CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeFace 128 | context:nil 129 | options:@{CIDetectorAccuracy: accuraryStr}]; 130 | 131 | return [detector featuresInImage:ciImage]; 132 | } 133 | 134 | @end 135 | -------------------------------------------------------------------------------- /bf/bf/BetterFaceClass/UIImageView+BetterFace.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageView+BetterFace.h 3 | // bf 4 | // 5 | // Created by croath on 13-10-22. 6 | // Copyright (c) 2013年 Croath. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImageView (BetterFace) 12 | 13 | @property (nonatomic) BOOL needsBetterFace; 14 | @property (nonatomic) BOOL fast; 15 | 16 | void hack_uiimageview_bf(); 17 | - (void)setBetterFaceImage:(UIImage *)image; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /bf/bf/BetterFaceClass/UIImageView+BetterFace.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageView+BetterFace.m 3 | // bf 4 | // 5 | // Created by croath on 13-10-22. 6 | // Copyright (c) 2013年 Croath. All rights reserved. 7 | // 8 | 9 | #import "UIImageView+BetterFace.h" 10 | #import 11 | #define BETTER_LAYER_NAME @"BETTER_LAYER_NAME" 12 | #define GOLDEN_RATIO (0.618) 13 | 14 | #ifdef BF_DEBUG 15 | #define BFLog(format...) NSLog(format) 16 | #else 17 | #define BFLog(format...) 18 | #endif 19 | 20 | static CIDetector *detector; 21 | 22 | @implementation UIImageView (BetterFace) 23 | 24 | void hack_uiimageview_bf(){ 25 | Method oriSetImgMethod = class_getInstanceMethod([UIImageView class], @selector(setImage:)); 26 | Method newSetImgMethod = class_getInstanceMethod([UIImageView class], @selector(_setBetterFaceImage:)); 27 | method_exchangeImplementations(newSetImgMethod, oriSetImgMethod); 28 | } 29 | 30 | - (void)setBetterFaceImage:(UIImage *)image{ 31 | [self setImage:image]; 32 | if (![self needsBetterFace]) { 33 | return; 34 | } 35 | 36 | [self faceDetect:image]; 37 | } 38 | 39 | - (void)_setBetterFaceImage:(UIImage *)image{ 40 | [self _setBetterFaceImage:image]; 41 | if (![self needsBetterFace]) { 42 | return; 43 | } 44 | 45 | [self faceDetect:image]; 46 | } 47 | 48 | char nbfKey; 49 | - (void)setNeedsBetterFace:(BOOL)needsBetterFace{ 50 | objc_setAssociatedObject(self, 51 | &nbfKey, 52 | [NSNumber numberWithBool:needsBetterFace], 53 | OBJC_ASSOCIATION_RETAIN_NONATOMIC); 54 | } 55 | 56 | - (BOOL)needsBetterFace{ 57 | NSNumber *associatedObject = objc_getAssociatedObject(self, &nbfKey); 58 | return [associatedObject boolValue]; 59 | } 60 | 61 | char fastSpeedKey; 62 | - (void)setFast:(BOOL)fast{ 63 | objc_setAssociatedObject(self, 64 | &fastSpeedKey, 65 | [NSNumber numberWithBool:fast], 66 | OBJC_ASSOCIATION_RETAIN_NONATOMIC); 67 | } 68 | 69 | char detectorKey; 70 | - (void)setDetector:(CIDetector *)detector{ 71 | objc_setAssociatedObject(self, 72 | &detectorKey, 73 | detector, 74 | OBJC_ASSOCIATION_RETAIN_NONATOMIC); 75 | } 76 | 77 | -(CIDetector *)detector{ 78 | return objc_getAssociatedObject(self, &detectorKey); 79 | } 80 | 81 | - (BOOL)fast{ 82 | NSNumber *associatedObject = objc_getAssociatedObject(self, &fastSpeedKey); 83 | return [associatedObject boolValue]; 84 | } 85 | 86 | - (void)faceDetect:(UIImage *)aImage 87 | { 88 | dispatch_queue_t queue = dispatch_queue_create("com.croath.betterface.queue", NULL); 89 | dispatch_async(queue, ^{ 90 | CIImage* image = aImage.CIImage; 91 | if (image == nil) { // just in case the UIImage was created using a CGImage revert to the previous, slower implementation 92 | image = [CIImage imageWithCGImage:aImage.CGImage]; 93 | } 94 | if (detector == nil) { 95 | NSDictionary *opts = [NSDictionary dictionaryWithObject:[self fast] ? CIDetectorAccuracyLow : CIDetectorAccuracyHigh 96 | forKey:CIDetectorAccuracy]; 97 | detector = [CIDetector detectorOfType:CIDetectorTypeFace 98 | context:nil 99 | options:opts]; 100 | } 101 | 102 | NSArray* features = [detector featuresInImage:image]; 103 | 104 | if ([features count] == 0) { 105 | BFLog(@"no faces"); 106 | dispatch_async(dispatch_get_main_queue(), ^{ 107 | [[self imageLayer] removeFromSuperlayer]; 108 | }); 109 | } else { 110 | BFLog(@"succeed %lu faces", (unsigned long)[features count]); 111 | [self markAfterFaceDetect:features 112 | size:CGSizeMake(CGImageGetWidth(aImage.CGImage), 113 | CGImageGetHeight(aImage.CGImage))]; 114 | } 115 | }); 116 | } 117 | 118 | -(void)markAfterFaceDetect:(NSArray *)features size:(CGSize)size{ 119 | CGRect fixedRect = CGRectMake(MAXFLOAT, MAXFLOAT, 0, 0); 120 | CGFloat rightBorder = 0, bottomBorder = 0; 121 | for (CIFaceFeature *f in features){ 122 | CGRect oneRect = f.bounds; 123 | oneRect.origin.y = size.height - oneRect.origin.y - oneRect.size.height; 124 | 125 | fixedRect.origin.x = MIN(oneRect.origin.x, fixedRect.origin.x); 126 | fixedRect.origin.y = MIN(oneRect.origin.y, fixedRect.origin.y); 127 | 128 | rightBorder = MAX(oneRect.origin.x + oneRect.size.width, rightBorder); 129 | bottomBorder = MAX(oneRect.origin.y + oneRect.size.height, bottomBorder); 130 | } 131 | 132 | fixedRect.size.width = rightBorder - fixedRect.origin.x; 133 | fixedRect.size.height = bottomBorder - fixedRect.origin.y; 134 | 135 | CGPoint fixedCenter = CGPointMake(fixedRect.origin.x + fixedRect.size.width / 2.0, 136 | fixedRect.origin.y + fixedRect.size.height / 2.0); 137 | CGPoint offset = CGPointZero; 138 | CGSize finalSize = size; 139 | if (size.width / size.height > self.bounds.size.width / self.bounds.size.height) { 140 | //move horizonal 141 | finalSize.height = self.bounds.size.height; 142 | finalSize.width = size.width/size.height * finalSize.height; 143 | fixedCenter.x = finalSize.width / size.width * fixedCenter.x; 144 | fixedCenter.y = finalSize.width / size.width * fixedCenter.y; 145 | 146 | offset.x = fixedCenter.x - self.bounds.size.width * 0.5; 147 | if (offset.x < 0) { 148 | offset.x = 0; 149 | } else if (offset.x + self.bounds.size.width > finalSize.width) { 150 | offset.x = finalSize.width - self.bounds.size.width; 151 | } 152 | offset.x = - offset.x; 153 | } else { 154 | //move vertical 155 | finalSize.width = self.bounds.size.width; 156 | finalSize.height = size.height/size.width * finalSize.width; 157 | fixedCenter.x = finalSize.width / size.width * fixedCenter.x; 158 | fixedCenter.y = finalSize.width / size.width * fixedCenter.y; 159 | 160 | offset.y = fixedCenter.y - self.bounds.size.height * (1-GOLDEN_RATIO); 161 | if (offset.y < 0) { 162 | offset.y = 0; 163 | } else if (offset.y + self.bounds.size.height > finalSize.height){ 164 | offset.y = finalSize.height - self.bounds.size.height; 165 | } 166 | offset.y = - offset.y; 167 | } 168 | 169 | dispatch_async(dispatch_get_main_queue(), ^{ 170 | CALayer *layer = [self imageLayer]; 171 | layer.frame = CGRectMake(offset.x, 172 | offset.y, 173 | finalSize.width, 174 | finalSize.height); 175 | layer.contents = (id)self.image.CGImage; 176 | }); 177 | } 178 | 179 | - (CALayer *)imageLayer { 180 | for (CALayer *layer in [self.layer sublayers]) { 181 | if ([[layer name] isEqualToString:BETTER_LAYER_NAME]) { 182 | return layer; 183 | } 184 | } 185 | 186 | CALayer *layer = [CALayer layer]; 187 | [layer setName:BETTER_LAYER_NAME]; 188 | layer.actions = @{@"contents": [NSNull null], 189 | @"bounds": [NSNull null], 190 | @"position": [NSNull null]}; 191 | [self.layer addSublayer:layer]; 192 | return layer; 193 | } 194 | 195 | @end 196 | -------------------------------------------------------------------------------- /bf/bf/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /bf/bf/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /bf/bf/Images/landscape/l1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/croath/UIImageView-BetterFace/de2b3ff3e17345eed20c5def7e4d1bd8ec1f97e5/bf/bf/Images/landscape/l1.jpg -------------------------------------------------------------------------------- /bf/bf/Images/landscape/l2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/croath/UIImageView-BetterFace/de2b3ff3e17345eed20c5def7e4d1bd8ec1f97e5/bf/bf/Images/landscape/l2.jpg -------------------------------------------------------------------------------- /bf/bf/Images/landscape/l3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/croath/UIImageView-BetterFace/de2b3ff3e17345eed20c5def7e4d1bd8ec1f97e5/bf/bf/Images/landscape/l3.jpg -------------------------------------------------------------------------------- /bf/bf/Images/landscape/l4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/croath/UIImageView-BetterFace/de2b3ff3e17345eed20c5def7e4d1bd8ec1f97e5/bf/bf/Images/landscape/l4.jpg -------------------------------------------------------------------------------- /bf/bf/Images/multiple/m1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/croath/UIImageView-BetterFace/de2b3ff3e17345eed20c5def7e4d1bd8ec1f97e5/bf/bf/Images/multiple/m1.jpg -------------------------------------------------------------------------------- /bf/bf/Images/multiple/m2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/croath/UIImageView-BetterFace/de2b3ff3e17345eed20c5def7e4d1bd8ec1f97e5/bf/bf/Images/multiple/m2.jpg -------------------------------------------------------------------------------- /bf/bf/Images/up/up1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/croath/UIImageView-BetterFace/de2b3ff3e17345eed20c5def7e4d1bd8ec1f97e5/bf/bf/Images/up/up1.jpg -------------------------------------------------------------------------------- /bf/bf/Images/up/up2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/croath/UIImageView-BetterFace/de2b3ff3e17345eed20c5def7e4d1bd8ec1f97e5/bf/bf/Images/up/up2.jpg -------------------------------------------------------------------------------- /bf/bf/Images/up/up3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/croath/UIImageView-BetterFace/de2b3ff3e17345eed20c5def7e4d1bd8ec1f97e5/bf/bf/Images/up/up3.jpg -------------------------------------------------------------------------------- /bf/bf/Images/up/up4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/croath/UIImageView-BetterFace/de2b3ff3e17345eed20c5def7e4d1bd8ec1f97e5/bf/bf/Images/up/up4.jpg -------------------------------------------------------------------------------- /bf/bf/Launch Screen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 27 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /bf/bf/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // bf 4 | // 5 | // Created by croath on 13-10-22. 6 | // Copyright (c) 2013年 Croath. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | @property (weak, nonatomic) IBOutlet UIImageView *view0; 13 | @property (weak, nonatomic) IBOutlet UIImageView *view1; 14 | 15 | - (IBAction)tabPressed:(id)sender; 16 | @end 17 | -------------------------------------------------------------------------------- /bf/bf/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // bf 4 | // 5 | // Created by croath on 13-10-22. 6 | // Copyright (c) 2013年 Croath. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import 11 | #import "UIImageView+BetterFace.h" 12 | 13 | @interface ViewController () 14 | 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | - (void)viewDidLoad 20 | { 21 | [super viewDidLoad]; 22 | [_view0.layer setBorderColor:[UIColor grayColor].CGColor]; 23 | [_view0.layer setBorderWidth:0.5f]; 24 | [_view0 setContentMode:UIViewContentModeScaleAspectFill]; 25 | [_view0 setClipsToBounds:YES]; 26 | 27 | [_view1.layer setBorderColor:[UIColor grayColor].CGColor]; 28 | [_view1.layer setBorderWidth:0.5f]; 29 | [_view1 setContentMode:UIViewContentModeScaleAspectFill]; 30 | [_view1 setClipsToBounds:YES]; 31 | [_view1 setNeedsBetterFace:YES]; 32 | [_view1 setFast:NO]; 33 | } 34 | 35 | - (IBAction)tabPressed:(id)sender { 36 | NSString *imageStr = @""; 37 | switch ([sender tag]) { 38 | case 0: 39 | imageStr = @"up1.jpg"; 40 | break; 41 | case 1: 42 | imageStr = @"up2.jpg"; 43 | break; 44 | case 2: 45 | imageStr = @"up3.jpg"; 46 | break; 47 | case 3: 48 | imageStr = @"up4.jpg"; 49 | break; 50 | case 4: 51 | imageStr = @"l1.jpg"; 52 | break; 53 | case 5: 54 | imageStr = @"l2.jpg"; 55 | break; 56 | case 6: 57 | imageStr = @"l3.jpg"; 58 | break; 59 | case 7: 60 | imageStr = @"l4.jpg"; 61 | break; 62 | case 8: 63 | imageStr = @"m1.jpg"; 64 | break; 65 | case 9: 66 | imageStr = @"m2.jpg"; 67 | break; 68 | default: 69 | break; 70 | } 71 | 72 | [_view0 setImage:[UIImage imageNamed:imageStr]]; 73 | [_view1 setImage:[UIImage imageNamed:imageStr]]; 74 | } 75 | @end 76 | -------------------------------------------------------------------------------- /bf/bf/bf-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | Launch Screen 29 | UIMainStoryboardFile 30 | Main 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /bf/bf/bf-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #define BF_DEBUG 17 | #endif 18 | -------------------------------------------------------------------------------- /bf/bf/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /bf/bf/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // bf 4 | // 5 | // Created by croath on 13-10-22. 6 | // Copyright (c) 2013年 Croath. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | #import "UIImageView+BetterFace.h" 13 | 14 | int main(int argc, char * argv[]) 15 | { 16 | @autoreleasepool { 17 | hack_uiimageview_bf(); 18 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /bf/bfTests/bfTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /bf/bfTests/bfTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // bfTests.m 3 | // bfTests 4 | // 5 | // Created by croath on 13-10-22. 6 | // Copyright (c) 2013年 Croath. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface bfTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation bfTests 16 | 17 | - (void)setUp 18 | { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown 24 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /bf/bfTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /doc/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/croath/UIImageView-BetterFace/de2b3ff3e17345eed20c5def7e4d1bd8ec1f97e5/doc/preview.png --------------------------------------------------------------------------------