├── .gitignore ├── CardStyleTableView.xcodeproj ├── project.pbxproj ├── xcshareddata │ └── xcschemes │ │ └── CardStyleTableView.xcscheme └── xcuserdata │ └── hongxin.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── CardStyleTableView.xcworkspace ├── contents.xcworkspacedata └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── CardStyleTableView ├── CardStyle.swift ├── CardStyleTableView.swift ├── CardStyleTableViewCell.swift ├── Constants.swift ├── Protocols.swift ├── Supporting Files │ └── Info.plist └── WeakObjectContainer.swift ├── CardStyleTableViewExample.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── hongxin.xcuserdatad │ └── xcschemes │ ├── CardStyleTableViewExample.xcscheme │ └── xcschememanagement.plist ├── CardStyleTableViewExample ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── examplePicture.imageset │ │ ├── Contents.json │ │ ├── examplePicture.png │ │ ├── examplePicture@2x.png │ │ └── examplePicture@3x.png ├── Base.lproj │ └── Main.storyboard ├── Example1ViewController.swift ├── Example2ViewController.swift ├── Info.plist ├── PhotoCell.swift └── ViewController.swift ├── LICENSE.md ├── README.md ├── Screenshots ├── Screenshot-1.png └── Screenshot-2.png └── TBCardStyleTableView.podspec /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | .idea/ 9 | .vscode/ 10 | 11 | ## Various settings 12 | *.pbxuser 13 | !default.pbxuser 14 | *.mode1v3 15 | !default.mode1v3 16 | *.mode2v3 17 | !default.mode2v3 18 | *.perspectivev3 19 | !default.perspectivev3 20 | xcuserdata/ 21 | 22 | ## Other 23 | *.moved-aside 24 | *.xcuserstate 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | *.dSYM.zip 30 | ".gitignore" 69L, 1440C 31 | -------------------------------------------------------------------------------- /CardStyleTableView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D37366D11F95EA0800442635 /* CardStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = D37366D01F95EA0800442635 /* CardStyle.swift */; }; 11 | D3788A341C5A139B008318C1 /* CardStyleTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3788A331C5A139B008318C1 /* CardStyleTableView.swift */; }; 12 | D3788A361C5A19BA008318C1 /* Protocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3788A351C5A19BA008318C1 /* Protocols.swift */; }; 13 | D3788A381C5A244B008318C1 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3788A371C5A244B008318C1 /* Constants.swift */; }; 14 | D399484C1DCC342B00D26BE4 /* WeakObjectContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D399484B1DCC342B00D26BE4 /* WeakObjectContainer.swift */; }; 15 | D3C25A5F1C4F3A1400D3A3DA /* CardStyleTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3C25A5E1C4F3A1400D3A3DA /* CardStyleTableViewCell.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | D37366D01F95EA0800442635 /* CardStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardStyle.swift; sourceTree = ""; }; 20 | D3788A331C5A139B008318C1 /* CardStyleTableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardStyleTableView.swift; sourceTree = ""; }; 21 | D3788A351C5A19BA008318C1 /* Protocols.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Protocols.swift; sourceTree = ""; }; 22 | D3788A371C5A244B008318C1 /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; 23 | D399484B1DCC342B00D26BE4 /* WeakObjectContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WeakObjectContainer.swift; sourceTree = ""; }; 24 | D3C25A531C4F393700D3A3DA /* CardStyleTableView.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CardStyleTableView.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 25 | D3C25A5E1C4F3A1400D3A3DA /* CardStyleTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardStyleTableViewCell.swift; sourceTree = ""; }; 26 | D3C25A611C4F3A5F00D3A3DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | D3C25A4F1C4F393700D3A3DA /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | ); 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXFrameworksBuildPhase section */ 38 | 39 | /* Begin PBXGroup section */ 40 | D3C25A491C4F393700D3A3DA = { 41 | isa = PBXGroup; 42 | children = ( 43 | D3C25A551C4F393700D3A3DA /* CardStyleTableView */, 44 | D3C25A601C4F3A2D00D3A3DA /* Supporting Files */, 45 | D3C25A541C4F393700D3A3DA /* Products */, 46 | ); 47 | sourceTree = ""; 48 | }; 49 | D3C25A541C4F393700D3A3DA /* Products */ = { 50 | isa = PBXGroup; 51 | children = ( 52 | D3C25A531C4F393700D3A3DA /* CardStyleTableView.framework */, 53 | ); 54 | name = Products; 55 | sourceTree = ""; 56 | }; 57 | D3C25A551C4F393700D3A3DA /* CardStyleTableView */ = { 58 | isa = PBXGroup; 59 | children = ( 60 | D3788A371C5A244B008318C1 /* Constants.swift */, 61 | D3788A351C5A19BA008318C1 /* Protocols.swift */, 62 | D37366D01F95EA0800442635 /* CardStyle.swift */, 63 | D3788A331C5A139B008318C1 /* CardStyleTableView.swift */, 64 | D3C25A5E1C4F3A1400D3A3DA /* CardStyleTableViewCell.swift */, 65 | D399484B1DCC342B00D26BE4 /* WeakObjectContainer.swift */, 66 | ); 67 | path = CardStyleTableView; 68 | sourceTree = ""; 69 | }; 70 | D3C25A601C4F3A2D00D3A3DA /* Supporting Files */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | D3C25A611C4F3A5F00D3A3DA /* Info.plist */, 74 | ); 75 | name = "Supporting Files"; 76 | path = "CardStyleTableView/Supporting Files"; 77 | sourceTree = ""; 78 | }; 79 | /* End PBXGroup section */ 80 | 81 | /* Begin PBXHeadersBuildPhase section */ 82 | D3C25A501C4F393700D3A3DA /* Headers */ = { 83 | isa = PBXHeadersBuildPhase; 84 | buildActionMask = 2147483647; 85 | files = ( 86 | ); 87 | runOnlyForDeploymentPostprocessing = 0; 88 | }; 89 | /* End PBXHeadersBuildPhase section */ 90 | 91 | /* Begin PBXNativeTarget section */ 92 | D3C25A521C4F393700D3A3DA /* CardStyleTableView */ = { 93 | isa = PBXNativeTarget; 94 | buildConfigurationList = D3C25A5B1C4F393700D3A3DA /* Build configuration list for PBXNativeTarget "CardStyleTableView" */; 95 | buildPhases = ( 96 | D3C25A4E1C4F393700D3A3DA /* Sources */, 97 | D3C25A4F1C4F393700D3A3DA /* Frameworks */, 98 | D3C25A501C4F393700D3A3DA /* Headers */, 99 | D3C25A511C4F393700D3A3DA /* Resources */, 100 | ); 101 | buildRules = ( 102 | ); 103 | dependencies = ( 104 | ); 105 | name = CardStyleTableView; 106 | productName = CardStyleTableViewCell; 107 | productReference = D3C25A531C4F393700D3A3DA /* CardStyleTableView.framework */; 108 | productType = "com.apple.product-type.framework"; 109 | }; 110 | /* End PBXNativeTarget section */ 111 | 112 | /* Begin PBXProject section */ 113 | D3C25A4A1C4F393700D3A3DA /* Project object */ = { 114 | isa = PBXProject; 115 | attributes = { 116 | LastUpgradeCheck = 1020; 117 | ORGANIZATIONNAME = Teambition; 118 | TargetAttributes = { 119 | D3C25A521C4F393700D3A3DA = { 120 | CreatedOnToolsVersion = 7.2; 121 | LastSwiftMigration = 1020; 122 | }; 123 | }; 124 | }; 125 | buildConfigurationList = D3C25A4D1C4F393700D3A3DA /* Build configuration list for PBXProject "CardStyleTableView" */; 126 | compatibilityVersion = "Xcode 3.2"; 127 | developmentRegion = en; 128 | hasScannedForEncodings = 0; 129 | knownRegions = ( 130 | en, 131 | Base, 132 | ); 133 | mainGroup = D3C25A491C4F393700D3A3DA; 134 | productRefGroup = D3C25A541C4F393700D3A3DA /* Products */; 135 | projectDirPath = ""; 136 | projectRoot = ""; 137 | targets = ( 138 | D3C25A521C4F393700D3A3DA /* CardStyleTableView */, 139 | ); 140 | }; 141 | /* End PBXProject section */ 142 | 143 | /* Begin PBXResourcesBuildPhase section */ 144 | D3C25A511C4F393700D3A3DA /* Resources */ = { 145 | isa = PBXResourcesBuildPhase; 146 | buildActionMask = 2147483647; 147 | files = ( 148 | ); 149 | runOnlyForDeploymentPostprocessing = 0; 150 | }; 151 | /* End PBXResourcesBuildPhase section */ 152 | 153 | /* Begin PBXSourcesBuildPhase section */ 154 | D3C25A4E1C4F393700D3A3DA /* Sources */ = { 155 | isa = PBXSourcesBuildPhase; 156 | buildActionMask = 2147483647; 157 | files = ( 158 | D3788A361C5A19BA008318C1 /* Protocols.swift in Sources */, 159 | D37366D11F95EA0800442635 /* CardStyle.swift in Sources */, 160 | D399484C1DCC342B00D26BE4 /* WeakObjectContainer.swift in Sources */, 161 | D3C25A5F1C4F3A1400D3A3DA /* CardStyleTableViewCell.swift in Sources */, 162 | D3788A341C5A139B008318C1 /* CardStyleTableView.swift in Sources */, 163 | D3788A381C5A244B008318C1 /* Constants.swift in Sources */, 164 | ); 165 | runOnlyForDeploymentPostprocessing = 0; 166 | }; 167 | /* End PBXSourcesBuildPhase section */ 168 | 169 | /* Begin XCBuildConfiguration section */ 170 | D3C25A591C4F393700D3A3DA /* Debug */ = { 171 | isa = XCBuildConfiguration; 172 | buildSettings = { 173 | ALWAYS_SEARCH_USER_PATHS = NO; 174 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 175 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 176 | CLANG_CXX_LIBRARY = "libc++"; 177 | CLANG_ENABLE_MODULES = YES; 178 | CLANG_ENABLE_OBJC_ARC = YES; 179 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 180 | CLANG_WARN_BOOL_CONVERSION = YES; 181 | CLANG_WARN_COMMA = YES; 182 | CLANG_WARN_CONSTANT_CONVERSION = YES; 183 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 184 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 185 | CLANG_WARN_EMPTY_BODY = YES; 186 | CLANG_WARN_ENUM_CONVERSION = YES; 187 | CLANG_WARN_INFINITE_RECURSION = YES; 188 | CLANG_WARN_INT_CONVERSION = YES; 189 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 190 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 191 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 192 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 193 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 194 | CLANG_WARN_STRICT_PROTOTYPES = YES; 195 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 196 | CLANG_WARN_UNREACHABLE_CODE = YES; 197 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 198 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 199 | COPY_PHASE_STRIP = NO; 200 | CURRENT_PROJECT_VERSION = 1; 201 | DEBUG_INFORMATION_FORMAT = dwarf; 202 | ENABLE_STRICT_OBJC_MSGSEND = YES; 203 | ENABLE_TESTABILITY = YES; 204 | GCC_C_LANGUAGE_STANDARD = gnu99; 205 | GCC_DYNAMIC_NO_PIC = NO; 206 | GCC_NO_COMMON_BLOCKS = YES; 207 | GCC_OPTIMIZATION_LEVEL = 0; 208 | GCC_PREPROCESSOR_DEFINITIONS = ( 209 | "DEBUG=1", 210 | "$(inherited)", 211 | ); 212 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 213 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 214 | GCC_WARN_UNDECLARED_SELECTOR = YES; 215 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 216 | GCC_WARN_UNUSED_FUNCTION = YES; 217 | GCC_WARN_UNUSED_VARIABLE = YES; 218 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 219 | MTL_ENABLE_DEBUG_INFO = YES; 220 | ONLY_ACTIVE_ARCH = YES; 221 | SDKROOT = iphoneos; 222 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 223 | TARGETED_DEVICE_FAMILY = "1,2"; 224 | VERSIONING_SYSTEM = "apple-generic"; 225 | VERSION_INFO_PREFIX = ""; 226 | }; 227 | name = Debug; 228 | }; 229 | D3C25A5A1C4F393700D3A3DA /* Release */ = { 230 | isa = XCBuildConfiguration; 231 | buildSettings = { 232 | ALWAYS_SEARCH_USER_PATHS = NO; 233 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 234 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 235 | CLANG_CXX_LIBRARY = "libc++"; 236 | CLANG_ENABLE_MODULES = YES; 237 | CLANG_ENABLE_OBJC_ARC = YES; 238 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 239 | CLANG_WARN_BOOL_CONVERSION = YES; 240 | CLANG_WARN_COMMA = YES; 241 | CLANG_WARN_CONSTANT_CONVERSION = YES; 242 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 243 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 244 | CLANG_WARN_EMPTY_BODY = YES; 245 | CLANG_WARN_ENUM_CONVERSION = YES; 246 | CLANG_WARN_INFINITE_RECURSION = YES; 247 | CLANG_WARN_INT_CONVERSION = YES; 248 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 249 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 250 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 251 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 252 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 253 | CLANG_WARN_STRICT_PROTOTYPES = YES; 254 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 255 | CLANG_WARN_UNREACHABLE_CODE = YES; 256 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 257 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 258 | COPY_PHASE_STRIP = NO; 259 | CURRENT_PROJECT_VERSION = 1; 260 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 261 | ENABLE_NS_ASSERTIONS = NO; 262 | ENABLE_STRICT_OBJC_MSGSEND = YES; 263 | GCC_C_LANGUAGE_STANDARD = gnu99; 264 | GCC_NO_COMMON_BLOCKS = YES; 265 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 266 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 267 | GCC_WARN_UNDECLARED_SELECTOR = YES; 268 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 269 | GCC_WARN_UNUSED_FUNCTION = YES; 270 | GCC_WARN_UNUSED_VARIABLE = YES; 271 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 272 | MTL_ENABLE_DEBUG_INFO = NO; 273 | SDKROOT = iphoneos; 274 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 275 | TARGETED_DEVICE_FAMILY = "1,2"; 276 | VALIDATE_PRODUCT = YES; 277 | VERSIONING_SYSTEM = "apple-generic"; 278 | VERSION_INFO_PREFIX = ""; 279 | }; 280 | name = Release; 281 | }; 282 | D3C25A5C1C4F393700D3A3DA /* Debug */ = { 283 | isa = XCBuildConfiguration; 284 | buildSettings = { 285 | CLANG_ENABLE_MODULES = YES; 286 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 287 | DEFINES_MODULE = YES; 288 | DYLIB_COMPATIBILITY_VERSION = 1; 289 | DYLIB_CURRENT_VERSION = 1; 290 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 291 | INFOPLIST_FILE = "$(SRCROOT)/CardStyleTableView/Supporting Files/Info.plist"; 292 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 293 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 294 | MARKETING_VERSION = 0.1.5; 295 | PRODUCT_BUNDLE_IDENTIFIER = com.teambition.CardStyleTableView; 296 | PRODUCT_NAME = CardStyleTableView; 297 | SKIP_INSTALL = YES; 298 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 299 | SWIFT_VERSION = 5.0; 300 | }; 301 | name = Debug; 302 | }; 303 | D3C25A5D1C4F393700D3A3DA /* Release */ = { 304 | isa = XCBuildConfiguration; 305 | buildSettings = { 306 | CLANG_ENABLE_MODULES = YES; 307 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 308 | DEFINES_MODULE = YES; 309 | DYLIB_COMPATIBILITY_VERSION = 1; 310 | DYLIB_CURRENT_VERSION = 1; 311 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 312 | INFOPLIST_FILE = "$(SRCROOT)/CardStyleTableView/Supporting Files/Info.plist"; 313 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 314 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 315 | MARKETING_VERSION = 0.1.5; 316 | PRODUCT_BUNDLE_IDENTIFIER = com.teambition.CardStyleTableView; 317 | PRODUCT_NAME = CardStyleTableView; 318 | SKIP_INSTALL = YES; 319 | SWIFT_VERSION = 5.0; 320 | }; 321 | name = Release; 322 | }; 323 | /* End XCBuildConfiguration section */ 324 | 325 | /* Begin XCConfigurationList section */ 326 | D3C25A4D1C4F393700D3A3DA /* Build configuration list for PBXProject "CardStyleTableView" */ = { 327 | isa = XCConfigurationList; 328 | buildConfigurations = ( 329 | D3C25A591C4F393700D3A3DA /* Debug */, 330 | D3C25A5A1C4F393700D3A3DA /* Release */, 331 | ); 332 | defaultConfigurationIsVisible = 0; 333 | defaultConfigurationName = Release; 334 | }; 335 | D3C25A5B1C4F393700D3A3DA /* Build configuration list for PBXNativeTarget "CardStyleTableView" */ = { 336 | isa = XCConfigurationList; 337 | buildConfigurations = ( 338 | D3C25A5C1C4F393700D3A3DA /* Debug */, 339 | D3C25A5D1C4F393700D3A3DA /* Release */, 340 | ); 341 | defaultConfigurationIsVisible = 0; 342 | defaultConfigurationName = Release; 343 | }; 344 | /* End XCConfigurationList section */ 345 | }; 346 | rootObject = D3C25A4A1C4F393700D3A3DA /* Project object */; 347 | } 348 | -------------------------------------------------------------------------------- /CardStyleTableView.xcodeproj/xcshareddata/xcschemes/CardStyleTableView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /CardStyleTableView.xcodeproj/xcuserdata/hongxin.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CardStyleTableView.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | D3C25A521C4F393700D3A3DA 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /CardStyleTableView.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /CardStyleTableView.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CardStyleTableView/CardStyle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CardStyle.swift 3 | // CardStyleTableView 4 | // 5 | // Created by 洪鑫 on 2017/10/17. 6 | // Copyright © 2017年 Teambition. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public struct CardStyle { 12 | public static func setup() { 13 | UITableView.cardStyle_swizzle() 14 | UITableViewCell.cardStyle_swizzle() 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CardStyleTableView/CardStyleTableView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CardStyleTableView.swift 3 | // CardStyleTableView 4 | // 5 | // Created by Xin Hong on 16/1/28. 6 | // Copyright © 2016年 Teambition. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UITableView { 12 | // MARK: - Properties 13 | public var cardStyleSource: CardStyleTableViewStyleSource? { 14 | get { 15 | let container = objc_getAssociatedObject(self, &AssociatedKeys.cardStyleTableViewStyleSource) as? WeakObjectContainer 16 | return container?.object as? CardStyleTableViewStyleSource 17 | } 18 | set { 19 | objc_setAssociatedObject(self, &AssociatedKeys.cardStyleTableViewStyleSource, WeakObjectContainer(object: newValue), .OBJC_ASSOCIATION_RETAIN_NONATOMIC) 20 | } 21 | } 22 | 23 | internal var leftPadding: CGFloat? { 24 | return cardStyleSource?.leftPaddingForCardStyleTableView() 25 | } 26 | internal var rightPadding: CGFloat? { 27 | return cardStyleSource?.rightPaddingForCardStyleTableView() 28 | } 29 | 30 | // MARK: - Initialize 31 | internal class func cardStyle_swizzle() { 32 | if self != UITableView.self { 33 | return 34 | } 35 | cardStyle_swizzleTableViewLayoutSubviews 36 | } 37 | 38 | // MARK: - Method swizzling 39 | @objc func cardStyle_tableViewSwizzledLayoutSubviews() { 40 | cardStyle_tableViewSwizzledLayoutSubviews() 41 | 42 | updateSubviews() 43 | } 44 | 45 | fileprivate static let cardStyle_swizzleTableViewLayoutSubviews: () = { 46 | let originalSelector = TableViewSelectors.layoutSubviews 47 | let swizzledSelector = TableViewSelectors.swizzledLayoutSubviews 48 | guard let originalMethod = class_getInstanceMethod(UITableView.self, originalSelector), let swizzledMethod = class_getInstanceMethod(UITableView.self, swizzledSelector) else { 49 | return 50 | } 51 | 52 | let didAddMethod = class_addMethod(UITableView.self, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod)) 53 | 54 | if didAddMethod { 55 | class_replaceMethod(UITableView.self, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod)) 56 | } else { 57 | method_exchangeImplementations(originalMethod, swizzledMethod) 58 | } 59 | print("cardStyle_swizzleTableViewLayoutSubviews") 60 | }() 61 | 62 | // MARK: - Helper 63 | fileprivate func updateSubviews() { 64 | guard let leftPadding = leftPadding, let rightPadding = rightPadding, style == .grouped && cardStyleSource != nil else { 65 | return 66 | } 67 | 68 | subviews.forEach { 69 | if $0 is UITableViewHeaderFooterView { 70 | if $0.frame.origin.x != leftPadding { 71 | $0.frame.origin.x = leftPadding 72 | } 73 | if $0.frame.width != frame.width - leftPadding - rightPadding { 74 | $0.frame.size.width = frame.width - leftPadding - rightPadding 75 | } 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /CardStyleTableView/CardStyleTableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CardStyleTableViewCell.swift 3 | // CardStyleTableView 4 | // 5 | // Created by Xin Hong on 16/1/20. 6 | // Copyright © 2016年 Teambition. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UITableViewCell { 12 | // MARK: - Properties 13 | fileprivate var tableView: UITableView? { 14 | get { 15 | let container = objc_getAssociatedObject(self, &AssociatedKeys.cardStyleTableViewCellTableView) as? WeakObjectContainer 16 | return container?.object as? UITableView 17 | } 18 | set { 19 | objc_setAssociatedObject(self, &AssociatedKeys.cardStyleTableViewCellTableView, WeakObjectContainer(object: newValue), .OBJC_ASSOCIATION_RETAIN_NONATOMIC) 20 | updateFrame() 21 | } 22 | } 23 | fileprivate var indexPath: IndexPath? { 24 | guard let tableView = tableView else { 25 | return nil 26 | } 27 | return tableView.indexPath(for: self) ?? tableView.indexPathForRow(at: center) 28 | } 29 | fileprivate var indexPathLocation: (isFirstRowInSection: Bool, isLastRowInSection: Bool) { 30 | guard let tableView = tableView, let indexPath = indexPath else { 31 | return (false, false) 32 | } 33 | let isFirstRowInSection = indexPath.row == 0 34 | let isLastRowInSection = indexPath.row == tableView.numberOfRows(inSection: indexPath.section) - 1 35 | return (isFirstRowInSection, isLastRowInSection) 36 | } 37 | 38 | // MARK: - Initialize 39 | internal class func cardStyle_swizzle() { 40 | if self != UITableViewCell.self { 41 | return 42 | } 43 | cardStyle_swizzleTableViewCellLayoutSubviews 44 | cardStyle_swizzleTableViewCellDidMoveToSuperview 45 | } 46 | 47 | // MARK: - Method swizzling 48 | @objc func cardStyle_tableViewCellSwizzledLayoutSubviews() { 49 | cardStyle_tableViewCellSwizzledLayoutSubviews() 50 | 51 | updateFrame() 52 | setRoundingCorners() 53 | } 54 | 55 | @objc func cardStyle_tableViewCellSwizzledDidMoveToSuperview() { 56 | cardStyle_tableViewCellSwizzledDidMoveToSuperview() 57 | 58 | tableView = nil 59 | if let tableView = superview as? UITableView { 60 | self.tableView = tableView 61 | } else if let tableView = superview?.superview as? UITableView { 62 | self.tableView = tableView 63 | } 64 | } 65 | 66 | fileprivate class func cardStyle_swizzleMethod(for aClass: AnyClass, originalSelector: Selector, swizzledSelector: Selector) { 67 | guard let originalMethod = class_getInstanceMethod(aClass, originalSelector), let swizzledMethod = class_getInstanceMethod(aClass, swizzledSelector) else { 68 | return 69 | } 70 | 71 | let didAddMethod = class_addMethod(aClass, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod)) 72 | 73 | if didAddMethod { 74 | class_replaceMethod(aClass, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod)) 75 | } else { 76 | method_exchangeImplementations(originalMethod, swizzledMethod) 77 | } 78 | } 79 | 80 | fileprivate static let cardStyle_swizzleTableViewCellLayoutSubviews: () = { 81 | let originalSelector = TableViewCellSelectors.layoutSubviews 82 | let swizzledSelector = TableViewCellSelectors.swizzledLayoutSubviews 83 | 84 | cardStyle_swizzleMethod(for: UITableViewCell.self, originalSelector: originalSelector, swizzledSelector: swizzledSelector) 85 | print("cardStyle_swizzleTableViewCellLayoutSubviews") 86 | }() 87 | 88 | fileprivate static let cardStyle_swizzleTableViewCellDidMoveToSuperview: () = { 89 | let originalSelector = TableViewCellSelectors.didMoveToSuperview 90 | let swizzledSelector = TableViewCellSelectors.swizzledDidMoveToSuperview 91 | 92 | cardStyle_swizzleMethod(for: UITableViewCell.self, originalSelector: originalSelector, swizzledSelector: swizzledSelector) 93 | print("cardStyle_swizzleTableViewCellDidMoveToSuperview") 94 | }() 95 | 96 | // MARK: - Helper 97 | fileprivate func updateFrame() { 98 | guard let tableView = tableView, tableView.style == .grouped && tableView.cardStyleSource != nil else { 99 | return 100 | } 101 | guard let leftPadding = tableView.leftPadding, let rightPadding = tableView.rightPadding else { 102 | return 103 | } 104 | 105 | var needsLayout = false 106 | if frame.origin.x != leftPadding { 107 | frame.origin.x = leftPadding 108 | needsLayout = true 109 | } 110 | if frame.width != tableView.frame.width - leftPadding - rightPadding { 111 | frame.size.width = tableView.frame.width - leftPadding - rightPadding 112 | needsLayout = true 113 | } 114 | 115 | if #available(iOS 10.0, *), needsLayout { 116 | layoutIfNeeded() 117 | } 118 | } 119 | 120 | fileprivate func setRoundingCorners() { 121 | guard let tableView = tableView, let indexPath = indexPath, tableView.style == .grouped && tableView.cardStyleSource != nil else { 122 | layer.mask = nil 123 | return 124 | } 125 | var roundingCorners = tableView.cardStyleSource?.roundingCornersForCard(inSection: indexPath.section) ?? UIRectCorner.allCorners 126 | guard let cornerRadius = tableView.cardStyleSource?.cornerRadiusForCardStyleTableView(), roundingCorners != [] else { 127 | layer.mask = nil 128 | return 129 | } 130 | 131 | let maskLayer = CAShapeLayer() 132 | let maskRect = bounds 133 | maskLayer.frame = maskRect 134 | let cornerRadii = CGSize(width: cornerRadius, height: cornerRadius) 135 | 136 | switch indexPathLocation { 137 | case (true, true): 138 | let maskPath = UIBezierPath(roundedRect: maskRect, byRoundingCorners: roundingCorners, cornerRadii: cornerRadii) 139 | maskLayer.path = maskPath.cgPath 140 | layer.mask = maskLayer 141 | case (true, false): 142 | let firstRowCorners: UIRectCorner = { 143 | if roundingCorners == .allCorners { 144 | return [.topLeft, .topRight] 145 | } else { 146 | roundingCorners.remove(.bottomLeft) 147 | roundingCorners.remove(.bottomRight) 148 | return roundingCorners 149 | } 150 | }() 151 | let maskPath = UIBezierPath(roundedRect: maskRect, byRoundingCorners: firstRowCorners, cornerRadii: cornerRadii) 152 | maskLayer.path = maskPath.cgPath 153 | layer.mask = maskLayer 154 | case (false, true): 155 | let lastRowCorners: UIRectCorner = { 156 | if roundingCorners == .allCorners { 157 | return [.bottomLeft, .bottomRight] 158 | } else { 159 | roundingCorners.remove(.topLeft) 160 | roundingCorners.remove(.topRight) 161 | return roundingCorners 162 | } 163 | }() 164 | let maskPath = UIBezierPath(roundedRect: maskRect, byRoundingCorners: lastRowCorners, cornerRadii: cornerRadii) 165 | maskLayer.path = maskPath.cgPath 166 | layer.mask = maskLayer 167 | default: 168 | layer.mask = nil 169 | } 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /CardStyleTableView/Constants.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Constants.swift 3 | // CardStyleTableView 4 | // 5 | // Created by Xin Hong on 16/1/28. 6 | // Copyright © 2016年 Teambition. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | internal struct AssociatedKeys { 12 | static var cardStyleTableViewStyleSource = "CardStyleTableViewStyleSource" 13 | static var cardStyleTableViewCellTableView = "CardStyleTableViewCellTableView" 14 | } 15 | 16 | internal struct TableViewSelectors { 17 | static let layoutSubviews = #selector(UITableView.layoutSubviews) 18 | static let swizzledLayoutSubviews = #selector(UITableView.cardStyle_tableViewSwizzledLayoutSubviews) 19 | } 20 | 21 | internal struct TableViewCellSelectors { 22 | static let layoutSubviews = #selector(UITableViewCell.layoutSubviews) 23 | static let didMoveToSuperview = #selector(UITableViewCell.didMoveToSuperview) 24 | static let swizzledLayoutSubviews = #selector(UITableViewCell.cardStyle_tableViewCellSwizzledLayoutSubviews) 25 | static let swizzledDidMoveToSuperview = #selector(UITableViewCell.cardStyle_tableViewCellSwizzledDidMoveToSuperview) 26 | } 27 | -------------------------------------------------------------------------------- /CardStyleTableView/Protocols.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Protocols.swift 3 | // CardStyleTableView 4 | // 5 | // Created by Xin Hong on 16/1/28. 6 | // Copyright © 2016年 Teambition. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public protocol CardStyleTableViewStyleSource { 12 | func roundingCornersForCard(inSection section: Int) -> UIRectCorner 13 | func leftPaddingForCardStyleTableView() -> CGFloat 14 | func rightPaddingForCardStyleTableView() -> CGFloat 15 | func cornerRadiusForCardStyleTableView() -> CGFloat 16 | } 17 | 18 | public extension CardStyleTableViewStyleSource { 19 | func roundingCornersForCard(inSection section: Int) -> UIRectCorner { 20 | return .allCorners 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CardStyleTableView/Supporting Files/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 | FMWK 17 | CFBundleShortVersionString 18 | $(MARKETING_VERSION) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /CardStyleTableView/WeakObjectContainer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WeakObjectContainer.swift 3 | // CardStyleTableView 4 | // 5 | // Created by Xin Hong on 2016/11/4. 6 | // Copyright © 2016年 Teambition. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class WeakObjectContainer: NSObject { 12 | weak var object: AnyObject? 13 | 14 | init(object: Any?) { 15 | super.init() 16 | self.object = object as AnyObject 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /CardStyleTableViewExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D3788A3C1C5A343A008318C1 /* CardStyleTableView.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3788A3B1C5A343A008318C1 /* CardStyleTableView.framework */; }; 11 | D3788A3D1C5A343A008318C1 /* CardStyleTableView.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D3788A3B1C5A343A008318C1 /* CardStyleTableView.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 12 | D3C25A381C4F388600D3A3DA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3C25A371C4F388600D3A3DA /* AppDelegate.swift */; }; 13 | D3C25A3A1C4F388600D3A3DA /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3C25A391C4F388600D3A3DA /* ViewController.swift */; }; 14 | D3C25A3D1C4F388600D3A3DA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D3C25A3B1C4F388600D3A3DA /* Main.storyboard */; }; 15 | D3C25A3F1C4F388600D3A3DA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D3C25A3E1C4F388600D3A3DA /* Assets.xcassets */; }; 16 | D3C25A681C4F3FAD00D3A3DA /* Example1ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3C25A671C4F3FAD00D3A3DA /* Example1ViewController.swift */; }; 17 | D3C25A6A1C4F9DDA00D3A3DA /* Example2ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3C25A691C4F9DDA00D3A3DA /* Example2ViewController.swift */; }; 18 | D3C25A6C1C4F9E5600D3A3DA /* PhotoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3C25A6B1C4F9E5600D3A3DA /* PhotoCell.swift */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXCopyFilesBuildPhase section */ 22 | D3788A3E1C5A343A008318C1 /* Embed Frameworks */ = { 23 | isa = PBXCopyFilesBuildPhase; 24 | buildActionMask = 2147483647; 25 | dstPath = ""; 26 | dstSubfolderSpec = 10; 27 | files = ( 28 | D3788A3D1C5A343A008318C1 /* CardStyleTableView.framework in Embed Frameworks */, 29 | ); 30 | name = "Embed Frameworks"; 31 | runOnlyForDeploymentPostprocessing = 0; 32 | }; 33 | /* End PBXCopyFilesBuildPhase section */ 34 | 35 | /* Begin PBXFileReference section */ 36 | D3788A3B1C5A343A008318C1 /* CardStyleTableView.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = CardStyleTableView.framework; path = "/Users/hongxin/Library/Developer/Xcode/DerivedData/CardStyleTableView-cpmvapkkiqfompgdktsxoaaqmlak/Build/Products/Debug-iphoneos/CardStyleTableView.framework"; sourceTree = ""; }; 37 | D3C25A341C4F388600D3A3DA /* CardStyleTableViewExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CardStyleTableViewExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | D3C25A371C4F388600D3A3DA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 39 | D3C25A391C4F388600D3A3DA /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 40 | D3C25A3C1C4F388600D3A3DA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 41 | D3C25A3E1C4F388600D3A3DA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 42 | D3C25A431C4F388600D3A3DA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 43 | D3C25A671C4F3FAD00D3A3DA /* Example1ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Example1ViewController.swift; sourceTree = ""; }; 44 | D3C25A691C4F9DDA00D3A3DA /* Example2ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Example2ViewController.swift; sourceTree = ""; }; 45 | D3C25A6B1C4F9E5600D3A3DA /* PhotoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhotoCell.swift; sourceTree = ""; }; 46 | /* End PBXFileReference section */ 47 | 48 | /* Begin PBXFrameworksBuildPhase section */ 49 | D3C25A311C4F388600D3A3DA /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | D3788A3C1C5A343A008318C1 /* CardStyleTableView.framework in Frameworks */, 54 | ); 55 | runOnlyForDeploymentPostprocessing = 0; 56 | }; 57 | /* End PBXFrameworksBuildPhase section */ 58 | 59 | /* Begin PBXGroup section */ 60 | D3C25A2B1C4F388600D3A3DA = { 61 | isa = PBXGroup; 62 | children = ( 63 | D3788A3B1C5A343A008318C1 /* CardStyleTableView.framework */, 64 | D3C25A361C4F388600D3A3DA /* CardStyleTableViewExample */, 65 | D3C25A351C4F388600D3A3DA /* Products */, 66 | ); 67 | sourceTree = ""; 68 | }; 69 | D3C25A351C4F388600D3A3DA /* Products */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | D3C25A341C4F388600D3A3DA /* CardStyleTableViewExample.app */, 73 | ); 74 | name = Products; 75 | sourceTree = ""; 76 | }; 77 | D3C25A361C4F388600D3A3DA /* CardStyleTableViewExample */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | D3C25A371C4F388600D3A3DA /* AppDelegate.swift */, 81 | D3C25A391C4F388600D3A3DA /* ViewController.swift */, 82 | D3C25A671C4F3FAD00D3A3DA /* Example1ViewController.swift */, 83 | D3C25A6B1C4F9E5600D3A3DA /* PhotoCell.swift */, 84 | D3C25A691C4F9DDA00D3A3DA /* Example2ViewController.swift */, 85 | D3C25A3B1C4F388600D3A3DA /* Main.storyboard */, 86 | D3C25A3E1C4F388600D3A3DA /* Assets.xcassets */, 87 | D3C25A431C4F388600D3A3DA /* Info.plist */, 88 | ); 89 | path = CardStyleTableViewExample; 90 | sourceTree = ""; 91 | }; 92 | /* End PBXGroup section */ 93 | 94 | /* Begin PBXNativeTarget section */ 95 | D3C25A331C4F388600D3A3DA /* CardStyleTableViewExample */ = { 96 | isa = PBXNativeTarget; 97 | buildConfigurationList = D3C25A461C4F388600D3A3DA /* Build configuration list for PBXNativeTarget "CardStyleTableViewExample" */; 98 | buildPhases = ( 99 | D3C25A301C4F388600D3A3DA /* Sources */, 100 | D3C25A311C4F388600D3A3DA /* Frameworks */, 101 | D3C25A321C4F388600D3A3DA /* Resources */, 102 | D3788A3E1C5A343A008318C1 /* Embed Frameworks */, 103 | ); 104 | buildRules = ( 105 | ); 106 | dependencies = ( 107 | ); 108 | name = CardStyleTableViewExample; 109 | productName = CardStyleTableViewCell; 110 | productReference = D3C25A341C4F388600D3A3DA /* CardStyleTableViewExample.app */; 111 | productType = "com.apple.product-type.application"; 112 | }; 113 | /* End PBXNativeTarget section */ 114 | 115 | /* Begin PBXProject section */ 116 | D3C25A2C1C4F388600D3A3DA /* Project object */ = { 117 | isa = PBXProject; 118 | attributes = { 119 | LastSwiftUpdateCheck = 0720; 120 | LastUpgradeCheck = 1020; 121 | ORGANIZATIONNAME = Teambition; 122 | TargetAttributes = { 123 | D3C25A331C4F388600D3A3DA = { 124 | CreatedOnToolsVersion = 7.2; 125 | LastSwiftMigration = 0900; 126 | }; 127 | }; 128 | }; 129 | buildConfigurationList = D3C25A2F1C4F388600D3A3DA /* Build configuration list for PBXProject "CardStyleTableViewExample" */; 130 | compatibilityVersion = "Xcode 3.2"; 131 | developmentRegion = en; 132 | hasScannedForEncodings = 0; 133 | knownRegions = ( 134 | en, 135 | Base, 136 | ); 137 | mainGroup = D3C25A2B1C4F388600D3A3DA; 138 | productRefGroup = D3C25A351C4F388600D3A3DA /* Products */; 139 | projectDirPath = ""; 140 | projectRoot = ""; 141 | targets = ( 142 | D3C25A331C4F388600D3A3DA /* CardStyleTableViewExample */, 143 | ); 144 | }; 145 | /* End PBXProject section */ 146 | 147 | /* Begin PBXResourcesBuildPhase section */ 148 | D3C25A321C4F388600D3A3DA /* Resources */ = { 149 | isa = PBXResourcesBuildPhase; 150 | buildActionMask = 2147483647; 151 | files = ( 152 | D3C25A3F1C4F388600D3A3DA /* Assets.xcassets in Resources */, 153 | D3C25A3D1C4F388600D3A3DA /* Main.storyboard in Resources */, 154 | ); 155 | runOnlyForDeploymentPostprocessing = 0; 156 | }; 157 | /* End PBXResourcesBuildPhase section */ 158 | 159 | /* Begin PBXSourcesBuildPhase section */ 160 | D3C25A301C4F388600D3A3DA /* Sources */ = { 161 | isa = PBXSourcesBuildPhase; 162 | buildActionMask = 2147483647; 163 | files = ( 164 | D3C25A6A1C4F9DDA00D3A3DA /* Example2ViewController.swift in Sources */, 165 | D3C25A6C1C4F9E5600D3A3DA /* PhotoCell.swift in Sources */, 166 | D3C25A3A1C4F388600D3A3DA /* ViewController.swift in Sources */, 167 | D3C25A381C4F388600D3A3DA /* AppDelegate.swift in Sources */, 168 | D3C25A681C4F3FAD00D3A3DA /* Example1ViewController.swift in Sources */, 169 | ); 170 | runOnlyForDeploymentPostprocessing = 0; 171 | }; 172 | /* End PBXSourcesBuildPhase section */ 173 | 174 | /* Begin PBXVariantGroup section */ 175 | D3C25A3B1C4F388600D3A3DA /* Main.storyboard */ = { 176 | isa = PBXVariantGroup; 177 | children = ( 178 | D3C25A3C1C4F388600D3A3DA /* Base */, 179 | ); 180 | name = Main.storyboard; 181 | sourceTree = ""; 182 | }; 183 | /* End PBXVariantGroup section */ 184 | 185 | /* Begin XCBuildConfiguration section */ 186 | D3C25A441C4F388600D3A3DA /* Debug */ = { 187 | isa = XCBuildConfiguration; 188 | buildSettings = { 189 | ALWAYS_SEARCH_USER_PATHS = NO; 190 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 191 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 192 | CLANG_CXX_LIBRARY = "libc++"; 193 | CLANG_ENABLE_MODULES = YES; 194 | CLANG_ENABLE_OBJC_ARC = YES; 195 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 196 | CLANG_WARN_BOOL_CONVERSION = YES; 197 | CLANG_WARN_COMMA = YES; 198 | CLANG_WARN_CONSTANT_CONVERSION = YES; 199 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 200 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 201 | CLANG_WARN_EMPTY_BODY = YES; 202 | CLANG_WARN_ENUM_CONVERSION = YES; 203 | CLANG_WARN_INFINITE_RECURSION = YES; 204 | CLANG_WARN_INT_CONVERSION = YES; 205 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 206 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 207 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 208 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 209 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 210 | CLANG_WARN_STRICT_PROTOTYPES = YES; 211 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 212 | CLANG_WARN_UNREACHABLE_CODE = YES; 213 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 214 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 215 | COPY_PHASE_STRIP = NO; 216 | DEBUG_INFORMATION_FORMAT = dwarf; 217 | ENABLE_STRICT_OBJC_MSGSEND = YES; 218 | ENABLE_TESTABILITY = YES; 219 | GCC_C_LANGUAGE_STANDARD = gnu99; 220 | GCC_DYNAMIC_NO_PIC = NO; 221 | GCC_NO_COMMON_BLOCKS = YES; 222 | GCC_OPTIMIZATION_LEVEL = 0; 223 | GCC_PREPROCESSOR_DEFINITIONS = ( 224 | "DEBUG=1", 225 | "$(inherited)", 226 | ); 227 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 228 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 229 | GCC_WARN_UNDECLARED_SELECTOR = YES; 230 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 231 | GCC_WARN_UNUSED_FUNCTION = YES; 232 | GCC_WARN_UNUSED_VARIABLE = YES; 233 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 234 | MTL_ENABLE_DEBUG_INFO = YES; 235 | ONLY_ACTIVE_ARCH = YES; 236 | SDKROOT = iphoneos; 237 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 238 | TARGETED_DEVICE_FAMILY = "1,2"; 239 | }; 240 | name = Debug; 241 | }; 242 | D3C25A451C4F388600D3A3DA /* Release */ = { 243 | isa = XCBuildConfiguration; 244 | buildSettings = { 245 | ALWAYS_SEARCH_USER_PATHS = NO; 246 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 247 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 248 | CLANG_CXX_LIBRARY = "libc++"; 249 | CLANG_ENABLE_MODULES = YES; 250 | CLANG_ENABLE_OBJC_ARC = YES; 251 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 252 | CLANG_WARN_BOOL_CONVERSION = YES; 253 | CLANG_WARN_COMMA = YES; 254 | CLANG_WARN_CONSTANT_CONVERSION = YES; 255 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 256 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 257 | CLANG_WARN_EMPTY_BODY = YES; 258 | CLANG_WARN_ENUM_CONVERSION = YES; 259 | CLANG_WARN_INFINITE_RECURSION = YES; 260 | CLANG_WARN_INT_CONVERSION = YES; 261 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 262 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 263 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 264 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 265 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 266 | CLANG_WARN_STRICT_PROTOTYPES = YES; 267 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 268 | CLANG_WARN_UNREACHABLE_CODE = YES; 269 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 270 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 271 | COPY_PHASE_STRIP = NO; 272 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 273 | ENABLE_NS_ASSERTIONS = NO; 274 | ENABLE_STRICT_OBJC_MSGSEND = YES; 275 | GCC_C_LANGUAGE_STANDARD = gnu99; 276 | GCC_NO_COMMON_BLOCKS = YES; 277 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 278 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 279 | GCC_WARN_UNDECLARED_SELECTOR = YES; 280 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 281 | GCC_WARN_UNUSED_FUNCTION = YES; 282 | GCC_WARN_UNUSED_VARIABLE = YES; 283 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 284 | MTL_ENABLE_DEBUG_INFO = NO; 285 | SDKROOT = iphoneos; 286 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 287 | TARGETED_DEVICE_FAMILY = "1,2"; 288 | VALIDATE_PRODUCT = YES; 289 | }; 290 | name = Release; 291 | }; 292 | D3C25A471C4F388600D3A3DA /* Debug */ = { 293 | isa = XCBuildConfiguration; 294 | buildSettings = { 295 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 296 | INFOPLIST_FILE = "$(SRCROOT)/CardStyleTableViewExample/Info.plist"; 297 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 298 | PRODUCT_BUNDLE_IDENTIFIER = Teambition.CardStyleTableViewExample; 299 | PRODUCT_NAME = CardStyleTableViewExample; 300 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 301 | SWIFT_VERSION = 5.0; 302 | }; 303 | name = Debug; 304 | }; 305 | D3C25A481C4F388600D3A3DA /* Release */ = { 306 | isa = XCBuildConfiguration; 307 | buildSettings = { 308 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 309 | INFOPLIST_FILE = "$(SRCROOT)/CardStyleTableViewExample/Info.plist"; 310 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 311 | PRODUCT_BUNDLE_IDENTIFIER = Teambition.CardStyleTableViewExample; 312 | PRODUCT_NAME = CardStyleTableViewExample; 313 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 314 | SWIFT_VERSION = 5.0; 315 | }; 316 | name = Release; 317 | }; 318 | /* End XCBuildConfiguration section */ 319 | 320 | /* Begin XCConfigurationList section */ 321 | D3C25A2F1C4F388600D3A3DA /* Build configuration list for PBXProject "CardStyleTableViewExample" */ = { 322 | isa = XCConfigurationList; 323 | buildConfigurations = ( 324 | D3C25A441C4F388600D3A3DA /* Debug */, 325 | D3C25A451C4F388600D3A3DA /* Release */, 326 | ); 327 | defaultConfigurationIsVisible = 0; 328 | defaultConfigurationName = Release; 329 | }; 330 | D3C25A461C4F388600D3A3DA /* Build configuration list for PBXNativeTarget "CardStyleTableViewExample" */ = { 331 | isa = XCConfigurationList; 332 | buildConfigurations = ( 333 | D3C25A471C4F388600D3A3DA /* Debug */, 334 | D3C25A481C4F388600D3A3DA /* Release */, 335 | ); 336 | defaultConfigurationIsVisible = 0; 337 | defaultConfigurationName = Release; 338 | }; 339 | /* End XCConfigurationList section */ 340 | }; 341 | rootObject = D3C25A2C1C4F388600D3A3DA /* Project object */; 342 | } 343 | -------------------------------------------------------------------------------- /CardStyleTableViewExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CardStyleTableViewExample.xcodeproj/xcuserdata/hongxin.xcuserdatad/xcschemes/CardStyleTableViewExample.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 | -------------------------------------------------------------------------------- /CardStyleTableViewExample.xcodeproj/xcuserdata/hongxin.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CardStyleTableViewExample.xcscheme 8 | 9 | orderHint 10 | 1 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | D3C25A331C4F388600D3A3DA 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /CardStyleTableViewExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CardStyleTableViewExample 4 | // 5 | // Created by 洪鑫 on 16/1/20. 6 | // Copyright © 2016年 Teambition. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CardStyleTableView 11 | 12 | @UIApplicationMain 13 | class AppDelegate: UIResponder, UIApplicationDelegate { 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { 17 | CardStyle.setup() 18 | return true 19 | } 20 | 21 | func applicationWillResignActive(_ application: UIApplication) { 22 | 23 | } 24 | 25 | func applicationDidEnterBackground(_ application: UIApplication) { 26 | 27 | } 28 | 29 | func applicationWillEnterForeground(_ application: UIApplication) { 30 | 31 | } 32 | 33 | func applicationDidBecomeActive(_ application: UIApplication) { 34 | 35 | } 36 | 37 | func applicationWillTerminate(_ application: UIApplication) { 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /CardStyleTableViewExample/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 | "idiom" : "ipad", 65 | "size" : "83.5x83.5", 66 | "scale" : "2x" 67 | } 68 | ], 69 | "info" : { 70 | "version" : 1, 71 | "author" : "xcode" 72 | } 73 | } -------------------------------------------------------------------------------- /CardStyleTableViewExample/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CardStyleTableViewExample/Assets.xcassets/examplePicture.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "examplePicture.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "examplePicture@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "examplePicture@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /CardStyleTableViewExample/Assets.xcassets/examplePicture.imageset/examplePicture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teambition/CardStyleTableView/d9d0179f555cd745b285baeb7d9ceca7dd995c9a/CardStyleTableViewExample/Assets.xcassets/examplePicture.imageset/examplePicture.png -------------------------------------------------------------------------------- /CardStyleTableViewExample/Assets.xcassets/examplePicture.imageset/examplePicture@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teambition/CardStyleTableView/d9d0179f555cd745b285baeb7d9ceca7dd995c9a/CardStyleTableViewExample/Assets.xcassets/examplePicture.imageset/examplePicture@2x.png -------------------------------------------------------------------------------- /CardStyleTableViewExample/Assets.xcassets/examplePicture.imageset/examplePicture@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teambition/CardStyleTableView/d9d0179f555cd745b285baeb7d9ceca7dd995c9a/CardStyleTableViewExample/Assets.xcassets/examplePicture.imageset/examplePicture@3x.png -------------------------------------------------------------------------------- /CardStyleTableViewExample/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 | 40 | 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 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 119 | 124 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | -------------------------------------------------------------------------------- /CardStyleTableViewExample/Example1ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Example1ViewController.swift 3 | // CardStyleTableViewExample 4 | // 5 | // Created by 洪鑫 on 16/1/20. 6 | // Copyright © 2016年 Teambition. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CardStyleTableView 11 | 12 | class Example1ViewController: UITableViewController { 13 | // MARK: - Life cycle 14 | override func viewDidLoad() { 15 | super.viewDidLoad() 16 | tableView.cardStyleSource = self 17 | } 18 | 19 | // MARK: - Table view data source and delegate 20 | override func numberOfSections(in tableView: UITableView) -> Int { 21 | return 10 22 | } 23 | 24 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 25 | return section + 1 26 | } 27 | 28 | override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 29 | return 60 30 | } 31 | 32 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 33 | var cell = tableView.dequeueReusableCell(withIdentifier: "Cell") 34 | if cell == nil { 35 | cell = UITableViewCell(style: .value1, reuseIdentifier: "Cell") 36 | } 37 | 38 | let remainder = indexPath.section % 5 39 | switch remainder { 40 | case 0: 41 | cell!.accessoryType = .disclosureIndicator 42 | case 1: 43 | cell!.accessoryType = .checkmark 44 | case 2: 45 | cell!.accessoryType = .detailButton 46 | case 3: 47 | cell!.accessoryType = .detailDisclosureButton 48 | default: 49 | cell!.accessoryType = .none 50 | } 51 | cell?.textLabel?.text = "Cell" 52 | cell?.detailTextLabel?.text = "Row \(indexPath.row), Section \(indexPath.section)" 53 | 54 | return cell! 55 | } 56 | 57 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 58 | 59 | } 60 | } 61 | 62 | extension Example1ViewController: CardStyleTableViewStyleSource { 63 | func roundingCornersForCard(inSection section: Int) -> UIRectCorner { 64 | return [.allCorners] 65 | } 66 | 67 | func leftPaddingForCardStyleTableView() -> CGFloat { 68 | return 20 69 | } 70 | 71 | func rightPaddingForCardStyleTableView() -> CGFloat { 72 | return 20 73 | } 74 | 75 | func cornerRadiusForCardStyleTableView() -> CGFloat { 76 | return 8 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /CardStyleTableViewExample/Example2ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Example2ViewController.swift 3 | // CardStyleTableViewExample 4 | // 5 | // Created by 洪鑫 on 16/1/20. 6 | // Copyright © 2016年 Teambition. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CardStyleTableView 11 | 12 | class Example2ViewController: UITableViewController { 13 | // MARK: - Life cycle 14 | override func viewDidLoad() { 15 | super.viewDidLoad() 16 | tableView.cardStyleSource = self 17 | } 18 | 19 | // MARK: - Table view data source and delegate 20 | override func numberOfSections(in tableView: UITableView) -> Int { 21 | return 10 22 | } 23 | 24 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 25 | return section + 1 26 | } 27 | 28 | override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 29 | return 70 30 | } 31 | 32 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 33 | let cell = tableView.dequeueReusableCell(withIdentifier: "PhotoCell", for: indexPath) as! PhotoCell 34 | return cell 35 | } 36 | 37 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 38 | 39 | } 40 | 41 | } 42 | 43 | extension Example2ViewController: CardStyleTableViewStyleSource { 44 | func roundingCornersForCard(inSection section: Int) -> UIRectCorner { 45 | return [.allCorners] 46 | } 47 | 48 | func leftPaddingForCardStyleTableView() -> CGFloat { 49 | return 10 50 | } 51 | 52 | func rightPaddingForCardStyleTableView() -> CGFloat { 53 | return 10 54 | } 55 | 56 | func cornerRadiusForCardStyleTableView() -> CGFloat { 57 | return 6 58 | } 59 | } 60 | 61 | -------------------------------------------------------------------------------- /CardStyleTableViewExample/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 | 0.1.3 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 12 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 | -------------------------------------------------------------------------------- /CardStyleTableViewExample/PhotoCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PhotoCell.swift 3 | // CardStyleTableViewExample 4 | // 5 | // Created by 洪鑫 on 16/1/20. 6 | // Copyright © 2016年 Teambition. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class PhotoCell: UITableViewCell { 12 | override func awakeFromNib() { 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /CardStyleTableViewExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // CardStyleTableViewExample 4 | // 5 | // Created by 洪鑫 on 16/1/20. 6 | // Copyright © 2016年 Teambition. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | override func viewDidLoad() { 13 | super.viewDidLoad() 14 | navigationItem.title = "CardStyle TableView" 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Teambition 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, 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, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CardStyleTableView 2 | An extension of UITableView and UITableViewCell which displays a card style view in grouped tableView, similar to the system's tableView before iOS 7. 3 | 4 | ![Screenshot](Screenshots/Screenshot-1.png "Screenshot-1") 5 | 6 | ![Screenshot](Screenshots/Screenshot-2.png "Screenshot-2") 7 | 8 | 9 | ## How To Get Started 10 | ### Carthage 11 | Specify "CardStyleTableView" in your ```Cartfile```: 12 | ```ogdl 13 | github "teambition/CardStyleTableView" 14 | ``` 15 | 16 | ### CocoaPods (version equal or above 0.1.4) 17 | 18 | [CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command: 19 | 20 | ```bash 21 | $ gem install cocoapods 22 | ``` 23 | 24 | To integrate features into your Xcode project using CocoaPods, specify it in your `Podfile`: 25 | 26 | ```ruby 27 | source 'https://github.com/CocoaPods/Specs.git' 28 | platform :ios, '8.0' 29 | use_frameworks! 30 | 31 | pod 'TBCardStyleTableView, '~> 0.1.4' 32 | ``` 33 | 34 | Then, run the following command: 35 | 36 | ```bash 37 | $ pod install 38 | ``` 39 | 40 | ### Usage 41 | #### Import CardStyleTableView 42 | ```swift 43 | import CardStyleTableView 44 | ``` 45 | 46 | #### Setup in your ```AppDelegate``` 47 | ```swift 48 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 49 | CardStyle.setup() 50 | return true 51 | } 52 | ``` 53 | 54 | #### Assign delegate 55 | ```swift 56 | tableView.cardStyleSource = self 57 | ``` 58 | 59 | #### CardStyleTableViewStyleSource 60 | ```swift 61 | func roundingCornersForCard(inSection section: Int) -> UIRectCorner { 62 | // set rounding corners of this section, default is .allCorners 63 | } 64 | 65 | func leftPaddingForCardStyleTableView() -> CGFloat { 66 | // leftPadding 67 | } 68 | 69 | func rightPaddingForCardStyleTableView() -> CGFloat { 70 | // rightPadding 71 | } 72 | 73 | func cornerRadiusForCardStyleTableView() -> CGFloat { 74 | // cornerRadius 75 | } 76 | ``` 77 | 78 | ## Minimum Requirement 79 | iOS 8.0 80 | 81 | ## Release Notes 82 | * [Release Notes](https://github.com/teambition/CardStyleTableView/releases) 83 | 84 | ## License 85 | CardStyleTableView is released under the MIT license. See [LICENSE](https://github.com/teambition/CardStyleTableView/blob/master/LICENSE.md) for details. 86 | 87 | ## More Info 88 | Have a question? Please [open an issue](https://github.com/teambition/CardStyleTableView/issues/new)! 89 | 90 | 91 | -------------------------------------------------------------------------------- /Screenshots/Screenshot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teambition/CardStyleTableView/d9d0179f555cd745b285baeb7d9ceca7dd995c9a/Screenshots/Screenshot-1.png -------------------------------------------------------------------------------- /Screenshots/Screenshot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teambition/CardStyleTableView/d9d0179f555cd745b285baeb7d9ceca7dd995c9a/Screenshots/Screenshot-2.png -------------------------------------------------------------------------------- /TBCardStyleTableView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |spec| 2 | 3 | spec.name = "TBCardStyleTableView" 4 | spec.version = "0.1.5" 5 | spec.summary = "TBCardSyleTableView is an extension of UITableView and UITableViewCell which displays a card style view in grouped tableView" 6 | 7 | spec.homepage = "https://github.com/teambition/CardStyleTableView" 8 | spec.license = { :type => "MIT", :file => "LICENSE.md" } 9 | spec.author = { "bruce" => "liangmingzou@163.com" } 10 | spec.platform = :ios, "8.0" 11 | spec.source = { :git => "https://github.com/teambition/CardStyleTableView.git", :tag => "#{spec.version}" } 12 | spec.swift_version = "5.0" 13 | 14 | spec.source_files = "CardStyleTableView/*.swift" 15 | spec.frameworks = "Foundation", "UIKit" 16 | 17 | end 18 | --------------------------------------------------------------------------------