├── .gitignore ├── README.md ├── Swift616.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── sunset.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── sunset.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── Swift616.xcscheme │ └── xcschememanagement.plist ├── Swift616 ├── AppDelegate.swift ├── Calendar │ ├── CalendarCell.swift │ ├── CalendarViewController.swift │ ├── Color.swift │ ├── Datecalculate.swift │ └── DayCell.swift ├── DateObject.swift ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── LaunchImage.launchimage │ │ └── Contents.json │ ├── first.imageset │ │ ├── Contents.json │ │ ├── first.png │ │ └── first@2x.png │ └── second.imageset │ │ ├── Contents.json │ │ ├── second.png │ │ └── second@2x.png └── Info.plist └── Swift616Tests ├── Info.plist └── Swift616Tests.swift /.gitignore: -------------------------------------------------------------------------------- 1 | 学习swift 所写的日历 同时用到了 delegate 和closure 作为回调函数只是出于练习目的 代码不规范 很多没用宏只是出于方便 不要骂!!! -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | swift-- 2 | ======= 3 | 4 | 学习 swift 写的一个日历控件 5 | 学习swift 所写的日历 同时用到了 delegate 和closure 作为回调函数只是出于练习目的 代码不规范 很多没用宏只是出于方便 不要骂!!! 6 | -------------------------------------------------------------------------------- /Swift616.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CB0BB59019502845003E78E2 /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB0BB58F19502845003E78E2 /* Color.swift */; }; 11 | CB32D590194E896100AE9045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB32D58F194E896100AE9045 /* AppDelegate.swift */; }; 12 | CB32D599194E896200AE9045 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CB32D598194E896200AE9045 /* Images.xcassets */; }; 13 | CB32D5A5194E896300AE9045 /* Swift616Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB32D5A4194E896300AE9045 /* Swift616Tests.swift */; }; 14 | CB32D5B5194E90DE00AE9045 /* Datecalculate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB32D5B4194E90DE00AE9045 /* Datecalculate.swift */; }; 15 | CB5FD815194EB70C00247979 /* DateObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB5FD814194EB70C00247979 /* DateObject.swift */; }; 16 | CB5FD817194EBA2200247979 /* DayCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB5FD816194EBA2200247979 /* DayCell.swift */; }; 17 | CB6B357F194EDDB00079C94A /* CalendarCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB6B357E194EDDB00079C94A /* CalendarCell.swift */; }; 18 | CB6B3581194FD4C60079C94A /* CalendarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB6B3580194FD4C60079C94A /* CalendarViewController.swift */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | CB32D59F194E896300AE9045 /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = CB32D582194E896000AE9045 /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = CB32D589194E896000AE9045; 27 | remoteInfo = Swift616; 28 | }; 29 | /* End PBXContainerItemProxy section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | CB0BB58F19502845003E78E2 /* Color.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = ""; }; 33 | CB32D58A194E896000AE9045 /* Swift616.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Swift616.app; sourceTree = BUILT_PRODUCTS_DIR; }; 34 | CB32D58E194E896000AE9045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 35 | CB32D58F194E896100AE9045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 36 | CB32D598194E896200AE9045 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 37 | CB32D59E194E896300AE9045 /* Swift616Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Swift616Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | CB32D5A3194E896300AE9045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 39 | CB32D5A4194E896300AE9045 /* Swift616Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Swift616Tests.swift; sourceTree = ""; }; 40 | CB32D5B4194E90DE00AE9045 /* Datecalculate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Datecalculate.swift; sourceTree = ""; }; 41 | CB5FD814194EB70C00247979 /* DateObject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DateObject.swift; path = ../DateObject.swift; sourceTree = ""; }; 42 | CB5FD816194EBA2200247979 /* DayCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DayCell.swift; sourceTree = ""; }; 43 | CB6B357E194EDDB00079C94A /* CalendarCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CalendarCell.swift; sourceTree = ""; }; 44 | CB6B3580194FD4C60079C94A /* CalendarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CalendarViewController.swift; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | CB32D587194E896000AE9045 /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | CB32D59B194E896300AE9045 /* Frameworks */ = { 56 | isa = PBXFrameworksBuildPhase; 57 | buildActionMask = 2147483647; 58 | files = ( 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | /* End PBXFrameworksBuildPhase section */ 63 | 64 | /* Begin PBXGroup section */ 65 | CB32D581194E896000AE9045 = { 66 | isa = PBXGroup; 67 | children = ( 68 | CB32D58C194E896000AE9045 /* Swift616 */, 69 | CB32D5A1194E896300AE9045 /* Swift616Tests */, 70 | CB32D58B194E896000AE9045 /* Products */, 71 | ); 72 | sourceTree = ""; 73 | }; 74 | CB32D58B194E896000AE9045 /* Products */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | CB32D58A194E896000AE9045 /* Swift616.app */, 78 | CB32D59E194E896300AE9045 /* Swift616Tests.xctest */, 79 | ); 80 | name = Products; 81 | sourceTree = ""; 82 | }; 83 | CB32D58C194E896000AE9045 /* Swift616 */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | CB32D5B3194E90CD00AE9045 /* Calendar */, 87 | CB32D58F194E896100AE9045 /* AppDelegate.swift */, 88 | CB32D598194E896200AE9045 /* Images.xcassets */, 89 | CB32D58D194E896000AE9045 /* Supporting Files */, 90 | ); 91 | path = Swift616; 92 | sourceTree = ""; 93 | }; 94 | CB32D58D194E896000AE9045 /* Supporting Files */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | CB32D58E194E896000AE9045 /* Info.plist */, 98 | ); 99 | name = "Supporting Files"; 100 | sourceTree = ""; 101 | }; 102 | CB32D5A1194E896300AE9045 /* Swift616Tests */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | CB32D5A4194E896300AE9045 /* Swift616Tests.swift */, 106 | CB32D5A2194E896300AE9045 /* Supporting Files */, 107 | ); 108 | path = Swift616Tests; 109 | sourceTree = ""; 110 | }; 111 | CB32D5A2194E896300AE9045 /* Supporting Files */ = { 112 | isa = PBXGroup; 113 | children = ( 114 | CB32D5A3194E896300AE9045 /* Info.plist */, 115 | ); 116 | name = "Supporting Files"; 117 | sourceTree = ""; 118 | }; 119 | CB32D5B3194E90CD00AE9045 /* Calendar */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | CB5FD814194EB70C00247979 /* DateObject.swift */, 123 | CB32D5B4194E90DE00AE9045 /* Datecalculate.swift */, 124 | CB5FD816194EBA2200247979 /* DayCell.swift */, 125 | CB6B357E194EDDB00079C94A /* CalendarCell.swift */, 126 | CB6B3580194FD4C60079C94A /* CalendarViewController.swift */, 127 | CB0BB58F19502845003E78E2 /* Color.swift */, 128 | ); 129 | path = Calendar; 130 | sourceTree = ""; 131 | }; 132 | /* End PBXGroup section */ 133 | 134 | /* Begin PBXNativeTarget section */ 135 | CB32D589194E896000AE9045 /* Swift616 */ = { 136 | isa = PBXNativeTarget; 137 | buildConfigurationList = CB32D5A8194E896300AE9045 /* Build configuration list for PBXNativeTarget "Swift616" */; 138 | buildPhases = ( 139 | CB32D586194E896000AE9045 /* Sources */, 140 | CB32D587194E896000AE9045 /* Frameworks */, 141 | CB32D588194E896000AE9045 /* Resources */, 142 | ); 143 | buildRules = ( 144 | ); 145 | dependencies = ( 146 | ); 147 | name = Swift616; 148 | productName = Swift616; 149 | productReference = CB32D58A194E896000AE9045 /* Swift616.app */; 150 | productType = "com.apple.product-type.application"; 151 | }; 152 | CB32D59D194E896300AE9045 /* Swift616Tests */ = { 153 | isa = PBXNativeTarget; 154 | buildConfigurationList = CB32D5AB194E896300AE9045 /* Build configuration list for PBXNativeTarget "Swift616Tests" */; 155 | buildPhases = ( 156 | CB32D59A194E896300AE9045 /* Sources */, 157 | CB32D59B194E896300AE9045 /* Frameworks */, 158 | CB32D59C194E896300AE9045 /* Resources */, 159 | ); 160 | buildRules = ( 161 | ); 162 | dependencies = ( 163 | CB32D5A0194E896300AE9045 /* PBXTargetDependency */, 164 | ); 165 | name = Swift616Tests; 166 | productName = Swift616Tests; 167 | productReference = CB32D59E194E896300AE9045 /* Swift616Tests.xctest */; 168 | productType = "com.apple.product-type.bundle.unit-test"; 169 | }; 170 | /* End PBXNativeTarget section */ 171 | 172 | /* Begin PBXProject section */ 173 | CB32D582194E896000AE9045 /* Project object */ = { 174 | isa = PBXProject; 175 | attributes = { 176 | LastUpgradeCheck = 0600; 177 | ORGANIZATIONNAME = SunSet; 178 | TargetAttributes = { 179 | CB32D589194E896000AE9045 = { 180 | CreatedOnToolsVersion = 6.0; 181 | }; 182 | CB32D59D194E896300AE9045 = { 183 | CreatedOnToolsVersion = 6.0; 184 | TestTargetID = CB32D589194E896000AE9045; 185 | }; 186 | }; 187 | }; 188 | buildConfigurationList = CB32D585194E896000AE9045 /* Build configuration list for PBXProject "Swift616" */; 189 | compatibilityVersion = "Xcode 3.2"; 190 | developmentRegion = English; 191 | hasScannedForEncodings = 0; 192 | knownRegions = ( 193 | en, 194 | Base, 195 | ); 196 | mainGroup = CB32D581194E896000AE9045; 197 | productRefGroup = CB32D58B194E896000AE9045 /* Products */; 198 | projectDirPath = ""; 199 | projectRoot = ""; 200 | targets = ( 201 | CB32D589194E896000AE9045 /* Swift616 */, 202 | CB32D59D194E896300AE9045 /* Swift616Tests */, 203 | ); 204 | }; 205 | /* End PBXProject section */ 206 | 207 | /* Begin PBXResourcesBuildPhase section */ 208 | CB32D588194E896000AE9045 /* Resources */ = { 209 | isa = PBXResourcesBuildPhase; 210 | buildActionMask = 2147483647; 211 | files = ( 212 | CB32D599194E896200AE9045 /* Images.xcassets in Resources */, 213 | ); 214 | runOnlyForDeploymentPostprocessing = 0; 215 | }; 216 | CB32D59C194E896300AE9045 /* Resources */ = { 217 | isa = PBXResourcesBuildPhase; 218 | buildActionMask = 2147483647; 219 | files = ( 220 | ); 221 | runOnlyForDeploymentPostprocessing = 0; 222 | }; 223 | /* End PBXResourcesBuildPhase section */ 224 | 225 | /* Begin PBXSourcesBuildPhase section */ 226 | CB32D586194E896000AE9045 /* Sources */ = { 227 | isa = PBXSourcesBuildPhase; 228 | buildActionMask = 2147483647; 229 | files = ( 230 | CB6B3581194FD4C60079C94A /* CalendarViewController.swift in Sources */, 231 | CB32D590194E896100AE9045 /* AppDelegate.swift in Sources */, 232 | CB0BB59019502845003E78E2 /* Color.swift in Sources */, 233 | CB6B357F194EDDB00079C94A /* CalendarCell.swift in Sources */, 234 | CB5FD815194EB70C00247979 /* DateObject.swift in Sources */, 235 | CB32D5B5194E90DE00AE9045 /* Datecalculate.swift in Sources */, 236 | CB5FD817194EBA2200247979 /* DayCell.swift in Sources */, 237 | ); 238 | runOnlyForDeploymentPostprocessing = 0; 239 | }; 240 | CB32D59A194E896300AE9045 /* Sources */ = { 241 | isa = PBXSourcesBuildPhase; 242 | buildActionMask = 2147483647; 243 | files = ( 244 | CB32D5A5194E896300AE9045 /* Swift616Tests.swift in Sources */, 245 | ); 246 | runOnlyForDeploymentPostprocessing = 0; 247 | }; 248 | /* End PBXSourcesBuildPhase section */ 249 | 250 | /* Begin PBXTargetDependency section */ 251 | CB32D5A0194E896300AE9045 /* PBXTargetDependency */ = { 252 | isa = PBXTargetDependency; 253 | target = CB32D589194E896000AE9045 /* Swift616 */; 254 | targetProxy = CB32D59F194E896300AE9045 /* PBXContainerItemProxy */; 255 | }; 256 | /* End PBXTargetDependency section */ 257 | 258 | /* Begin XCBuildConfiguration section */ 259 | CB32D5A6194E896300AE9045 /* Debug */ = { 260 | isa = XCBuildConfiguration; 261 | buildSettings = { 262 | ALWAYS_SEARCH_USER_PATHS = NO; 263 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 264 | CLANG_CXX_LIBRARY = "libc++"; 265 | CLANG_ENABLE_MODULES = YES; 266 | CLANG_ENABLE_OBJC_ARC = YES; 267 | CLANG_WARN_BOOL_CONVERSION = YES; 268 | CLANG_WARN_CONSTANT_CONVERSION = YES; 269 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 270 | CLANG_WARN_EMPTY_BODY = YES; 271 | CLANG_WARN_ENUM_CONVERSION = YES; 272 | CLANG_WARN_INT_CONVERSION = YES; 273 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 274 | CLANG_WARN_UNREACHABLE_CODE = YES; 275 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 276 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 277 | COPY_PHASE_STRIP = NO; 278 | ENABLE_STRICT_OBJC_MSGSEND = YES; 279 | GCC_C_LANGUAGE_STANDARD = gnu99; 280 | GCC_DYNAMIC_NO_PIC = NO; 281 | GCC_OPTIMIZATION_LEVEL = 0; 282 | GCC_PREPROCESSOR_DEFINITIONS = ( 283 | "DEBUG=1", 284 | "$(inherited)", 285 | ); 286 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 287 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 288 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 289 | GCC_WARN_UNDECLARED_SELECTOR = YES; 290 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 291 | GCC_WARN_UNUSED_FUNCTION = YES; 292 | GCC_WARN_UNUSED_VARIABLE = YES; 293 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 294 | METAL_ENABLE_DEBUG_INFO = YES; 295 | ONLY_ACTIVE_ARCH = YES; 296 | SDKROOT = iphoneos; 297 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 298 | }; 299 | name = Debug; 300 | }; 301 | CB32D5A7194E896300AE9045 /* Release */ = { 302 | isa = XCBuildConfiguration; 303 | buildSettings = { 304 | ALWAYS_SEARCH_USER_PATHS = NO; 305 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 306 | CLANG_CXX_LIBRARY = "libc++"; 307 | CLANG_ENABLE_MODULES = YES; 308 | CLANG_ENABLE_OBJC_ARC = YES; 309 | CLANG_WARN_BOOL_CONVERSION = YES; 310 | CLANG_WARN_CONSTANT_CONVERSION = YES; 311 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 312 | CLANG_WARN_EMPTY_BODY = YES; 313 | CLANG_WARN_ENUM_CONVERSION = YES; 314 | CLANG_WARN_INT_CONVERSION = YES; 315 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 316 | CLANG_WARN_UNREACHABLE_CODE = YES; 317 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 318 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 319 | COPY_PHASE_STRIP = YES; 320 | ENABLE_NS_ASSERTIONS = NO; 321 | ENABLE_STRICT_OBJC_MSGSEND = YES; 322 | GCC_C_LANGUAGE_STANDARD = gnu99; 323 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 324 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 325 | GCC_WARN_UNDECLARED_SELECTOR = YES; 326 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 327 | GCC_WARN_UNUSED_FUNCTION = YES; 328 | GCC_WARN_UNUSED_VARIABLE = YES; 329 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 330 | METAL_ENABLE_DEBUG_INFO = NO; 331 | SDKROOT = iphoneos; 332 | VALIDATE_PRODUCT = YES; 333 | }; 334 | name = Release; 335 | }; 336 | CB32D5A9194E896300AE9045 /* Debug */ = { 337 | isa = XCBuildConfiguration; 338 | buildSettings = { 339 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 340 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 341 | INFOPLIST_FILE = Swift616/Info.plist; 342 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 343 | PRODUCT_NAME = "$(TARGET_NAME)"; 344 | }; 345 | name = Debug; 346 | }; 347 | CB32D5AA194E896300AE9045 /* Release */ = { 348 | isa = XCBuildConfiguration; 349 | buildSettings = { 350 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 351 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 352 | INFOPLIST_FILE = Swift616/Info.plist; 353 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 354 | PRODUCT_NAME = "$(TARGET_NAME)"; 355 | }; 356 | name = Release; 357 | }; 358 | CB32D5AC194E896300AE9045 /* Debug */ = { 359 | isa = XCBuildConfiguration; 360 | buildSettings = { 361 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/Swift616.app/Swift616"; 362 | FRAMEWORK_SEARCH_PATHS = ( 363 | "$(SDKROOT)/Developer/Library/Frameworks", 364 | "$(inherited)", 365 | ); 366 | GCC_PREPROCESSOR_DEFINITIONS = ( 367 | "DEBUG=1", 368 | "$(inherited)", 369 | ); 370 | INFOPLIST_FILE = Swift616Tests/Info.plist; 371 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 372 | METAL_ENABLE_DEBUG_INFO = YES; 373 | PRODUCT_NAME = "$(TARGET_NAME)"; 374 | TEST_HOST = "$(BUNDLE_LOADER)"; 375 | }; 376 | name = Debug; 377 | }; 378 | CB32D5AD194E896300AE9045 /* Release */ = { 379 | isa = XCBuildConfiguration; 380 | buildSettings = { 381 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/Swift616.app/Swift616"; 382 | FRAMEWORK_SEARCH_PATHS = ( 383 | "$(SDKROOT)/Developer/Library/Frameworks", 384 | "$(inherited)", 385 | ); 386 | INFOPLIST_FILE = Swift616Tests/Info.plist; 387 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 388 | METAL_ENABLE_DEBUG_INFO = NO; 389 | PRODUCT_NAME = "$(TARGET_NAME)"; 390 | TEST_HOST = "$(BUNDLE_LOADER)"; 391 | }; 392 | name = Release; 393 | }; 394 | /* End XCBuildConfiguration section */ 395 | 396 | /* Begin XCConfigurationList section */ 397 | CB32D585194E896000AE9045 /* Build configuration list for PBXProject "Swift616" */ = { 398 | isa = XCConfigurationList; 399 | buildConfigurations = ( 400 | CB32D5A6194E896300AE9045 /* Debug */, 401 | CB32D5A7194E896300AE9045 /* Release */, 402 | ); 403 | defaultConfigurationIsVisible = 0; 404 | defaultConfigurationName = Release; 405 | }; 406 | CB32D5A8194E896300AE9045 /* Build configuration list for PBXNativeTarget "Swift616" */ = { 407 | isa = XCConfigurationList; 408 | buildConfigurations = ( 409 | CB32D5A9194E896300AE9045 /* Debug */, 410 | CB32D5AA194E896300AE9045 /* Release */, 411 | ); 412 | defaultConfigurationIsVisible = 0; 413 | defaultConfigurationName = Release; 414 | }; 415 | CB32D5AB194E896300AE9045 /* Build configuration list for PBXNativeTarget "Swift616Tests" */ = { 416 | isa = XCConfigurationList; 417 | buildConfigurations = ( 418 | CB32D5AC194E896300AE9045 /* Debug */, 419 | CB32D5AD194E896300AE9045 /* Release */, 420 | ); 421 | defaultConfigurationIsVisible = 0; 422 | defaultConfigurationName = Release; 423 | }; 424 | /* End XCConfigurationList section */ 425 | }; 426 | rootObject = CB32D582194E896000AE9045 /* Project object */; 427 | } 428 | -------------------------------------------------------------------------------- /Swift616.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift616.xcodeproj/project.xcworkspace/xcuserdata/sunset.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaokaiyuan99/swift--/dd720eebae6d9c2cc8b138b8f94ec45474c099af/Swift616.xcodeproj/project.xcworkspace/xcuserdata/sunset.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Swift616.xcodeproj/xcuserdata/sunset.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 24 | 36 | 37 | 38 | 40 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Swift616.xcodeproj/xcuserdata/sunset.xcuserdatad/xcschemes/Swift616.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /Swift616.xcodeproj/xcuserdata/sunset.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Swift616.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | CB32D589194E896000AE9045 16 | 17 | primary 18 | 19 | 20 | CB32D59D194E896300AE9045 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Swift616/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DayCell.swift 3 | // Swift616 4 | // 5 | // Created by SunSet on 14-6-16. 6 | // Copyright (c) 2014 zhaokaiyuan. 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: NSDictionary?) -> Bool { 18 | self.window = UIWindow(frame: UIScreen.mainScreen().bounds) 19 | var viewController = CalendarViewController()//DetailViewController() 20 | var nav:UINavigationController = UINavigationController(rootViewController: viewController); 21 | self.window!.rootViewController = nav 22 | self.window!.makeKeyAndVisible() 23 | 24 | return true 25 | } 26 | 27 | func applicationWillResignActive(application: UIApplication) { 28 | // 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. 29 | // 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. 30 | } 31 | 32 | func applicationDidEnterBackground(application: UIApplication) { 33 | // 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. 34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | } 36 | 37 | func applicationWillEnterForeground(application: UIApplication) { 38 | // 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. 39 | } 40 | 41 | func applicationDidBecomeActive(application: UIApplication) { 42 | // 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. 43 | } 44 | 45 | func applicationWillTerminate(application: UIApplication) { 46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 47 | } 48 | 49 | 50 | } 51 | 52 | -------------------------------------------------------------------------------- /Swift616/Calendar/CalendarCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DayCell.swift 3 | // Swift616 4 | // 5 | // Created by SunSet on 14-6-16. 6 | // Copyright (c) 2014 zhaokaiyuan. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | 13 | class CalendarCell: UIView ,DayCellDelegate{ 14 | 15 | 16 | var headView:UIView? 17 | var year:Int? 18 | var month:Int? 19 | var masterLabel:UILabel? 20 | 21 | var weekLabelArray:NSMutableArray? 22 | var dayLabelArray:NSMutableArray? 23 | 24 | init(frame: CGRect, year: Int ,month:Int) { 25 | super.init(frame: frame) 26 | weekLabelArray = NSMutableArray(); 27 | dayLabelArray = NSMutableArray(); 28 | self.year = year; 29 | self.month = month; 30 | self.setup(); 31 | } 32 | 33 | func updateMonthView(){ 34 | masterLabel!.text = String(self.month!) 35 | var xOffset:CGFloat = self.frame.size.width/7.0; 36 | var yOffset:CGFloat = 44.0; 37 | var monthDay:Int = Datecalculate.getDayCountOf(self.month!, year: self.year!) 38 | var startNumber:Int = Datecalculate.getStart(self.month!, year: self.year!) 39 | for (var i:Int = 0; i=monthDay) { 50 | cell.hidden = true; 51 | }else{ 52 | cell.hidden = false; 53 | } 54 | } 55 | } 56 | 57 | func createMonthView( ){ 58 | var xOffset:CGFloat = self.frame.size.width/7.0; 59 | var yOffset:CGFloat = 44.0; 60 | var startNumber:Int = Datecalculate.getStart(self.month!, year: self.year!) 61 | for (var i:Int = 0; i<32; i++) { 62 | var numberX:Int = (i+startNumber)%7; 63 | var numberY:Int = (i+startNumber)/7; 64 | var cell:DayCell = DayCell(frame: CGRectMake(CGFloat(numberX)*xOffset, 70 + CGFloat(numberY) * yOffset, xOffset, yOffset)) 65 | self.addSubview(cell); 66 | dayLabelArray!.addObject(cell) 67 | cell.setDay(i+1) 68 | } 69 | 70 | } 71 | var TapDayCell:( (year:Int,month:Int,day:Int )->Void)? 72 | 73 | func changeItem(year:Int,month:Int,day:Int){ 74 | TapDayCell!(year: year,month: month,day: day) 75 | } 76 | 77 | func setup(){ 78 | headView = UIView(frame: CGRectMake(0, 0, 320, 70)) 79 | self.addSubview(headView); 80 | headView!.backgroundColor = UIColor.whiteColor() 81 | 82 | var view:UIView = UIView(frame: CGRectMake(0, headView!.frame.size.height-0.3, headView!.frame.size.width, 0.3)) 83 | self.addSubview(view) 84 | 85 | view.backgroundColor = UIColor.colorWithHexString("c1c1c1") 86 | 87 | 88 | 89 | masterLabel = UILabel(frame: CGRectMake(4, 10, 30, 30)) 90 | masterLabel!.backgroundColor = UIColor.clearColor() 91 | masterLabel!.textAlignment = NSTextAlignment.Right 92 | masterLabel!.font = UIFont(name: "HelveticaNeue", size: 26.0) 93 | masterLabel!.text = String(self.month!) 94 | headView!.addSubview(masterLabel) 95 | 96 | var masterLabelUnit:UILabel = UILabel(frame: CGRectMake(masterLabel!.frame.origin.x+masterLabel!.frame.size.width, 16.0, 34, 24)) 97 | masterLabelUnit.backgroundColor = UIColor.clearColor() 98 | masterLabelUnit.textAlignment = NSTextAlignment.Left 99 | masterLabelUnit.font = UIFont(name: "HelveticaNeue", size: 20.0) 100 | masterLabelUnit.text = "月" 101 | masterLabelUnit.textColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.6) 102 | headView!.addSubview(masterLabelUnit) 103 | 104 | var xOffset:CGFloat = self.frame.size.width/7.0; 105 | var yOffset:CGFloat = 44.0 106 | 107 | for (var i:Int = 0 ; i<7; i++) { 108 | var dayOfTheWeekLabel:UILabel = UILabel(frame: CGRectMake(xOffset*CGFloat(i), yOffset, xOffset, 20)) 109 | dayOfTheWeekLabel.textColor = UIColor.blackColor() 110 | dayOfTheWeekLabel.textAlignment = NSTextAlignment.Center 111 | dayOfTheWeekLabel.backgroundColor = UIColor.clearColor() 112 | dayOfTheWeekLabel.font = UIFont(name: "HelveticaNeue-Light", size: 18.0) 113 | headView!.addSubview(dayOfTheWeekLabel) 114 | weekLabelArray!.addObject(dayOfTheWeekLabel) 115 | 116 | } 117 | self.updateWithDayNames(["日","一","二","三","四","五","六"]) 118 | self.createMonthView() 119 | } 120 | 121 | 122 | func updateWithDayNames(dayNames:NSArray){ 123 | for (var i:Int = 0 ; i < dayNames.count; i++) { 124 | var label:UILabel = weekLabelArray!.objectAtIndex(i) as UILabel 125 | label.text = dayNames[i] as String 126 | if (i==0) { 127 | label.textColor = UIColor.orangeColor() 128 | 129 | } 130 | if (i == dayNames.count-1) { 131 | label.textColor = UIColor.orangeColor() 132 | } 133 | 134 | } 135 | } 136 | 137 | 138 | } 139 | 140 | 141 | -------------------------------------------------------------------------------- /Swift616/Calendar/CalendarViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CalendarViewController.swift 3 | // Swift616 4 | // 5 | // Created by SunSet on 14-6-17. 6 | // Copyright (c) 2014 SunSet. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CalendarViewController : UIViewController, UITableViewDelegate, UITableViewDataSource 12 | { 13 | 14 | var table:UITableView? 15 | var dataArray:NSMutableArray? 16 | var fromDate:DateObject? 17 | var toDate:DateObject? 18 | 19 | override func viewDidLoad() { 20 | super.viewDidLoad() 21 | 22 | 23 | self.view.backgroundColor = UIColor.whiteColor(); 24 | dataArray = NSMutableArray() 25 | var fromYear:Int = 2014; 26 | var toYear:Int = 2016; 27 | var fromMonth:Int = 1; 28 | var toMonth:Int = 1; 29 | var number:Int = ( toYear - fromYear ) * 12 + toMonth - fromMonth + 1 30 | 31 | for (var i:Int = 0 ; i Int 80 | { 81 | return 1 82 | } 83 | 84 | func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int 85 | { 86 | return self.dataArray!.count 87 | } 88 | 89 | 90 | func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 91 | 92 | 93 | var cell: UITableViewCell? = tableView.dequeueReusableCellWithIdentifier("Cell") as? UITableViewCell 94 | 95 | if cell == nil { // no value 96 | cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell") as UITableViewCell 97 | cell!.selectionStyle = UITableViewCellSelectionStyle.None 98 | var calendarCell:CalendarCell = CalendarCell(frame: CGRectMake(0, 0, 310, 400), year: 2014, month: 1) 99 | cell!.contentView.addSubview(calendarCell) 100 | calendarCell.tag = 1000001 101 | } 102 | 103 | 104 | var cellView:CalendarCell = cell!.contentView.viewWithTag(1000001) as CalendarCell 105 | var row:Int = indexPath.row 106 | var object:DateObject = self.dataArray!.objectAtIndex(row) as DateObject 107 | cellView.year = object.year 108 | cellView.month = object.month 109 | cellView.TapDayCell = {(year:Int,month:Int,day:Int ) in 110 | println(year); 111 | println(month); 112 | println(day); 113 | } 114 | cellView.updateMonthView() 115 | return cell! 116 | } 117 | 118 | func tableView(tableView: UITableView!, heightForRowAtIndexPath indexPath: NSIndexPath!) -> CGFloat{ 119 | var object = self.dataArray!.objectAtIndex(indexPath.row) as DateObject 120 | var layer = Datecalculate.getLayer(object.year!, month: object.month!) 121 | var y = 70 + 44 * layer 122 | return CGFloat(y) 123 | } 124 | 125 | } 126 | 127 | -------------------------------------------------------------------------------- /Swift616/Calendar/Color.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Color.swift 3 | // Swift616 4 | // 5 | // Created by SunSet on 14-6-17. 6 | // Copyright (c) 2014年 SunSet. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | extension UIColor { 13 | class func colorWithHexString(stringToConvert:String)->UIColor{ 14 | NSCharacterSet.whitespaceAndNewlineCharacterSet() 15 | var cString:NSString = stringToConvert.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()).uppercaseString 16 | 17 | if (cString.length < 6){ 18 | return UIColor.clearColor(); 19 | } 20 | if cString.hasPrefix("0X"){ 21 | cString = cString.substringFromIndex(2) 22 | } 23 | if cString.hasPrefix("#"){ 24 | cString = cString.substringFromIndex(1) 25 | } 26 | if (cString.length != 6){ 27 | return UIColor.clearColor(); 28 | } 29 | var range:NSRange = NSMakeRange(0, 2); 30 | var rString:String = cString.substringWithRange(range) 31 | range.location = 2; 32 | 33 | var gString:String = cString.substringWithRange(range) 34 | range.location = 4; 35 | var bString:String = cString.substringWithRange(range) 36 | var r:CUnsignedInt=0 37 | var g:CUnsignedInt=0 38 | var b:CUnsignedInt=0 39 | NSScanner.scannerWithString(rString).scanHexInt(&r) 40 | NSScanner.scannerWithString(gString).scanHexInt(&g) 41 | NSScanner.scannerWithString(bString).scanHexInt(&b) 42 | 43 | 44 | 45 | return UIColor(red: CGFloat(r)/255.0, green: CGFloat(g)/255.0, blue: CGFloat(b)/255.0, alpha: 1.0) 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /Swift616/Calendar/Datecalculate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DayCell.swift 3 | // Swift616 4 | // 5 | // Created by SunSet on 14-6-16. 6 | // Copyright (c) 2014 zhaokaiyuan. All rights reserved. 7 | // 8 | import Foundation 9 | 10 | class Datecalculate: NSObject{ 11 | class func getDayCountOf(month:Int , year:Int)->Int{ 12 | switch (month) { 13 | case 1: 14 | return 31 15 | case 3: 16 | return 31 17 | case 4: 18 | return 30 19 | case 5: 20 | return 31 21 | case 6: 22 | return 30 23 | case 7: 24 | return 31 25 | case 8: 26 | return 31 27 | case 9: 28 | return 30 29 | case 10: 30 | return 31 31 | case 11: 32 | return 30 33 | case 12: 34 | return 31 35 | default: 36 | break 37 | } 38 | if(year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) 39 | { 40 | return 29 41 | } 42 | else { 43 | return 28 44 | } 45 | } 46 | 47 | 48 | class func getStart(month:Int , year:Int)->Int{ 49 | var baseNumber:Int 50 | var startNumber:Int 51 | 52 | if(year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) 53 | { 54 | switch (month) { 55 | case 1: 56 | baseNumber = 0 57 | 58 | case 2: 59 | baseNumber = 3 60 | 61 | case 3: 62 | baseNumber = 4 63 | 64 | case 4: 65 | baseNumber = 0 66 | 67 | case 5: 68 | baseNumber = 2 69 | 70 | case 6: 71 | baseNumber = 5 72 | 73 | case 7: 74 | baseNumber = 0 75 | 76 | case 8: 77 | baseNumber = 3 78 | 79 | case 9: 80 | baseNumber = 6 81 | 82 | case 10: 83 | baseNumber = 1 84 | 85 | case 11: 86 | baseNumber = 4 87 | 88 | case 12: 89 | baseNumber = 6 90 | 91 | default: 92 | baseNumber = 0 93 | } 94 | startNumber = (year + year/4 + year/400 - year/100 - 2 + baseNumber + 1) % 7 95 | } 96 | 97 | else 98 | { 99 | switch (month) { 100 | case 1: 101 | baseNumber = 0 102 | case 2: 103 | baseNumber = 3 104 | case 3: 105 | baseNumber = 3 106 | case 4: 107 | baseNumber = 6 108 | case 5: 109 | baseNumber = 1 110 | case 6: 111 | baseNumber = 4 112 | case 7: 113 | baseNumber = 6 114 | case 8: 115 | baseNumber = 2 116 | case 9: 117 | baseNumber = 5 118 | case 10: 119 | baseNumber = 0 120 | case 11: 121 | baseNumber = 3; 122 | break; 123 | case 12: 124 | baseNumber = 5 125 | default: 126 | baseNumber = 0 127 | } 128 | startNumber = (year + year/4 + year/400 - year/100 - 1 + baseNumber + 1) % 7 129 | } 130 | return startNumber 131 | } 132 | 133 | class func getLayer(year:Int , month:Int)->Int{ 134 | var monthDay = self.getDayCountOf(month, year: year) 135 | var startNumber = self.getStart(month, year: year) 136 | var newLayer = startNumber+monthDay 137 | var layer = ceilf(Float(startNumber+monthDay)/7) 138 | return Int(layer); 139 | } 140 | } -------------------------------------------------------------------------------- /Swift616/Calendar/DayCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DayCell.swift 3 | // Swift616 4 | // 5 | // Created by SunSet on 14-6-16. 6 | // Copyright (c) 2014 zhaokaiyuan. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | @objc protocol DayCellDelegate : NSObjectProtocol { 13 | @optional func changeItem(year:Int,month:Int,day:Int) 14 | } 15 | 16 | 17 | 18 | class DayCell: UIView { 19 | var button:UIButton? 20 | var dayLabel:UILabel? 21 | var explainLabel:UILabel? 22 | var day:Int? 23 | var month:Int? 24 | var year:Int? 25 | var delegate:DayCellDelegate? 26 | 27 | init(frame: CGRect) { 28 | super.init(frame: frame) 29 | // Initialization code 30 | 31 | 32 | button = UIButton.buttonWithType(UIButtonType.Custom)as? UIButton 33 | button!.frame = CGRectMake(0, 0, frame.size.width, frame.size.height) 34 | button!.backgroundColor = UIColor.clearColor() 35 | button!.addTarget(self, action: "buttonAction:", forControlEvents: UIControlEvents.TouchUpInside) 36 | addSubview(self.button) 37 | 38 | dayLabel = UILabel(frame: self.bounds) 39 | dayLabel!.textAlignment = NSTextAlignment.Center 40 | dayLabel!.font = UIFont(name: "HelveticaNeue-Light" , size: 18.0); 41 | dayLabel!.backgroundColor = UIColor.clearColor() 42 | addSubview(dayLabel) 43 | 44 | explainLabel = UILabel(frame: CGRectMake(0, self.frame.size.height/2, self.frame.size.width, 20)) 45 | explainLabel!.textAlignment = NSTextAlignment.Center 46 | explainLabel!.font = UIFont.boldSystemFontOfSize(14.0) 47 | explainLabel!.backgroundColor = UIColor.clearColor() 48 | explainLabel!.tag = 100 49 | explainLabel!.text = "今天" 50 | 51 | 52 | addSubview(explainLabel) 53 | explainLabel!.hidden = true 54 | 55 | var view:UIView = UIView(frame: CGRectMake(0, self.frame.size.height-0.3, self.frame.size.width, 0.3)); 56 | view.backgroundColor = UIColor.colorWithHexString("c1c1c1") 57 | addSubview(view) 58 | } 59 | 60 | 61 | func buttonAction(sender: UIButton) 62 | { 63 | delegate?.changeItem?(year!, month: month!, day: day!) 64 | } 65 | 66 | func isToday()->Bool 67 | { 68 | 69 | var today = NSCalendar.currentCalendar().components(NSCalendarUnit.EraCalendarUnit|NSCalendarUnit.YearCalendarUnit|NSCalendarUnit.MonthCalendarUnit|NSCalendarUnit.DayCalendarUnit, fromDate: NSDate()) as NSDateComponents 70 | if today.day == self.day && today.month == self.month && today.year == self.year{ 71 | return true; 72 | }else{ 73 | return false; 74 | } 75 | } 76 | 77 | 78 | func isFuture()->Bool{ 79 | var today = NSCalendar.currentCalendar().components(NSCalendarUnit.EraCalendarUnit|NSCalendarUnit.YearCalendarUnit|NSCalendarUnit.MonthCalendarUnit|NSCalendarUnit.DayCalendarUnit, fromDate: NSDate()) as NSDateComponents 80 | 81 | if self.year > today.year { 82 | return true 83 | }else if (self.year == today.year && self.month>today.month){ 84 | return true; 85 | }else if (self.year == today.year && self.month==today.month && self.day > today.day){ 86 | return true; 87 | } 88 | return false; 89 | } 90 | 91 | 92 | 93 | func setDay(newDay:Int){ 94 | self.day = newDay; 95 | dayLabel!.text = String(newDay) 96 | if self.isToday(){ 97 | dayLabel!.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height/2) 98 | explainLabel!.hidden = false 99 | explainLabel!.textColor = UIColor.orangeColor() 100 | dayLabel!.textColor = UIColor.orangeColor() 101 | self.userInteractionEnabled = true 102 | }else{ 103 | dayLabel!.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height) 104 | explainLabel!.hidden = true 105 | if self.isFuture(){ 106 | dayLabel!.textColor = UIColor.blackColor() 107 | self.userInteractionEnabled = false 108 | }else{ 109 | dayLabel!.textColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.6) 110 | self.userInteractionEnabled = true; 111 | button!.setImage(nil, forState: UIControlState.Normal) 112 | button!.setImage(nil, forState: UIControlState.Selected) 113 | dayLabel!.textColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.6) 114 | 115 | 116 | } 117 | } 118 | } 119 | 120 | } 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /Swift616/DateObject.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DayCell.swift 3 | // Swift616 4 | // 5 | // Created by SunSet on 14-6-16. 6 | // Copyright (c) 2014 zhaokaiyuan. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | class DateObject: NSObject{ 11 | var day : Int? 12 | var month : Int? 13 | var year : Int? 14 | 15 | } -------------------------------------------------------------------------------- /Swift616/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Swift616/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Swift616/Images.xcassets/first.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "first.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x", 11 | "filename" : "first@2x.png" 12 | } 13 | ], 14 | "info" : { 15 | "version" : 1, 16 | "author" : "xcode" 17 | } 18 | } -------------------------------------------------------------------------------- /Swift616/Images.xcassets/first.imageset/first.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaokaiyuan99/swift--/dd720eebae6d9c2cc8b138b8f94ec45474c099af/Swift616/Images.xcassets/first.imageset/first.png -------------------------------------------------------------------------------- /Swift616/Images.xcassets/first.imageset/first@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaokaiyuan99/swift--/dd720eebae6d9c2cc8b138b8f94ec45474c099af/Swift616/Images.xcassets/first.imageset/first@2x.png -------------------------------------------------------------------------------- /Swift616/Images.xcassets/second.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "second.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x", 11 | "filename" : "second@2x.png" 12 | } 13 | ], 14 | "info" : { 15 | "version" : 1, 16 | "author" : "xcode" 17 | } 18 | } -------------------------------------------------------------------------------- /Swift616/Images.xcassets/second.imageset/second.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaokaiyuan99/swift--/dd720eebae6d9c2cc8b138b8f94ec45474c099af/Swift616/Images.xcassets/second.imageset/second.png -------------------------------------------------------------------------------- /Swift616/Images.xcassets/second.imageset/second@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhaokaiyuan99/swift--/dd720eebae6d9c2cc8b138b8f94ec45474c099af/Swift616/Images.xcassets/second.imageset/second@2x.png -------------------------------------------------------------------------------- /Swift616/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | yuan.${PRODUCT_NAME:rfc1034identifier} 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 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UIStatusBarTintParameters 30 | 31 | UINavigationBar 32 | 33 | Style 34 | UIBarStyleDefault 35 | Translucent 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Swift616Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | yuan.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Swift616Tests/Swift616Tests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Swift616Tests.swift 3 | // Swift616Tests 4 | // 5 | // Created by SunSet on 14-6-16. 6 | // Copyright (c) 2014年 SunSet. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class Swift616Tests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | super.tearDown() 21 | } 22 | 23 | func testExample() { 24 | // This is an example of a functional test case. 25 | XCTAssert(true, "Pass") 26 | } 27 | 28 | func testPerformanceExample() { 29 | // This is an example of a performance test case. 30 | self.measureBlock() { 31 | // Put the code you want to measure the time of here. 32 | } 33 | } 34 | 35 | } 36 | --------------------------------------------------------------------------------