├── CoverFlowLayout.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── CoverFlowLayout.xcscmblueprint │ └── xcuserdata │ │ └── Broccoli.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── Broccoli.xcuserdatad │ └── xcschemes │ ├── CoverFlowLayout.xcscheme │ └── xcschememanagement.plist ├── CoverFlowLayout ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── CoverFlowLayout.swift ├── Info.plist └── ViewController.swift └── README.md /CoverFlowLayout.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A43F3A011C074ABD0019A555 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A43F3A001C074ABD0019A555 /* AppDelegate.swift */; }; 11 | A43F3A031C074ABD0019A555 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A43F3A021C074ABD0019A555 /* ViewController.swift */; }; 12 | A43F3A061C074ABD0019A555 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A43F3A041C074ABD0019A555 /* Main.storyboard */; }; 13 | A43F3A081C074ABD0019A555 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A43F3A071C074ABD0019A555 /* Assets.xcassets */; }; 14 | A43F3A0B1C074ABD0019A555 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A43F3A091C074ABD0019A555 /* LaunchScreen.storyboard */; }; 15 | A43F3A131C074E770019A555 /* CoverFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = A43F3A121C074E770019A555 /* CoverFlowLayout.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | A43F39FD1C074ABD0019A555 /* CoverFlowLayout.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CoverFlowLayout.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | A43F3A001C074ABD0019A555 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 21 | A43F3A021C074ABD0019A555 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 22 | A43F3A051C074ABD0019A555 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 23 | A43F3A071C074ABD0019A555 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 24 | A43F3A0A1C074ABD0019A555 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 25 | A43F3A0C1C074ABD0019A555 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 26 | A43F3A121C074E770019A555 /* CoverFlowLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoverFlowLayout.swift; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | A43F39FA1C074ABD0019A555 /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | ); 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXFrameworksBuildPhase section */ 38 | 39 | /* Begin PBXGroup section */ 40 | A43F39F41C074ABD0019A555 = { 41 | isa = PBXGroup; 42 | children = ( 43 | A43F39FF1C074ABD0019A555 /* CoverFlowLayout */, 44 | A43F39FE1C074ABD0019A555 /* Products */, 45 | ); 46 | sourceTree = ""; 47 | }; 48 | A43F39FE1C074ABD0019A555 /* Products */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | A43F39FD1C074ABD0019A555 /* CoverFlowLayout.app */, 52 | ); 53 | name = Products; 54 | sourceTree = ""; 55 | }; 56 | A43F39FF1C074ABD0019A555 /* CoverFlowLayout */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | A43F3A001C074ABD0019A555 /* AppDelegate.swift */, 60 | A43F3A021C074ABD0019A555 /* ViewController.swift */, 61 | A43F3A121C074E770019A555 /* CoverFlowLayout.swift */, 62 | A43F3A041C074ABD0019A555 /* Main.storyboard */, 63 | A43F3A071C074ABD0019A555 /* Assets.xcassets */, 64 | A43F3A091C074ABD0019A555 /* LaunchScreen.storyboard */, 65 | A43F3A0C1C074ABD0019A555 /* Info.plist */, 66 | ); 67 | path = CoverFlowLayout; 68 | sourceTree = ""; 69 | }; 70 | /* End PBXGroup section */ 71 | 72 | /* Begin PBXNativeTarget section */ 73 | A43F39FC1C074ABD0019A555 /* CoverFlowLayout */ = { 74 | isa = PBXNativeTarget; 75 | buildConfigurationList = A43F3A0F1C074ABD0019A555 /* Build configuration list for PBXNativeTarget "CoverFlowLayout" */; 76 | buildPhases = ( 77 | A43F39F91C074ABD0019A555 /* Sources */, 78 | A43F39FA1C074ABD0019A555 /* Frameworks */, 79 | A43F39FB1C074ABD0019A555 /* Resources */, 80 | ); 81 | buildRules = ( 82 | ); 83 | dependencies = ( 84 | ); 85 | name = CoverFlowLayout; 86 | productName = CoverFlowLayout; 87 | productReference = A43F39FD1C074ABD0019A555 /* CoverFlowLayout.app */; 88 | productType = "com.apple.product-type.application"; 89 | }; 90 | /* End PBXNativeTarget section */ 91 | 92 | /* Begin PBXProject section */ 93 | A43F39F51C074ABD0019A555 /* Project object */ = { 94 | isa = PBXProject; 95 | attributes = { 96 | LastSwiftUpdateCheck = 0710; 97 | LastUpgradeCheck = 0710; 98 | ORGANIZATIONNAME = Broccoli; 99 | TargetAttributes = { 100 | A43F39FC1C074ABD0019A555 = { 101 | CreatedOnToolsVersion = 7.1.1; 102 | }; 103 | }; 104 | }; 105 | buildConfigurationList = A43F39F81C074ABD0019A555 /* Build configuration list for PBXProject "CoverFlowLayout" */; 106 | compatibilityVersion = "Xcode 3.2"; 107 | developmentRegion = English; 108 | hasScannedForEncodings = 0; 109 | knownRegions = ( 110 | en, 111 | Base, 112 | ); 113 | mainGroup = A43F39F41C074ABD0019A555; 114 | productRefGroup = A43F39FE1C074ABD0019A555 /* Products */; 115 | projectDirPath = ""; 116 | projectRoot = ""; 117 | targets = ( 118 | A43F39FC1C074ABD0019A555 /* CoverFlowLayout */, 119 | ); 120 | }; 121 | /* End PBXProject section */ 122 | 123 | /* Begin PBXResourcesBuildPhase section */ 124 | A43F39FB1C074ABD0019A555 /* Resources */ = { 125 | isa = PBXResourcesBuildPhase; 126 | buildActionMask = 2147483647; 127 | files = ( 128 | A43F3A0B1C074ABD0019A555 /* LaunchScreen.storyboard in Resources */, 129 | A43F3A081C074ABD0019A555 /* Assets.xcassets in Resources */, 130 | A43F3A061C074ABD0019A555 /* Main.storyboard in Resources */, 131 | ); 132 | runOnlyForDeploymentPostprocessing = 0; 133 | }; 134 | /* End PBXResourcesBuildPhase section */ 135 | 136 | /* Begin PBXSourcesBuildPhase section */ 137 | A43F39F91C074ABD0019A555 /* Sources */ = { 138 | isa = PBXSourcesBuildPhase; 139 | buildActionMask = 2147483647; 140 | files = ( 141 | A43F3A031C074ABD0019A555 /* ViewController.swift in Sources */, 142 | A43F3A131C074E770019A555 /* CoverFlowLayout.swift in Sources */, 143 | A43F3A011C074ABD0019A555 /* AppDelegate.swift in Sources */, 144 | ); 145 | runOnlyForDeploymentPostprocessing = 0; 146 | }; 147 | /* End PBXSourcesBuildPhase section */ 148 | 149 | /* Begin PBXVariantGroup section */ 150 | A43F3A041C074ABD0019A555 /* Main.storyboard */ = { 151 | isa = PBXVariantGroup; 152 | children = ( 153 | A43F3A051C074ABD0019A555 /* Base */, 154 | ); 155 | name = Main.storyboard; 156 | sourceTree = ""; 157 | }; 158 | A43F3A091C074ABD0019A555 /* LaunchScreen.storyboard */ = { 159 | isa = PBXVariantGroup; 160 | children = ( 161 | A43F3A0A1C074ABD0019A555 /* Base */, 162 | ); 163 | name = LaunchScreen.storyboard; 164 | sourceTree = ""; 165 | }; 166 | /* End PBXVariantGroup section */ 167 | 168 | /* Begin XCBuildConfiguration section */ 169 | A43F3A0D1C074ABD0019A555 /* Debug */ = { 170 | isa = XCBuildConfiguration; 171 | buildSettings = { 172 | ALWAYS_SEARCH_USER_PATHS = NO; 173 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 174 | CLANG_CXX_LIBRARY = "libc++"; 175 | CLANG_ENABLE_MODULES = YES; 176 | CLANG_ENABLE_OBJC_ARC = YES; 177 | CLANG_WARN_BOOL_CONVERSION = YES; 178 | CLANG_WARN_CONSTANT_CONVERSION = YES; 179 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 180 | CLANG_WARN_EMPTY_BODY = YES; 181 | CLANG_WARN_ENUM_CONVERSION = YES; 182 | CLANG_WARN_INT_CONVERSION = YES; 183 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 184 | CLANG_WARN_UNREACHABLE_CODE = YES; 185 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 186 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 187 | COPY_PHASE_STRIP = NO; 188 | DEBUG_INFORMATION_FORMAT = dwarf; 189 | ENABLE_STRICT_OBJC_MSGSEND = YES; 190 | ENABLE_TESTABILITY = YES; 191 | GCC_C_LANGUAGE_STANDARD = gnu99; 192 | GCC_DYNAMIC_NO_PIC = NO; 193 | GCC_NO_COMMON_BLOCKS = YES; 194 | GCC_OPTIMIZATION_LEVEL = 0; 195 | GCC_PREPROCESSOR_DEFINITIONS = ( 196 | "DEBUG=1", 197 | "$(inherited)", 198 | ); 199 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 200 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 201 | GCC_WARN_UNDECLARED_SELECTOR = YES; 202 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 203 | GCC_WARN_UNUSED_FUNCTION = YES; 204 | GCC_WARN_UNUSED_VARIABLE = YES; 205 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 206 | MTL_ENABLE_DEBUG_INFO = YES; 207 | ONLY_ACTIVE_ARCH = YES; 208 | SDKROOT = iphoneos; 209 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 210 | TARGETED_DEVICE_FAMILY = "1,2"; 211 | }; 212 | name = Debug; 213 | }; 214 | A43F3A0E1C074ABD0019A555 /* Release */ = { 215 | isa = XCBuildConfiguration; 216 | buildSettings = { 217 | ALWAYS_SEARCH_USER_PATHS = NO; 218 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 219 | CLANG_CXX_LIBRARY = "libc++"; 220 | CLANG_ENABLE_MODULES = YES; 221 | CLANG_ENABLE_OBJC_ARC = YES; 222 | CLANG_WARN_BOOL_CONVERSION = YES; 223 | CLANG_WARN_CONSTANT_CONVERSION = YES; 224 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 225 | CLANG_WARN_EMPTY_BODY = YES; 226 | CLANG_WARN_ENUM_CONVERSION = YES; 227 | CLANG_WARN_INT_CONVERSION = YES; 228 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 229 | CLANG_WARN_UNREACHABLE_CODE = YES; 230 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 231 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 232 | COPY_PHASE_STRIP = NO; 233 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 234 | ENABLE_NS_ASSERTIONS = NO; 235 | ENABLE_STRICT_OBJC_MSGSEND = YES; 236 | GCC_C_LANGUAGE_STANDARD = gnu99; 237 | GCC_NO_COMMON_BLOCKS = YES; 238 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 239 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 240 | GCC_WARN_UNDECLARED_SELECTOR = YES; 241 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 242 | GCC_WARN_UNUSED_FUNCTION = YES; 243 | GCC_WARN_UNUSED_VARIABLE = YES; 244 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 245 | MTL_ENABLE_DEBUG_INFO = NO; 246 | SDKROOT = iphoneos; 247 | TARGETED_DEVICE_FAMILY = "1,2"; 248 | VALIDATE_PRODUCT = YES; 249 | }; 250 | name = Release; 251 | }; 252 | A43F3A101C074ABD0019A555 /* Debug */ = { 253 | isa = XCBuildConfiguration; 254 | buildSettings = { 255 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 256 | INFOPLIST_FILE = CoverFlowLayout/Info.plist; 257 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 258 | PRODUCT_BUNDLE_IDENTIFIER = com.Broccoli.CoverFlowLayout; 259 | PRODUCT_NAME = "$(TARGET_NAME)"; 260 | }; 261 | name = Debug; 262 | }; 263 | A43F3A111C074ABD0019A555 /* Release */ = { 264 | isa = XCBuildConfiguration; 265 | buildSettings = { 266 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 267 | INFOPLIST_FILE = CoverFlowLayout/Info.plist; 268 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 269 | PRODUCT_BUNDLE_IDENTIFIER = com.Broccoli.CoverFlowLayout; 270 | PRODUCT_NAME = "$(TARGET_NAME)"; 271 | }; 272 | name = Release; 273 | }; 274 | /* End XCBuildConfiguration section */ 275 | 276 | /* Begin XCConfigurationList section */ 277 | A43F39F81C074ABD0019A555 /* Build configuration list for PBXProject "CoverFlowLayout" */ = { 278 | isa = XCConfigurationList; 279 | buildConfigurations = ( 280 | A43F3A0D1C074ABD0019A555 /* Debug */, 281 | A43F3A0E1C074ABD0019A555 /* Release */, 282 | ); 283 | defaultConfigurationIsVisible = 0; 284 | defaultConfigurationName = Release; 285 | }; 286 | A43F3A0F1C074ABD0019A555 /* Build configuration list for PBXNativeTarget "CoverFlowLayout" */ = { 287 | isa = XCConfigurationList; 288 | buildConfigurations = ( 289 | A43F3A101C074ABD0019A555 /* Debug */, 290 | A43F3A111C074ABD0019A555 /* Release */, 291 | ); 292 | defaultConfigurationIsVisible = 0; 293 | }; 294 | /* End XCConfigurationList section */ 295 | }; 296 | rootObject = A43F39F51C074ABD0019A555 /* Project object */; 297 | } 298 | -------------------------------------------------------------------------------- /CoverFlowLayout.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CoverFlowLayout.xcodeproj/project.xcworkspace/xcshareddata/CoverFlowLayout.xcscmblueprint: -------------------------------------------------------------------------------- 1 | { 2 | "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "0FBFB078993A8E30684AD0F54DFEC7F60287D3DA", 3 | "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { 4 | 5 | }, 6 | "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { 7 | "2ADE6DD5FE3F220904FC8623C0EDE339BC93A3D6" : 0, 8 | "0FBFB078993A8E30684AD0F54DFEC7F60287D3DA" : 0 9 | }, 10 | "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "B57E253C-1299-44D7-BD38-1AAC474763D2", 11 | "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { 12 | "2ADE6DD5FE3F220904FC8623C0EDE339BC93A3D6" : "", 13 | "0FBFB078993A8E30684AD0F54DFEC7F60287D3DA" : "CoverFlowLayout\/" 14 | }, 15 | "DVTSourceControlWorkspaceBlueprintNameKey" : "CoverFlowLayout", 16 | "DVTSourceControlWorkspaceBlueprintVersion" : 204, 17 | "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "CoverFlowLayout.xcodeproj", 18 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ 19 | { 20 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/broccolii\/CoverFlowLayout.git", 21 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", 22 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "0FBFB078993A8E30684AD0F54DFEC7F60287D3DA" 23 | }, 24 | { 25 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/broccolii\/LoadingView.git", 26 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", 27 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "2ADE6DD5FE3F220904FC8623C0EDE339BC93A3D6" 28 | } 29 | ] 30 | } -------------------------------------------------------------------------------- /CoverFlowLayout.xcodeproj/project.xcworkspace/xcuserdata/Broccoli.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/broccolii/CoverFlowLayout/c1c2eaa165ce93bde649b294371e6912d54a8721/CoverFlowLayout.xcodeproj/project.xcworkspace/xcuserdata/Broccoli.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /CoverFlowLayout.xcodeproj/xcuserdata/Broccoli.xcuserdatad/xcschemes/CoverFlowLayout.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /CoverFlowLayout.xcodeproj/xcuserdata/Broccoli.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CoverFlowLayout.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | A43F39FC1C074ABD0019A555 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /CoverFlowLayout/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CoverFlowLayout 4 | // 5 | // Created by Broccoli on 15/11/26. 6 | // Copyright © 2015年 Broccoli. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // 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. 24 | // 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. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 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 | func applicationDidBecomeActive(application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /CoverFlowLayout/Assets.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 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /CoverFlowLayout/Base.lproj/LaunchScreen.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 | -------------------------------------------------------------------------------- /CoverFlowLayout/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 | -------------------------------------------------------------------------------- /CoverFlowLayout/CoverFlowLayout.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CoverFlowLayout.swift 3 | // CoverFlowLayout 4 | // 5 | // Created by Broccoli on 15/11/26. 6 | // Copyright © 2015年 Broccoli. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CoverFlowLayout: UICollectionViewFlowLayout { 12 | let kDistanceToProjectionPlane: CGFloat = 500.0 13 | 14 | var maxCoverDegree: CGFloat = 30.0 15 | var coverDensity: CGFloat = 0.25 16 | 17 | override func shouldInvalidateLayoutForBoundsChange(newBounds: CGRect) -> Bool { 18 | return true 19 | } 20 | 21 | override func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionViewLayoutAttributes]? { 22 | let indexPaths = indexPathsOfItemsInRect(rect) 23 | 24 | var resultingAttributes = [UICollectionViewLayoutAttributes]() 25 | 26 | for indexPath in indexPaths { 27 | let attributes = layoutAttributesForItemAtIndexPath(indexPath)! 28 | resultingAttributes.append(attributes) 29 | } 30 | return resultingAttributes 31 | } 32 | 33 | override func layoutAttributesForItemAtIndexPath(indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? { 34 | let attributes = UICollectionViewLayoutAttributes(forCellWithIndexPath: indexPath) 35 | 36 | attributes.size = itemSize 37 | attributes.center = CGPoint(x: collectionView!.bounds.size.width * CGFloat(indexPath.row) + collectionView!.bounds.size.width, y: collectionView!.bounds.size.height / 2) 38 | 39 | interpolateAttributes(attributes, forOffset: collectionView!.contentOffset.x) 40 | return attributes 41 | } 42 | 43 | override func collectionViewContentSize() -> CGSize { 44 | return CGSize(width: collectionView!.bounds.width * CGFloat(collectionView!.numberOfItemsInSection(0)), height: collectionView!.bounds.height) 45 | } 46 | } 47 | 48 | 49 | // MARK: - private method 50 | private extension CoverFlowLayout { 51 | func indexPathsOfItemsInRect(rect: CGRect) -> [NSIndexPath] { 52 | if collectionView!.numberOfItemsInSection(0) == 0 { 53 | return [NSIndexPath]() 54 | } 55 | var minRow: Int = max(Int(rect.origin.x / collectionView!.bounds.width), 0) 56 | var maxRow: Int = Int(CGRectGetMaxX(rect) / collectionView!.bounds.width) 57 | 58 | let candidateMinRow = max(minRow - 1, 0) 59 | if maxXForRow(candidateMinRow) >= rect.origin.x { 60 | minRow = candidateMinRow 61 | } 62 | 63 | let candidateMaxRow = min(maxRow + 1, collectionView!.numberOfItemsInSection(0) - 1) 64 | if minXForRow(candidateMaxRow) <= CGRectGetMaxX(rect) { 65 | maxRow = candidateMaxRow 66 | } 67 | 68 | var resultingInexPaths = [NSIndexPath]() 69 | 70 | for i in Int(minRow) ..< Int(maxRow) + 1 { 71 | resultingInexPaths.append(NSIndexPath(forRow: i, inSection: 0)) 72 | } 73 | 74 | return resultingInexPaths 75 | } 76 | 77 | func minXForRow(row: Int) -> CGFloat { 78 | return itemCenterForRow(row - 1).x + (1 / 2 - coverDensity) * itemSize.width 79 | } 80 | 81 | func maxXForRow(row: Int) -> CGFloat { 82 | return itemCenterForRow(row + 1).x - (1 / 2 - coverDensity) * itemSize.width 83 | } 84 | 85 | func minXCenterForRow(row: Int) -> CGFloat { 86 | let halfWidth = itemSize.width / 2 87 | let maxRads = maxCoverDegree * CGFloat(M_PI) / 180 88 | let center = itemCenterForRow(row - 1).x 89 | let prevItemRightEdge = center + halfWidth 90 | let projectedLeftEdgeLocal = halfWidth * cos(maxRads) * kDistanceToProjectionPlane / (kDistanceToProjectionPlane + halfWidth * sin(maxRads)) 91 | return prevItemRightEdge - coverDensity * itemSize.width + projectedLeftEdgeLocal 92 | } 93 | 94 | func maxXCenterForRow(row: Int) -> CGFloat { 95 | let halfWidth = itemSize.width / 2 96 | let maxRads = maxCoverDegree * CGFloat(M_PI) / 180 97 | let center = itemCenterForRow(row + 1).x 98 | let nextItemLeftEdge = center - halfWidth 99 | let projectedRightEdgeLocal = fabs(halfWidth * cos(maxRads) * kDistanceToProjectionPlane / (-halfWidth * sin(maxRads) - kDistanceToProjectionPlane)) 100 | return nextItemLeftEdge + coverDensity * itemSize.width - projectedRightEdgeLocal 101 | } 102 | 103 | func itemCenterForRow(row: Int) -> CGPoint { 104 | let collectionViewSize = collectionView!.bounds.size 105 | return CGPoint(x: CGFloat(row) * collectionViewSize.width + collectionViewSize.width / 2, y: collectionViewSize.height / 2) 106 | } 107 | 108 | func interpolateAttributes(attributes: UICollectionViewLayoutAttributes, forOffset offset: CGFloat) { 109 | let attributesPath = attributes.indexPath 110 | 111 | let minInterval = CGFloat(attributesPath.row - 1) * collectionView!.bounds.width 112 | let maxInterval = CGFloat(attributesPath.row + 1) * collectionView!.bounds.width 113 | 114 | let minX = minXCenterForRow(attributesPath.row) 115 | let maxX = maxXCenterForRow(attributesPath.row) 116 | 117 | let interpolatedX = min(max(minX + (((maxX - minX) / (maxInterval - minInterval)) * (offset - minInterval)), minX), maxX) 118 | attributes.center = CGPoint(x: interpolatedX, y: attributes.center.y) 119 | 120 | let angle = -maxCoverDegree + (interpolatedX - minX) * 2 * maxCoverDegree / (maxX - minX) 121 | var transform = CATransform3DIdentity 122 | 123 | transform.m34 = -1.0 / kDistanceToProjectionPlane 124 | transform = CATransform3DRotate(transform, angle * CGFloat(M_PI) / 180, 0, 1, 0) 125 | attributes.transform3D = transform 126 | attributes.zIndex = NSIntegerMax - attributesPath.row 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /CoverFlowLayout/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 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /CoverFlowLayout/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // CoverFlowLayout 4 | // 5 | // Created by Broccoli on 15/11/26. 6 | // Copyright © 2015年 Broccoli. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UICollectionViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view, typically from a nib. 16 | } 17 | 18 | override func didReceiveMemoryWarning() { 19 | super.didReceiveMemoryWarning() 20 | // Dispose of any resources that can be recreated. 21 | } 22 | 23 | 24 | } 25 | 26 | private let CellIdentifier = "CollectionCell" 27 | extension ViewController { 28 | override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 29 | return 30 30 | } 31 | override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { 32 | let cell = collectionView.dequeueReusableCellWithReuseIdentifier(CellIdentifier, forIndexPath: indexPath) 33 | cell.backgroundColor = UIColor(red: CGFloat(arc4random() % 255) / 255.0, green: CGFloat(arc4random() % 255) / 255.0, blue: CGFloat(arc4random() % 255) / 255.0, alpha: 1.0) 34 | cell.layer.allowsEdgeAntialiasing = true 35 | return cell 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CoverFlowLayout 2 | 模仿 Finder 中的 cover 模式 3 | 4 | --------------------------------------------------------------------------------