Repository: ProducterTips/producter-book-examples
Branch: master
Commit: 50b67c07ab3c
Files: 692
Total size: 282.5 MB
Directory structure:
gitextract_g_1wn6sw/
├── .gitignore
└── Example Codes/
├── Animation Advanced/
│ ├── Animation Advanced/
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets/
│ │ │ ├── AppIcon.appiconset/
│ │ │ │ └── Contents.json
│ │ │ ├── Contents.json
│ │ │ └── leaf.imageset/
│ │ │ └── Contents.json
│ │ ├── Base.lproj/
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ ├── DetailViewController.swift
│ │ ├── Info.plist
│ │ ├── MasterViewController.swift
│ │ ├── bezierAdvanced.swift
│ │ ├── bezierSimple.swift
│ │ ├── bezierUIDynamic.swift
│ │ ├── keyframe.swift
│ │ └── maskAnimation.swift
│ └── Animation Advanced.xcodeproj/
│ ├── project.pbxproj
│ ├── project.xcworkspace/
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata/
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata/
│ │ ├── kevinzhow.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── zhowkevin.xcuserdatad/
│ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata/
│ ├── kevinzhow.xcuserdatad/
│ │ └── xcschemes/
│ │ ├── Animation Advanced.xcscheme
│ │ └── xcschememanagement.plist
│ ├── zhoukaiwen.xcuserdatad/
│ │ └── xcschemes/
│ │ └── xcschememanagement.plist
│ └── zhowkevin.xcuserdatad/
│ ├── xcdebugger/
│ │ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes/
│ ├── Animation Advanced.xcscheme
│ └── xcschememanagement.plist
├── AutoLayout/
│ ├── TextView/
│ │ ├── Meow/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.xib
│ │ │ │ └── Main.storyboard
│ │ │ ├── Images.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── cat_cart.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── cat_eyes.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── cat_fat.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── Info.plist
│ │ │ └── ViewController.swift
│ │ ├── Meow.xcodeproj/
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace/
│ │ │ │ ├── contents.xcworkspacedata
│ │ │ │ ├── xcshareddata/
│ │ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ │ └── xcuserdata/
│ │ │ │ ├── kevin.xcuserdatad/
│ │ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ │ └── zhowkevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── xcschemes/
│ │ │ │ ├── Meow.xcscheme
│ │ │ │ └── xcschememanagement.plist
│ │ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ │ └── xcschemes/
│ │ │ │ └── xcschememanagement.plist
│ │ │ └── zhowkevin.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ ├── Meow.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ └── MeowTests/
│ │ ├── Info.plist
│ │ └── MeowTests.swift
│ ├── meow_0/
│ │ ├── Meow/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.xib
│ │ │ │ └── Main.storyboard
│ │ │ ├── Images.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── cat_cart.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── cat_eyes.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── cat_fat.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── Info.plist
│ │ │ └── ViewController.swift
│ │ ├── Meow.xcodeproj/
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace/
│ │ │ │ ├── contents.xcworkspacedata
│ │ │ │ ├── xcshareddata/
│ │ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ │ └── xcuserdata/
│ │ │ │ ├── kevin.xcuserdatad/
│ │ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ │ └── zhowkevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── xcschemes/
│ │ │ │ ├── Meow.xcscheme
│ │ │ │ └── xcschememanagement.plist
│ │ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ │ └── xcschemes/
│ │ │ │ └── xcschememanagement.plist
│ │ │ └── zhowkevin.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ ├── Meow.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ └── MeowTests/
│ │ ├── Info.plist
│ │ └── MeowTests.swift
│ ├── meow_1/
│ │ ├── Meow/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.xib
│ │ │ │ └── Main.storyboard
│ │ │ ├── Images.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── cat_cart.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── cat_eyes.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── cat_fat.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── Info.plist
│ │ │ └── ViewController.swift
│ │ ├── Meow.xcodeproj/
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace/
│ │ │ │ ├── contents.xcworkspacedata
│ │ │ │ ├── xcshareddata/
│ │ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ │ └── xcuserdata/
│ │ │ │ ├── kevin.xcuserdatad/
│ │ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ │ └── zhowkevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── xcschemes/
│ │ │ │ ├── Meow.xcscheme
│ │ │ │ └── xcschememanagement.plist
│ │ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ │ └── xcschemes/
│ │ │ │ └── xcschememanagement.plist
│ │ │ └── zhowkevin.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ ├── Meow.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ └── MeowTests/
│ │ ├── Info.plist
│ │ └── MeowTests.swift
│ └── meow_2/
│ ├── Meow/
│ │ ├── AppDelegate.swift
│ │ ├── Base.lproj/
│ │ │ ├── LaunchScreen.xib
│ │ │ └── Main.storyboard
│ │ ├── Images.xcassets/
│ │ │ ├── AppIcon.appiconset/
│ │ │ │ └── Contents.json
│ │ │ ├── cat_cart.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── cat_eyes.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── cat_fat.imageset/
│ │ │ └── Contents.json
│ │ ├── Info.plist
│ │ └── ViewController.swift
│ ├── Meow.xcodeproj/
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── zhowkevin.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ ├── Meow.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ └── xcschememanagement.plist
│ │ └── zhowkevin.xcuserdatad/
│ │ └── xcschemes/
│ │ ├── Meow.xcscheme
│ │ └── xcschememanagement.plist
│ └── MeowTests/
│ ├── Info.plist
│ └── MeowTests.swift
├── Diary/
│ ├── Diary_0/
│ │ ├── Diary/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets/
│ │ │ │ └── AppIcon.appiconset/
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── DiaryLabel.swift
│ │ │ ├── Info.plist
│ │ │ └── ViewController.swift
│ │ └── Diary.xcodeproj/
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata/
│ │ └── kevin.xcuserdatad/
│ │ └── xcschemes/
│ │ ├── Diary.xcscheme
│ │ └── xcschememanagement.plist
│ ├── Diary_1/
│ │ ├── Diary/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets/
│ │ │ │ └── AppIcon.appiconset/
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── DiaryLabel.swift
│ │ │ ├── Info.plist
│ │ │ ├── TpldKhangXiDictTrial.otf
│ │ │ ├── ViewController.swift
│ │ │ └── Wyue-GutiFangsong-NC_deliverable.otf
│ │ └── Diary.xcodeproj/
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ ├── Diary.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ └── zhoukaiwen.xcuserdatad/
│ │ └── xcschemes/
│ │ └── xcschememanagement.plist
│ ├── Diary_10/
│ │ ├── Diary/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Contents.json
│ │ │ │ ├── Oval.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Oval_pressed.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── Diary.xcdatamodeld/
│ │ │ │ └── Diary.xcdatamodel/
│ │ │ │ └── contents
│ │ │ ├── DiaryAnimator.swift
│ │ │ ├── DiaryCell.swift
│ │ │ ├── DiaryComposeViewController.swift
│ │ │ ├── DiaryLabel.swift
│ │ │ ├── DiaryLayout.swift
│ │ │ ├── DiaryLocationHelper.swift
│ │ │ ├── DiaryMonthCollectionViewController.swift
│ │ │ ├── DiaryTemplate.html
│ │ │ ├── DiaryViewController.swift
│ │ │ ├── DiaryYearCollectionViewController.swift
│ │ │ ├── Helper.swift
│ │ │ ├── HomeCollectionViewController.swift
│ │ │ ├── HomeYearCollectionViewCell.swift
│ │ │ ├── Info.plist
│ │ │ ├── TpldKhangXiDictTrial.otf
│ │ │ ├── ViewController.swift
│ │ │ └── Wyue-GutiFangsong-NC_deliverable.otf
│ │ └── Diary.xcodeproj/
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ ├── kevinzhow.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ ├── xcdebugger/
│ │ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes/
│ │ │ ├── Diary.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ ├── kevinzhow.xcuserdatad/
│ │ │ ├── xcdebugger/
│ │ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes/
│ │ │ ├── Diary.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ └── zhoukaiwen.xcuserdatad/
│ │ └── xcschemes/
│ │ └── xcschememanagement.plist
│ ├── Diary_11/
│ │ ├── Diary/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Contents.json
│ │ │ │ ├── Oval.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Oval_pressed.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── Diary.xcdatamodeld/
│ │ │ │ └── Diary.xcdatamodel/
│ │ │ │ └── contents
│ │ │ ├── DiaryAnimator.swift
│ │ │ ├── DiaryCell.swift
│ │ │ ├── DiaryComposeViewController.swift
│ │ │ ├── DiaryLabel.swift
│ │ │ ├── DiaryLayout.swift
│ │ │ ├── DiaryLocationHelper.swift
│ │ │ ├── DiaryMonthCollectionViewController.swift
│ │ │ ├── DiaryTemplate.html
│ │ │ ├── DiaryViewController.swift
│ │ │ ├── DiaryYearCollectionViewController.swift
│ │ │ ├── Helper.swift
│ │ │ ├── HomeCollectionViewController.swift
│ │ │ ├── HomeYearCollectionViewCell.swift
│ │ │ ├── Info.plist
│ │ │ ├── TpldKhangXiDictTrial.otf
│ │ │ ├── ViewController.swift
│ │ │ └── Wyue-GutiFangsong-NC_deliverable.otf
│ │ └── Diary.xcodeproj/
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ ├── kevinzhow.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ ├── xcdebugger/
│ │ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes/
│ │ │ ├── Diary.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ ├── kevinzhow.xcuserdatad/
│ │ │ ├── xcdebugger/
│ │ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes/
│ │ │ ├── Diary.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ └── zhoukaiwen.xcuserdatad/
│ │ └── xcschemes/
│ │ └── xcschememanagement.plist
│ ├── Diary_12/
│ │ ├── Diary/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Contents.json
│ │ │ │ ├── Oval.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Oval_pressed.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── Diary.xcdatamodeld/
│ │ │ │ └── Diary.xcdatamodel/
│ │ │ │ └── contents
│ │ │ ├── DiaryAnimator.swift
│ │ │ ├── DiaryCell.swift
│ │ │ ├── DiaryComposeViewController.swift
│ │ │ ├── DiaryLabel.swift
│ │ │ ├── DiaryLayout.swift
│ │ │ ├── DiaryLocationHelper.swift
│ │ │ ├── DiaryMonthCollectionViewController.swift
│ │ │ ├── DiaryTemplate.html
│ │ │ ├── DiaryViewController.swift
│ │ │ ├── DiaryYearCollectionViewController.swift
│ │ │ ├── Helper.swift
│ │ │ ├── HomeCollectionViewController.swift
│ │ │ ├── HomeYearCollectionViewCell.swift
│ │ │ ├── Info.plist
│ │ │ ├── TpldKhangXiDictTrial.otf
│ │ │ ├── ViewController.swift
│ │ │ └── Wyue-GutiFangsong-NC_deliverable.otf
│ │ └── Diary.xcodeproj/
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ ├── kevinzhow.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ ├── xcdebugger/
│ │ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes/
│ │ │ ├── Diary.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ ├── kevinzhow.xcuserdatad/
│ │ │ ├── xcdebugger/
│ │ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes/
│ │ │ ├── Diary.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ └── zhoukaiwen.xcuserdatad/
│ │ ├── xcdebugger/
│ │ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes/
│ │ └── xcschememanagement.plist
│ ├── Diary_13/
│ │ ├── Diary/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Contents.json
│ │ │ │ ├── Oval.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Oval_pressed.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── Diary.xcdatamodeld/
│ │ │ │ └── Diary.xcdatamodel/
│ │ │ │ └── contents
│ │ │ ├── DiaryAnimator.swift
│ │ │ ├── DiaryCell.swift
│ │ │ ├── DiaryComposeViewController.swift
│ │ │ ├── DiaryLabel.swift
│ │ │ ├── DiaryLayout.swift
│ │ │ ├── DiaryLocationHelper.swift
│ │ │ ├── DiaryMonthCollectionViewController.swift
│ │ │ ├── DiaryTemplate.html
│ │ │ ├── DiaryViewController.swift
│ │ │ ├── DiaryYearCollectionViewController.swift
│ │ │ ├── Helper.swift
│ │ │ ├── HomeCollectionViewController.swift
│ │ │ ├── HomeYearCollectionViewCell.swift
│ │ │ ├── Info.plist
│ │ │ ├── TpldKhangXiDictTrial.otf
│ │ │ ├── ViewController.swift
│ │ │ └── Wyue-GutiFangsong-NC_deliverable.otf
│ │ ├── Diary.xcodeproj/
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace/
│ │ │ │ ├── contents.xcworkspacedata
│ │ │ │ ├── xcshareddata/
│ │ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ │ └── xcuserdata/
│ │ │ │ ├── kevin.xcuserdatad/
│ │ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ │ ├── kevinzhow.xcuserdatad/
│ │ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ │ └── zhoukaiwen.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ ├── xcdebugger/
│ │ │ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ │ └── xcschemes/
│ │ │ │ ├── Diary.xcscheme
│ │ │ │ └── xcschememanagement.plist
│ │ │ ├── kevinzhow.xcuserdatad/
│ │ │ │ ├── xcdebugger/
│ │ │ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ │ └── xcschemes/
│ │ │ │ ├── Diary.xcscheme
│ │ │ │ └── xcschememanagement.plist
│ │ │ └── zhoukaiwen.xcuserdatad/
│ │ │ ├── xcdebugger/
│ │ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes/
│ │ │ └── xcschememanagement.plist
│ │ ├── Diary.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ └── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── Podfile
│ ├── Diary_2/
│ │ ├── Diary/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets/
│ │ │ │ └── AppIcon.appiconset/
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── DiaryLabel.swift
│ │ │ ├── DiaryLayout.swift
│ │ │ ├── HomeCollectionViewController.swift
│ │ │ ├── HomeYearCollectionViewCell.swift
│ │ │ ├── Info.plist
│ │ │ ├── TpldKhangXiDictTrial.otf
│ │ │ ├── ViewController.swift
│ │ │ └── Wyue-GutiFangsong-NC_deliverable.otf
│ │ └── Diary.xcodeproj/
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ ├── Diary.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ └── zhoukaiwen.xcuserdatad/
│ │ └── xcschemes/
│ │ └── xcschememanagement.plist
│ ├── Diary_3/
│ │ ├── Diary/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets/
│ │ │ │ └── AppIcon.appiconset/
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── DiaryCell.swift
│ │ │ ├── DiaryLabel.swift
│ │ │ ├── DiaryLayout.swift
│ │ │ ├── DiaryYearCollectionViewController.swift
│ │ │ ├── HomeCollectionViewController.swift
│ │ │ ├── HomeYearCollectionViewCell.swift
│ │ │ ├── Info.plist
│ │ │ ├── TpldKhangXiDictTrial.otf
│ │ │ ├── ViewController.swift
│ │ │ └── Wyue-GutiFangsong-NC_deliverable.otf
│ │ └── Diary.xcodeproj/
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ ├── Diary.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ └── zhoukaiwen.xcuserdatad/
│ │ └── xcschemes/
│ │ └── xcschememanagement.plist
│ ├── Diary_4/
│ │ ├── Diary/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Contents.json
│ │ │ │ ├── Oval.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Oval_pressed.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── DiaryCell.swift
│ │ │ ├── DiaryLabel.swift
│ │ │ ├── DiaryLayout.swift
│ │ │ ├── DiaryMonthCollectionViewController.swift
│ │ │ ├── DiaryYearCollectionViewController.swift
│ │ │ ├── Helper.swift
│ │ │ ├── HomeCollectionViewController.swift
│ │ │ ├── HomeYearCollectionViewCell.swift
│ │ │ ├── Info.plist
│ │ │ ├── TpldKhangXiDictTrial.otf
│ │ │ ├── ViewController.swift
│ │ │ └── Wyue-GutiFangsong-NC_deliverable.otf
│ │ └── Diary.xcodeproj/
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ ├── Diary.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ └── zhoukaiwen.xcuserdatad/
│ │ └── xcschemes/
│ │ └── xcschememanagement.plist
│ ├── Diary_5/
│ │ ├── Diary/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Contents.json
│ │ │ │ ├── Oval.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Oval_pressed.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── DiaryAnimator.swift
│ │ │ ├── DiaryCell.swift
│ │ │ ├── DiaryLabel.swift
│ │ │ ├── DiaryLayout.swift
│ │ │ ├── DiaryMonthCollectionViewController.swift
│ │ │ ├── DiaryYearCollectionViewController.swift
│ │ │ ├── Helper.swift
│ │ │ ├── HomeCollectionViewController.swift
│ │ │ ├── HomeYearCollectionViewCell.swift
│ │ │ ├── Info.plist
│ │ │ ├── TpldKhangXiDictTrial.otf
│ │ │ ├── ViewController.swift
│ │ │ └── Wyue-GutiFangsong-NC_deliverable.otf
│ │ └── Diary.xcodeproj/
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ ├── Diary.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ └── zhoukaiwen.xcuserdatad/
│ │ └── xcschemes/
│ │ └── xcschememanagement.plist
│ ├── Diary_6/
│ │ ├── Diary/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Contents.json
│ │ │ │ ├── Oval.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Oval_pressed.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── DiaryAnimator.swift
│ │ │ ├── DiaryCell.swift
│ │ │ ├── DiaryComposeViewController.swift
│ │ │ ├── DiaryLabel.swift
│ │ │ ├── DiaryLayout.swift
│ │ │ ├── DiaryLocationHelper.swift
│ │ │ ├── DiaryMonthCollectionViewController.swift
│ │ │ ├── DiaryYearCollectionViewController.swift
│ │ │ ├── Helper.swift
│ │ │ ├── HomeCollectionViewController.swift
│ │ │ ├── HomeYearCollectionViewCell.swift
│ │ │ ├── Info.plist
│ │ │ ├── TpldKhangXiDictTrial.otf
│ │ │ ├── ViewController.swift
│ │ │ └── Wyue-GutiFangsong-NC_deliverable.otf
│ │ └── Diary.xcodeproj/
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ ├── Diary.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ └── zhoukaiwen.xcuserdatad/
│ │ └── xcschemes/
│ │ └── xcschememanagement.plist
│ ├── Diary_7/
│ │ ├── Diary/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Contents.json
│ │ │ │ ├── Oval.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Oval_pressed.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── Diary.xcdatamodeld/
│ │ │ │ └── Diary.xcdatamodel/
│ │ │ │ └── contents
│ │ │ ├── DiaryAnimator.swift
│ │ │ ├── DiaryCell.swift
│ │ │ ├── DiaryComposeViewController.swift
│ │ │ ├── DiaryLabel.swift
│ │ │ ├── DiaryLayout.swift
│ │ │ ├── DiaryLocationHelper.swift
│ │ │ ├── DiaryMonthCollectionViewController.swift
│ │ │ ├── DiaryYearCollectionViewController.swift
│ │ │ ├── Helper.swift
│ │ │ ├── HomeCollectionViewController.swift
│ │ │ ├── HomeYearCollectionViewCell.swift
│ │ │ ├── Info.plist
│ │ │ ├── TpldKhangXiDictTrial.otf
│ │ │ ├── ViewController.swift
│ │ │ └── Wyue-GutiFangsong-NC_deliverable.otf
│ │ └── Diary.xcodeproj/
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ ├── Diary.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ └── zhoukaiwen.xcuserdatad/
│ │ └── xcschemes/
│ │ └── xcschememanagement.plist
│ ├── Diary_8/
│ │ ├── Diary/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Contents.json
│ │ │ │ ├── Oval.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Oval_pressed.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── Diary.xcdatamodeld/
│ │ │ │ └── Diary.xcdatamodel/
│ │ │ │ └── contents
│ │ │ ├── DiaryAnimator.swift
│ │ │ ├── DiaryCell.swift
│ │ │ ├── DiaryComposeViewController.swift
│ │ │ ├── DiaryLabel.swift
│ │ │ ├── DiaryLayout.swift
│ │ │ ├── DiaryLocationHelper.swift
│ │ │ ├── DiaryMonthCollectionViewController.swift
│ │ │ ├── DiaryYearCollectionViewController.swift
│ │ │ ├── Helper.swift
│ │ │ ├── HomeCollectionViewController.swift
│ │ │ ├── HomeYearCollectionViewCell.swift
│ │ │ ├── Info.plist
│ │ │ ├── TpldKhangXiDictTrial.otf
│ │ │ ├── ViewController.swift
│ │ │ └── Wyue-GutiFangsong-NC_deliverable.otf
│ │ └── Diary.xcodeproj/
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ ├── kevinzhow.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ ├── xcdebugger/
│ │ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes/
│ │ │ ├── Diary.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ ├── kevinzhow.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ ├── Diary.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ └── zhoukaiwen.xcuserdatad/
│ │ └── xcschemes/
│ │ └── xcschememanagement.plist
│ ├── Diary_9/
│ │ ├── Diary/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Contents.json
│ │ │ │ ├── Oval.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Oval_pressed.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── Diary.xcdatamodeld/
│ │ │ │ └── Diary.xcdatamodel/
│ │ │ │ └── contents
│ │ │ ├── DiaryAnimator.swift
│ │ │ ├── DiaryCell.swift
│ │ │ ├── DiaryComposeViewController.swift
│ │ │ ├── DiaryLabel.swift
│ │ │ ├── DiaryLayout.swift
│ │ │ ├── DiaryLocationHelper.swift
│ │ │ ├── DiaryMonthCollectionViewController.swift
│ │ │ ├── DiaryTemplate.html
│ │ │ ├── DiaryViewController.swift
│ │ │ ├── DiaryYearCollectionViewController.swift
│ │ │ ├── Helper.swift
│ │ │ ├── HomeCollectionViewController.swift
│ │ │ ├── HomeYearCollectionViewCell.swift
│ │ │ ├── Info.plist
│ │ │ ├── TpldKhangXiDictTrial.otf
│ │ │ ├── ViewController.swift
│ │ │ └── Wyue-GutiFangsong-NC_deliverable.otf
│ │ └── Diary.xcodeproj/
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ ├── kevinzhow.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ ├── xcdebugger/
│ │ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes/
│ │ │ ├── Diary.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ ├── kevinzhow.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ ├── Diary.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ └── zhoukaiwen.xcuserdatad/
│ │ └── xcschemes/
│ │ └── xcschememanagement.plist
│ └── UILabel/
│ ├── Label.playground/
│ │ ├── Contents.swift
│ │ ├── contents.xcplayground
│ │ ├── playground.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── zhowkevin.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── timeline.xctimeline
│ └── LabelClass.playground/
│ ├── Contents.swift
│ ├── contents.xcplayground
│ ├── playground.xcworkspace/
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata/
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── zhowkevin.xcuserdatad/
│ │ └── UserInterfaceState.xcuserstate
│ └── timeline.xctimeline
├── Framer/
│ └── Diary.framer/
│ ├── .gitignore
│ ├── app.coffee
│ ├── framer/
│ │ ├── coffee-script.js
│ │ ├── config.json
│ │ ├── framer.generated.js
│ │ ├── framer.init.js
│ │ ├── framer.js
│ │ ├── framer.js.map.old
│ │ ├── framer.js.old
│ │ ├── framer.modules.js
│ │ ├── mirror.css
│ │ ├── style.css
│ │ └── version
│ ├── imported/
│ │ └── Diary/
│ │ ├── layers.json
│ │ └── layers.json.js
│ ├── index.html
│ └── modules/
│ └── myModule.coffee
├── Simple iOS App/
│ ├── SimpleHello_0/
│ │ ├── SimpleHello/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.xib
│ │ │ │ └── Main.storyboard
│ │ │ ├── Images.xcassets/
│ │ │ │ └── AppIcon.appiconset/
│ │ │ │ └── Contents.json
│ │ │ ├── Info.plist
│ │ │ └── ViewController.swift
│ │ ├── SimpleHello.xcodeproj/
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace/
│ │ │ │ ├── contents.xcworkspacedata
│ │ │ │ ├── xcshareddata/
│ │ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ │ └── xcuserdata/
│ │ │ │ ├── kevin.xcuserdatad/
│ │ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ │ └── zhowkevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── xcschemes/
│ │ │ │ ├── SimpleHello.xcscheme
│ │ │ │ └── xcschememanagement.plist
│ │ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ │ └── xcschemes/
│ │ │ │ └── xcschememanagement.plist
│ │ │ └── zhowkevin.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ ├── SimpleHello.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ └── SimpleHelloTests/
│ │ ├── Info.plist
│ │ └── SimpleHelloTests.swift
│ ├── SimpleHello_1/
│ │ ├── SimpleHello/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.xib
│ │ │ │ └── Main.storyboard
│ │ │ ├── Images.xcassets/
│ │ │ │ └── AppIcon.appiconset/
│ │ │ │ └── Contents.json
│ │ │ ├── Info.plist
│ │ │ └── ViewController.swift
│ │ ├── SimpleHello.xcodeproj/
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace/
│ │ │ │ ├── contents.xcworkspacedata
│ │ │ │ ├── xcshareddata/
│ │ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ │ └── xcuserdata/
│ │ │ │ ├── kevin.xcuserdatad/
│ │ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ │ └── zhowkevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── xcschemes/
│ │ │ │ ├── SimpleHello.xcscheme
│ │ │ │ └── xcschememanagement.plist
│ │ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ │ └── xcschemes/
│ │ │ │ └── xcschememanagement.plist
│ │ │ └── zhowkevin.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ ├── SimpleHello.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ └── SimpleHelloTests/
│ │ ├── Info.plist
│ │ └── SimpleHelloTests.swift
│ └── SimpleHello_final/
│ ├── SimpleHello/
│ │ ├── AppDelegate.swift
│ │ ├── Base.lproj/
│ │ │ ├── LaunchScreen.xib
│ │ │ └── Main.storyboard
│ │ ├── Images.xcassets/
│ │ │ └── AppIcon.appiconset/
│ │ │ └── Contents.json
│ │ ├── Info.plist
│ │ └── ViewController.swift
│ ├── SimpleHello.xcodeproj/
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata/
│ │ │ ├── kevin.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── zhowkevin.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ ├── SimpleHello.xcscheme
│ │ │ └── xcschememanagement.plist
│ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ └── xcschemes/
│ │ │ └── xcschememanagement.plist
│ │ └── zhowkevin.xcuserdatad/
│ │ └── xcschemes/
│ │ ├── SimpleHello.xcscheme
│ │ └── xcschememanagement.plist
│ └── SimpleHelloTests/
│ ├── Info.plist
│ └── SimpleHelloTests.swift
├── Sketch/
│ ├── Diary.sketch
│ └── Wunderlist_refine.sketch
├── Swift/
│ ├── SwiftPlayground_1.playground/
│ │ ├── Contents.swift
│ │ ├── contents.xcplayground
│ │ └── playground.xcworkspace/
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata/
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── zhowkevin.xcuserdatad/
│ │ └── UserInterfaceState.xcuserstate
│ ├── SwiftPlayground_2.playground/
│ │ ├── Contents.swift
│ │ ├── contents.xcplayground
│ │ └── playground.xcworkspace/
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata/
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── zhowkevin.xcuserdatad/
│ │ └── UserInterfaceState.xcuserstate
│ ├── SwiftPlayground_enum.playground/
│ │ ├── Contents.swift
│ │ ├── contents.xcplayground
│ │ └── playground.xcworkspace/
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata/
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── zhowkevin.xcuserdatad/
│ │ └── UserInterfaceState.xcuserstate
│ └── SwiftPlayground_protocol.playground/
│ ├── Contents.swift
│ ├── contents.xcplayground
│ ├── playground.xcworkspace/
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata/
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── zhowkevin.xcuserdatad/
│ │ └── UserInterfaceState.xcuserstate
│ └── timeline.xctimeline
├── What is iOS App/
│ ├── What is iOS App/
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets/
│ │ │ └── AppIcon.appiconset/
│ │ │ └── Contents.json
│ │ ├── Base.lproj/
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ └── ViewController.swift
│ └── What is iOS App.xcodeproj/
│ ├── project.pbxproj
│ ├── project.xcworkspace/
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata/
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata/
│ │ ├── kevin.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ ├── kevinzhow.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ ├── zhoukaiwen.xcuserdatad/
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── zhowkevin.xcuserdatad/
│ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata/
│ ├── kevin.xcuserdatad/
│ │ └── xcschemes/
│ │ ├── What is iOS App.xcscheme
│ │ └── xcschememanagement.plist
│ ├── kevinzhow.xcuserdatad/
│ │ └── xcschemes/
│ │ ├── What is iOS App.xcscheme
│ │ └── xcschememanagement.plist
│ ├── zhoukaiwen.xcuserdatad/
│ │ └── xcschemes/
│ │ └── xcschememanagement.plist
│ └── zhowkevin.xcuserdatad/
│ └── xcschemes/
│ ├── What is iOS App.xcscheme
│ └── xcschememanagement.plist
└── iOS Animation/
├── iOS Animation/
│ ├── AppDelegate.swift
│ ├── Assets.xcassets/
│ │ └── AppIcon.appiconset/
│ │ └── Contents.json
│ ├── Base.lproj/
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── DetailViewController.swift
│ ├── Info.plist
│ └── MasterViewController.swift
└── iOS Animation.xcodeproj/
├── project.pbxproj
├── project.xcworkspace/
│ ├── contents.xcworkspacedata
│ ├── xcshareddata/
│ │ └── IDEWorkspaceChecks.plist
│ └── xcuserdata/
│ ├── kevin.xcuserdatad/
│ │ └── UserInterfaceState.xcuserstate
│ ├── zhoukaiwen.xcuserdatad/
│ │ └── UserInterfaceState.xcuserstate
│ └── zhowkevin.xcuserdatad/
│ └── UserInterfaceState.xcuserstate
└── xcuserdata/
├── kevin.xcuserdatad/
│ └── xcschemes/
│ ├── iOS Animation.xcscheme
│ └── xcschememanagement.plist
├── zhoukaiwen.xcuserdatad/
│ └── xcschemes/
│ └── xcschememanagement.plist
└── zhowkevin.xcuserdatad/
└── xcschemes/
├── iOS Animation.xcscheme
└── xcschememanagement.plist
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
Pods
.DS_Store
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced/AppDelegate.swift
================================================
//
// AppDelegate.swift
// Animation Advanced
//
// Created by zhowkevin on 15/8/29.
// Copyright © 2015年 zhowkevin. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let splitViewController = self.window!.rootViewController as! UISplitViewController
let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController
navigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem
splitViewController.delegate = self
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// 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.
// 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.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// 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.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// 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.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// 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.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
// MARK: - Split view
func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController:UIViewController, onto primaryViewController:UIViewController) -> Bool {
guard let secondaryAsNavController = secondaryViewController as? UINavigationController else { return false }
guard let topAsDetailController = secondaryAsNavController.topViewController as? DetailViewController else { return false }
if topAsDetailController.detailItem == nil {
// Return true to indicate that we have handled the collapse by doing nothing; the secondary controller will be discarded.
return true
}
return false
}
}
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced/Assets.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced/Assets.xcassets/Contents.json
================================================
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced/Assets.xcassets/leaf.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "SVNKLWEYMX.jpg",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced/Base.lproj/LaunchScreen.storyboard
================================================
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced/Base.lproj/Main.storyboard
================================================
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced/DetailViewController.swift
================================================
//
// DetailViewController.swift
// Animation Advanced
//
// Created by zhowkevin on 15/8/29.
// Copyright © 2015年 zhowkevin. All rights reserved.
//
import UIKit
let color = UIColor(red: 0.225, green: 1.000, blue: 0.743, alpha: 1.000)
class DetailViewController: UIViewController {
@IBOutlet weak var detailDescriptionLabel: UILabel!
let jellyShape = CAShapeLayer()
var currentControlPoint: CGFloat = 0
var dummyView: UIView?
//
var box : UIView?
var animator:UIDynamicAnimator? = nil
var gravity: UIGravityBehavior!
var collision: UICollisionBehavior!
var displayLinkUIDynamic: CADisplayLink?
//
var imageView = UIImageView(frame: CGRect.zero)
var maskView = UIImageView(frame: CGRect.zero)
var detailItem: AnimationType? {
didSet {
// Update the view.
self.configureView()
}
}
func configureView() {
// Update the user interface for the detail item.
if let detail = self.detailItem {
if let label = self.detailDescriptionLabel {
label.text = detail.rawValue
}
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.configureView()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if let detail = self.detailItem {
switch detail {
case .Bezier:
bezierSimple()
case .BezierAdvanced:
bezierAdvanced()
case .BezierUIDynamic:
bezierUIDynamic()
case .KeyFrame:
keyFrame()
case .MaskAnimation:
maskAnimation()
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
CFBundleSignature
????
CFBundleVersion
1
LSRequiresIPhoneOS
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
Main
UIRequiredDeviceCapabilities
armv7
UIStatusBarTintParameters
UINavigationBar
Style
UIBarStyleDefault
Translucent
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
UISupportedInterfaceOrientations~ipad
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced/MasterViewController.swift
================================================
//
// MasterViewController.swift
// Animation Advanced
//
// Created by zhowkevin on 15/8/29.
// Copyright © 2015年 zhowkevin. All rights reserved.
//
import UIKit
enum AnimationType: String {
case Bezier = "BezierSimple"
case BezierAdvanced = "BezierAdvanced"
case BezierUIDynamic = "BezierUIDynamic"
case KeyFrame = "KeyFrame"
case MaskAnimation = "MaskAnimation"
}
class MasterViewController: UITableViewController {
var detailViewController: DetailViewController? = nil
var objects = [AnimationType.Bezier, AnimationType.BezierAdvanced,
AnimationType.BezierUIDynamic, AnimationType.KeyFrame, AnimationType.MaskAnimation]
override func viewDidLoad() {
super.viewDidLoad()
if let split = self.splitViewController {
let controllers = split.viewControllers
self.detailViewController = (controllers[controllers.count-1] as! UINavigationController).topViewController as? DetailViewController
}
}
override func viewWillAppear(_ animated: Bool) {
self.clearsSelectionOnViewWillAppear = self.splitViewController!.isCollapsed
super.viewWillAppear(animated)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Segues
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showDetail" {
if let indexPath = self.tableView.indexPathForSelectedRow {
let object = objects[(indexPath as NSIndexPath).row]
let controller = (segue.destination as! UINavigationController).topViewController as! DetailViewController
controller.detailItem = object
controller.navigationItem.leftBarButtonItem = self.splitViewController?.displayModeButtonItem
controller.navigationItem.leftItemsSupplementBackButton = true
}
}
}
// MARK: - Table View
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return objects.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
let object = objects[(indexPath as NSIndexPath).row]
cell.textLabel!.text = object.rawValue
return cell
}
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return true
}
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
objects.remove(at: (indexPath as NSIndexPath).row)
tableView.deleteRows(at: [indexPath], with: .fade)
} else if editingStyle == .insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
}
}
}
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced/bezierAdvanced.swift
================================================
//
// bezierAdvanced.swift
// Animation Advanced
//
// Created by zhowkevin on 15/9/6.
// Copyright © 2015年 zhowkevin. All rights reserved.
//
import UIKit
extension DetailViewController {
/**
For BezierAdvanced
*/
func bezierAdvanced() {
let pan = UIPanGestureRecognizer(target: self, action: #selector(DetailViewController.updatePathPan(_:)))
view.addGestureRecognizer(pan)
//// 绘制多边形
let polygonPath = UIBezierPath()
polygonPath.move(to: CGPoint(x: 0, y: 0))
polygonPath.addQuadCurve(to: CGPoint(x: 0, y: view.frame.height), controlPoint: CGPoint(x: 0, y: view.frame.height/2.0))
polygonPath.close()
// 绘制 CAShapeLayer
jellyShape.drawsAsynchronously = true
jellyShape.frame = view.bounds
jellyShape.path = polygonPath.cgPath
jellyShape.lineWidth = 3.0
jellyShape.lineCap = .round
jellyShape.lineJoin = .round
jellyShape.strokeColor = UIColor.white.cgColor
jellyShape.fillColor = color.cgColor
view.layer.addSublayer(jellyShape)
}
@objc func updatePathPan(_ gesture: UIPanGestureRecognizer) {
if gesture.state == .ended {
let displayLink = CADisplayLink(target: self, selector: #selector(DetailViewController.syncPath))
displayLink.add(to: RunLoop.current, forMode: .default)
dummyView = UIView(frame: CGRect(x: currentControlPoint, y: view.frame.height/2.0, width: 10, height: 10))
view.addSubview(dummyView!)
UIView.animate(withDuration: 1.0, delay: 0, usingSpringWithDamping: 0.3, initialSpringVelocity: 50, options: UIView.AnimationOptions(), animations: { () -> Void in
self.dummyView!.center = CGPoint(x: 0, y: self.view.frame.height/2.0)
}, completion: { finish in
self.currentControlPoint = 0
displayLink.invalidate()
})
} else if gesture.state == .changed {
let translationPoint = gesture.translation(in: view)
currentControlPoint = currentControlPoint + translationPoint.x
//// 绘制多边形
let polygonPath = UIBezierPath()
polygonPath.move(to: CGPoint(x: 0, y: 0))
polygonPath.addQuadCurve(to: CGPoint(x: 0, y: view.frame.height), controlPoint: CGPoint(x: currentControlPoint, y: view.frame.height/2.0))
polygonPath.close()
gesture.setTranslation(CGPoint.zero, in: view)
jellyShape.path = polygonPath.cgPath
}
}
@objc func syncPath() {
if let dummyView = dummyView, let currentLayer = dummyView.layer.presentation() {
//// 绘制多边形
let polygonPath = UIBezierPath()
polygonPath.move(to: CGPoint(x: 0, y: 0))
polygonPath.addQuadCurve(to: CGPoint(x: 0, y: view.frame.height), controlPoint: CGPoint(x: currentLayer.frame.origin.x, y: view.frame.height/2.0))
polygonPath.close()
jellyShape.path = polygonPath.cgPath
}
}
}
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced/bezierSimple.swift
================================================
//
// bezierSimple.swift
// Animation Advanced
//
// Created by zhowkevin on 15/9/6.
// Copyright © 2015年 zhowkevin. All rights reserved.
//
import UIKit
extension DetailViewController {
/**
For Bezier
*/
func bezierSimple() {
//// 绘制多边形
let polygonPath = UIBezierPath()
polygonPath.move(to: CGPoint(x: 162, y: 93))
polygonPath.addLine(to: CGPoint(x: 230.48, y: 142.75))
polygonPath.addLine(to: CGPoint(x: 204.32, y: 223.25))
polygonPath.addLine(to: CGPoint(x: 119.68, y: 223.25))
polygonPath.addLine(to: CGPoint(x: 93.52, y: 142.75))
polygonPath.close()
//// 绘制五角星
let starPath = UIBezierPath()
starPath.move(to: CGPoint(x: 162, y: 82))
starPath.addLine(to: CGPoint(x: 191.27, y: 124.71))
starPath.addLine(to: CGPoint(x: 240.94, y: 139.35))
starPath.addLine(to: CGPoint(x: 209.36, y: 180.39))
starPath.addLine(to: CGPoint(x: 210.79, y: 232.15))
starPath.addLine(to: CGPoint(x: 162, y: 214.8))
starPath.addLine(to: CGPoint(x: 113.21, y: 232.15))
starPath.addLine(to: CGPoint(x: 114.64, y: 180.39))
starPath.addLine(to: CGPoint(x: 83.06, y: 139.35))
starPath.addLine(to: CGPoint(x: 132.73, y: 124.71))
starPath.close()
// 绘制 CAShapeLayer
let shape = CAShapeLayer()
shape.drawsAsynchronously = true
shape.frame = view.bounds
shape.path = polygonPath.cgPath
shape.lineWidth = 3.0
shape.lineCap = .round
shape.lineJoin = .round
shape.strokeColor = UIColor.white.cgColor
shape.fillColor = color.cgColor
view.layer.addSublayer(shape)
let pathAnimation = CABasicAnimation(keyPath: "path")
pathAnimation.fromValue = polygonPath.cgPath
pathAnimation.toValue = starPath.cgPath
pathAnimation.duration = 1.0
pathAnimation.autoreverses = false
pathAnimation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
shape.add(pathAnimation, forKey: "animationKey")
shape.path = starPath.cgPath
}
}
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced/bezierUIDynamic.swift
================================================
//
// bezierUIDynamic.swift
// Animation Advanced
//
// Created by zhowkevin on 15/9/6.
// Copyright © 2015年 zhowkevin. All rights reserved.
//
import UIKit
extension DetailViewController {
/**
For BezierUIDynamic
*/
@objc func updateUIDynamicPathPan(_ gesture: UIPanGestureRecognizer) {
if gesture.state == .ended {
bezierUIDynamicSetup()
} else if gesture.state == .changed {
let translationPoint = gesture.translation(in: view)
currentControlPoint = currentControlPoint + translationPoint.x
//// Polygon Drawing
let polygonPath = UIBezierPath()
polygonPath.move(to: CGPoint(x: 0, y: 0))
polygonPath.addQuadCurve(to: CGPoint(x: 0, y: view.frame.height), controlPoint: CGPoint(x: currentControlPoint, y: view.frame.height/2.0))
polygonPath.close()
gesture.setTranslation(CGPoint.zero, in: view)
jellyShape.path = polygonPath.cgPath
} else if gesture.state == .began {
displayLinkUIDynamic?.invalidate()
currentControlPoint = 0
}
}
func bezierUIDynamic() {
let pan = UIPanGestureRecognizer(target: self, action: #selector(DetailViewController.updateUIDynamicPathPan(_:)))
view.addGestureRecognizer(pan)
//// Polygon Drawing
let polygonPath = UIBezierPath()
polygonPath.move(to: CGPoint(x: 0, y: 0))
polygonPath.addQuadCurve(to: CGPoint(x: 0, y: view.frame.height), controlPoint: CGPoint(x: 0, y: view.frame.height/2.0))
polygonPath.close()
// 绘制 CAShapeLayer
jellyShape.drawsAsynchronously = true
jellyShape.frame = view.bounds
jellyShape.path = polygonPath.cgPath
jellyShape.lineWidth = 3.0
jellyShape.lineCap = CAShapeLayerLineCap.round
jellyShape.lineJoin = CAShapeLayerLineJoin.round
jellyShape.strokeColor = UIColor.white.cgColor
jellyShape.fillColor = color.cgColor
view.layer.addSublayer(jellyShape)
}
func bezierUIDynamicSetup() {
// 创建物理碰撞盒子
box = UIView(frame: CGRect(x: currentControlPoint, y: view.frame.height/2.0, width: 10, height: 10))
// box?.backgroundColor = UIColor.redColor()
view.addSubview(box!)
// 创建 Animator
animator = UIDynamicAnimator(referenceView:self.view)
// 给盒子添加重力属性
gravity = UIGravityBehavior(items: [box!])
// 将重力调整为x轴向左坠落
gravity.gravityDirection = CGVector(dx: -10.9, dy: 0)
// 给盒子增加碰撞检测
collision = UICollisionBehavior(items: [box!])
collision.translatesReferenceBoundsIntoBoundary = true
// 修改盒子的弹性
let itemBehaviour = UIDynamicItemBehavior(items: [box!])
itemBehaviour.elasticity = 0.6
animator?.addBehavior(itemBehaviour)
animator?.addBehavior(collision)
animator?.addBehavior(gravity)
displayLinkUIDynamic = CADisplayLink(target: self, selector: #selector(DetailViewController.syncUIDynamicPath))
displayLinkUIDynamic!.add(to: .current, forMode: .default)
}
@objc func syncUIDynamicPath() {
if let dummyView = box, let currentLayer = dummyView.layer.presentation() {
//// Polygon Drawing
let polygonPath = UIBezierPath()
polygonPath.move(to: CGPoint(x: 0, y: 0))
polygonPath.addQuadCurve(to: CGPoint(x: 0, y: view.frame.height), controlPoint: CGPoint(x: currentLayer.frame.origin.x, y: view.frame.height/2.0))
polygonPath.close()
jellyShape.path = polygonPath.cgPath
}
}
}
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced/keyframe.swift
================================================
//
// keyframe.swift
// Animation Advanced
//
// Created by zhowkevin on 15/9/6.
// Copyright © 2015年 zhowkevin. All rights reserved.
//
import UIKit
extension DetailViewController {
func keyFrame() {
imageView.image = UIImage(named: "leaf")
// clipsToBounds使得图片显示不超过imageView的bounds
imageView.clipsToBounds = true
// ScaleAspectFill避免图片在缩放的时候变形
imageView.contentMode = .scaleAspectFill
view.window!.addSubview(imageView)
imageView.frame = CGRect(x: 0, y: 64, width: view.frame.width, height: 260)
startKeyFrameAnimation()
}
func startKeyFrameAnimation() {
// 定义一个总时间为2秒的动画
UIView.animateKeyframes(withDuration: 2, delay: 0, options: UIView.KeyframeAnimationOptions.calculationModeCubic, animations: {
// 在动画进度为0的时候开始,耗时0.5秒
UIView.addKeyframe(withRelativeStartTime: 0.0, relativeDuration: 0.5) {
self.imageView.frame = CGRect(x: 0, y: 48, width: self.view.frame.width, height: 0)
}
// 在动画进度为0.25的时候开始,耗时0.5秒
UIView.addKeyframe(withRelativeStartTime: 0.25, relativeDuration: 0.5) {
self.imageView.frame = CGRect(x: 0, y: 32, width: self.view.frame.width, height: 260 + self.view.frame.height/4.0)
}
// 在动画进度为0.5的时候开始,耗时0.5秒
UIView.addKeyframe(withRelativeStartTime: 0.5, relativeDuration: 0.5) {
self.imageView.frame = CGRect(x: 0, y: 16, width: self.view.frame.width, height: 260 + self.view.frame.height/2.0)
}
// 在动画进度为0.75的时候开始,耗时0.5秒
UIView.addKeyframe(withRelativeStartTime: 0.75, relativeDuration: 0.5) {
self.imageView.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
}
}, completion: nil)
}
}
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced/maskAnimation.swift
================================================
//
// maskAnimation.swift
// Animation Advanced
//
// Created by zhowkevin on 15/9/6.
// Copyright © 2015年 zhowkevin. All rights reserved.
//
import UIKit
extension DetailViewController {
func maskAnimation() {
imageView.image = UIImage(named: "leaf")
imageView.clipsToBounds = true
imageView.contentMode = .scaleAspectFill
view.window!.addSubview(imageView)
imageView.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.size
.height)
maskView.frame = CGRect(x: 0, y: 64, width: 30, height: 30)
maskView.layer.cornerRadius = 15.0
maskView.layer.masksToBounds = true
maskView.backgroundColor = UIColor.black
imageView.layer.mask = maskView.layer
startMaskAnimation()
}
func startMaskAnimation() {
let screenWidth = view.frame.width
let screenHeight = view.frame.height
// 针对bounds的变形动画
let transformAnim = CAKeyframeAnimation(keyPath:"bounds")
// values中定义了各个关键帧真对属性所需要修改的目标数值
transformAnim.values = [NSValue(cgRect:CGRect(x: 0, y: 0, width: 64, height: 64)) ,
NSValue(cgRect:CGRect(x: 0, y: 0, width: 128, height: 128)) ,
NSValue(cgRect:CGRect(x: 0, y: 0, width: 256, height: 256)) ,
NSValue(cgRect:CGRect(x: 0, y: 0, width: view.frame.height*2 , height: view.frame.height*2)) ]
// keyTimes和values是一一对应的关系,定义了每个关键帧
// 执行时相对于总时间的位置
transformAnim.keyTimes = [0, 0.349, 0.618, 1]
// duration为总时间
transformAnim.duration = 1
// removedOnCompletion定义了动画完成时是否从Layer上删除
transformAnim.isRemovedOnCompletion = false
// fillMode定义了动画完成时,对于Layer的属性修改是否保留
transformAnim.fillMode = .forwards
// 我们这里将removedOnCompletion定义为false,fillMode
// 定义为kCAFillModeForwards则可以使得动画结束时,保留
// Layer的结束状态,你可以通过注释到这两句,看看其默认效果
self.maskView.layer.add(transformAnim, forKey: "bounds")
// 定义位移动画,因为Core Animation不能操作frame,所以
// 需要拆分成position和bounds两个动画
let positionAnim = CAKeyframeAnimation(keyPath:"position")
positionAnim.values = [NSValue(cgPoint:CGPoint(x: screenWidth/8.0, y: screenHeight/8.0)) ,
NSValue(cgPoint:CGPoint(x: screenWidth/4.0, y: screenHeight/4.0)) ,
NSValue(cgPoint:CGPoint(x: screenWidth/2.0, y: screenHeight/2.0)) ,
NSValue(cgPoint:CGPoint(x: screenWidth/2.0, y: screenHeight/2.0)) ]
positionAnim.keyTimes = [0, 0.249, 0.618, 1]
positionAnim.duration = 1
positionAnim.isRemovedOnCompletion = false
positionAnim.fillMode = .forwards
self.maskView.layer.add(positionAnim, forKey: "position")
// 定义修改圆角的动画
let radiusAnim = CAKeyframeAnimation(keyPath:"cornerRadius")
radiusAnim.values = [32,64,128,view.frame.height]
radiusAnim.keyTimes = [0, 0.349, 0.618, 1]
radiusAnim.duration = 1
radiusAnim.isRemovedOnCompletion = false
radiusAnim.fillMode = .forwards
self.maskView.layer.add(radiusAnim, forKey: "cornerRadius")
}
}
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
6A4FDAFA1B9B5C3300C4A33B /* bezierSimple.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A4FDAF91B9B5C3300C4A33B /* bezierSimple.swift */; };
6A4FDAFC1B9B5C8700C4A33B /* bezierAdvanced.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A4FDAFB1B9B5C8700C4A33B /* bezierAdvanced.swift */; };
6A4FDAFE1B9B5CBB00C4A33B /* bezierUIDynamic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A4FDAFD1B9B5CBB00C4A33B /* bezierUIDynamic.swift */; };
6A4FDB001B9B5E3600C4A33B /* keyframe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A4FDAFF1B9B5E3600C4A33B /* keyframe.swift */; };
6A4FDB021B9B636A00C4A33B /* maskAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A4FDB011B9B636A00C4A33B /* maskAnimation.swift */; };
6AC7997C1B92082C00DDFD47 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AC7997B1B92082C00DDFD47 /* AppDelegate.swift */; };
6AC7997E1B92082C00DDFD47 /* MasterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AC7997D1B92082C00DDFD47 /* MasterViewController.swift */; };
6AC799801B92082C00DDFD47 /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AC7997F1B92082C00DDFD47 /* DetailViewController.swift */; };
6AC799831B92082C00DDFD47 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6AC799811B92082C00DDFD47 /* Main.storyboard */; };
6AC799851B92082C00DDFD47 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6AC799841B92082C00DDFD47 /* Assets.xcassets */; };
6AC799881B92082C00DDFD47 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6AC799861B92082C00DDFD47 /* LaunchScreen.storyboard */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
6A4FDAF91B9B5C3300C4A33B /* bezierSimple.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = bezierSimple.swift; sourceTree = ""; };
6A4FDAFB1B9B5C8700C4A33B /* bezierAdvanced.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = bezierAdvanced.swift; sourceTree = ""; };
6A4FDAFD1B9B5CBB00C4A33B /* bezierUIDynamic.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = bezierUIDynamic.swift; sourceTree = ""; };
6A4FDAFF1B9B5E3600C4A33B /* keyframe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = keyframe.swift; sourceTree = ""; };
6A4FDB011B9B636A00C4A33B /* maskAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = maskAnimation.swift; sourceTree = ""; };
6AC799781B92082C00DDFD47 /* Animation Advanced.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Animation Advanced.app"; sourceTree = BUILT_PRODUCTS_DIR; };
6AC7997B1B92082C00DDFD47 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
6AC7997D1B92082C00DDFD47 /* MasterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterViewController.swift; sourceTree = ""; };
6AC7997F1B92082C00DDFD47 /* DetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = ""; };
6AC799821B92082C00DDFD47 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
6AC799841B92082C00DDFD47 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
6AC799871B92082C00DDFD47 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
6AC799891B92082C00DDFD47 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
6AC799751B92082C00DDFD47 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
6A4FDB031B9B63C700C4A33B /* Animations */ = {
isa = PBXGroup;
children = (
6A4FDAFD1B9B5CBB00C4A33B /* bezierUIDynamic.swift */,
6A4FDAFF1B9B5E3600C4A33B /* keyframe.swift */,
6A4FDAFB1B9B5C8700C4A33B /* bezierAdvanced.swift */,
6A4FDAF91B9B5C3300C4A33B /* bezierSimple.swift */,
6A4FDB011B9B636A00C4A33B /* maskAnimation.swift */,
);
name = Animations;
sourceTree = "";
};
6AC7996F1B92082C00DDFD47 = {
isa = PBXGroup;
children = (
6AC7997A1B92082C00DDFD47 /* Animation Advanced */,
6AC799791B92082C00DDFD47 /* Products */,
);
sourceTree = "";
};
6AC799791B92082C00DDFD47 /* Products */ = {
isa = PBXGroup;
children = (
6AC799781B92082C00DDFD47 /* Animation Advanced.app */,
);
name = Products;
sourceTree = "";
};
6AC7997A1B92082C00DDFD47 /* Animation Advanced */ = {
isa = PBXGroup;
children = (
6AC7997B1B92082C00DDFD47 /* AppDelegate.swift */,
6AC7997D1B92082C00DDFD47 /* MasterViewController.swift */,
6AC7997F1B92082C00DDFD47 /* DetailViewController.swift */,
6A4FDB031B9B63C700C4A33B /* Animations */,
6AC799811B92082C00DDFD47 /* Main.storyboard */,
6AC799841B92082C00DDFD47 /* Assets.xcassets */,
6AC799861B92082C00DDFD47 /* LaunchScreen.storyboard */,
6AC799891B92082C00DDFD47 /* Info.plist */,
);
path = "Animation Advanced";
sourceTree = "";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
6AC799771B92082C00DDFD47 /* Animation Advanced */ = {
isa = PBXNativeTarget;
buildConfigurationList = 6AC7998C1B92082C00DDFD47 /* Build configuration list for PBXNativeTarget "Animation Advanced" */;
buildPhases = (
6AC799741B92082C00DDFD47 /* Sources */,
6AC799751B92082C00DDFD47 /* Frameworks */,
6AC799761B92082C00DDFD47 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = "Animation Advanced";
productName = "Animation Advanced";
productReference = 6AC799781B92082C00DDFD47 /* Animation Advanced.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
6AC799701B92082C00DDFD47 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = zhowkevin;
TargetAttributes = {
6AC799771B92082C00DDFD47 = {
CreatedOnToolsVersion = 7.0;
LastSwiftMigration = 0800;
};
};
};
buildConfigurationList = 6AC799731B92082C00DDFD47 /* Build configuration list for PBXProject "Animation Advanced" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 6AC7996F1B92082C00DDFD47;
productRefGroup = 6AC799791B92082C00DDFD47 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
6AC799771B92082C00DDFD47 /* Animation Advanced */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
6AC799761B92082C00DDFD47 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6AC799881B92082C00DDFD47 /* LaunchScreen.storyboard in Resources */,
6AC799851B92082C00DDFD47 /* Assets.xcassets in Resources */,
6AC799831B92082C00DDFD47 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
6AC799741B92082C00DDFD47 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6A4FDAFA1B9B5C3300C4A33B /* bezierSimple.swift in Sources */,
6AC799801B92082C00DDFD47 /* DetailViewController.swift in Sources */,
6A4FDB021B9B636A00C4A33B /* maskAnimation.swift in Sources */,
6A4FDB001B9B5E3600C4A33B /* keyframe.swift in Sources */,
6A4FDAFE1B9B5CBB00C4A33B /* bezierUIDynamic.swift in Sources */,
6AC7997E1B92082C00DDFD47 /* MasterViewController.swift in Sources */,
6AC7997C1B92082C00DDFD47 /* AppDelegate.swift in Sources */,
6A4FDAFC1B9B5C8700C4A33B /* bezierAdvanced.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
6AC799811B92082C00DDFD47 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
6AC799821B92082C00DDFD47 /* Base */,
);
name = Main.storyboard;
sourceTree = "";
};
6AC799861B92082C00DDFD47 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
6AC799871B92082C00DDFD47 /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
6AC7998A1B92082C00DDFD47 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
6AC7998B1B92082C00DDFD47 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
6AC7998D1B92082C00DDFD47 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = "Animation Advanced/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "kevinzhow.Animation-Advanced";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
};
name = Debug;
};
6AC7998E1B92082C00DDFD47 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = "Animation Advanced/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "kevinzhow.Animation-Advanced";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
6AC799731B92082C00DDFD47 /* Build configuration list for PBXProject "Animation Advanced" */ = {
isa = XCConfigurationList;
buildConfigurations = (
6AC7998A1B92082C00DDFD47 /* Debug */,
6AC7998B1B92082C00DDFD47 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
6AC7998C1B92082C00DDFD47 /* Build configuration list for PBXNativeTarget "Animation Advanced" */ = {
isa = XCConfigurationList;
buildConfigurations = (
6AC7998D1B92082C00DDFD47 /* Debug */,
6AC7998E1B92082C00DDFD47 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 6AC799701B92082C00DDFD47 /* Project object */;
}
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
================================================
IDEDidComputeMac32BitWarning
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced.xcodeproj/xcuserdata/kevinzhow.xcuserdatad/xcschemes/Animation Advanced.xcscheme
================================================
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced.xcodeproj/xcuserdata/kevinzhow.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Animation Advanced.xcscheme
orderHint
0
SuppressBuildableAutocreation
6AC799771B92082C00DDFD47
primary
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced.xcodeproj/xcuserdata/zhoukaiwen.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Animation Advanced.xcscheme_^#shared#^_
orderHint
0
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced.xcodeproj/xcuserdata/zhowkevin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
================================================
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced.xcodeproj/xcuserdata/zhowkevin.xcuserdatad/xcschemes/Animation Advanced.xcscheme
================================================
================================================
FILE: Example Codes/Animation Advanced/Animation Advanced.xcodeproj/xcuserdata/zhowkevin.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Animation Advanced.xcscheme
orderHint
0
SuppressBuildableAutocreation
6AC799771B92082C00DDFD47
primary
================================================
FILE: Example Codes/AutoLayout/TextView/Meow/AppDelegate.swift
================================================
//
// AppDelegate.swift
// Meow
//
// Created by kevinzhow on 15/6/10.
// Copyright (c) 2015年 kevinzhow. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// 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.
// 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.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// 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.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// 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.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// 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.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
================================================
FILE: Example Codes/AutoLayout/TextView/Meow/Base.lproj/LaunchScreen.xib
================================================
================================================
FILE: Example Codes/AutoLayout/TextView/Meow/Base.lproj/Main.storyboard
================================================
Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.
Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.
================================================
FILE: Example Codes/AutoLayout/TextView/Meow/Images.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/AutoLayout/TextView/Meow/Images.xcassets/cat_cart.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "cat_cart.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/AutoLayout/TextView/Meow/Images.xcassets/cat_eyes.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "cat_eyes.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/AutoLayout/TextView/Meow/Images.xcassets/cat_fat.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "cat_fat.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/AutoLayout/TextView/Meow/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
CFBundleSignature
????
CFBundleVersion
1
LSRequiresIPhoneOS
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
Main
UIRequiredDeviceCapabilities
armv7
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
UISupportedInterfaceOrientations~ipad
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
================================================
FILE: Example Codes/AutoLayout/TextView/Meow/ViewController.swift
================================================
//
// ViewController.swift
// Meow
//
// Created by kevinzhow on 15/6/10.
// Copyright (c) 2015年 kevinzhow. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
================================================
FILE: Example Codes/AutoLayout/TextView/Meow.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
0AA102261B2866B500C0B299 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA102251B2866B500C0B299 /* AppDelegate.swift */; };
0AA102281B2866B500C0B299 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA102271B2866B500C0B299 /* ViewController.swift */; };
0AA1022B1B2866B500C0B299 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0AA102291B2866B500C0B299 /* Main.storyboard */; };
0AA1022D1B2866B500C0B299 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0AA1022C1B2866B500C0B299 /* Images.xcassets */; };
0AA102301B2866B500C0B299 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0AA1022E1B2866B500C0B299 /* LaunchScreen.xib */; };
0AA1023C1B2866B500C0B299 /* MeowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA1023B1B2866B500C0B299 /* MeowTests.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
0AA102361B2866B500C0B299 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0AA102181B2866B500C0B299 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 0AA1021F1B2866B500C0B299;
remoteInfo = Meow;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
0AA102201B2866B500C0B299 /* Meow.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Meow.app; sourceTree = BUILT_PRODUCTS_DIR; };
0AA102241B2866B500C0B299 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
0AA102251B2866B500C0B299 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
0AA102271B2866B500C0B299 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
0AA1022A1B2866B500C0B299 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
0AA1022C1B2866B500C0B299 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
0AA1022F1B2866B500C0B299 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
0AA102351B2866B500C0B299 /* MeowTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MeowTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
0AA1023A1B2866B500C0B299 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
0AA1023B1B2866B500C0B299 /* MeowTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeowTests.swift; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
0AA1021D1B2866B500C0B299 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
0AA102321B2866B500C0B299 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
0AA102171B2866B500C0B299 = {
isa = PBXGroup;
children = (
0AA102221B2866B500C0B299 /* Meow */,
0AA102381B2866B500C0B299 /* MeowTests */,
0AA102211B2866B500C0B299 /* Products */,
);
sourceTree = "";
};
0AA102211B2866B500C0B299 /* Products */ = {
isa = PBXGroup;
children = (
0AA102201B2866B500C0B299 /* Meow.app */,
0AA102351B2866B500C0B299 /* MeowTests.xctest */,
);
name = Products;
sourceTree = "";
};
0AA102221B2866B500C0B299 /* Meow */ = {
isa = PBXGroup;
children = (
0AA102251B2866B500C0B299 /* AppDelegate.swift */,
0AA102271B2866B500C0B299 /* ViewController.swift */,
0AA102291B2866B500C0B299 /* Main.storyboard */,
0AA1022C1B2866B500C0B299 /* Images.xcassets */,
0AA1022E1B2866B500C0B299 /* LaunchScreen.xib */,
0AA102231B2866B500C0B299 /* Supporting Files */,
);
path = Meow;
sourceTree = "";
};
0AA102231B2866B500C0B299 /* Supporting Files */ = {
isa = PBXGroup;
children = (
0AA102241B2866B500C0B299 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "";
};
0AA102381B2866B500C0B299 /* MeowTests */ = {
isa = PBXGroup;
children = (
0AA1023B1B2866B500C0B299 /* MeowTests.swift */,
0AA102391B2866B500C0B299 /* Supporting Files */,
);
path = MeowTests;
sourceTree = "";
};
0AA102391B2866B500C0B299 /* Supporting Files */ = {
isa = PBXGroup;
children = (
0AA1023A1B2866B500C0B299 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
0AA1021F1B2866B500C0B299 /* Meow */ = {
isa = PBXNativeTarget;
buildConfigurationList = 0AA1023F1B2866B500C0B299 /* Build configuration list for PBXNativeTarget "Meow" */;
buildPhases = (
0AA1021C1B2866B500C0B299 /* Sources */,
0AA1021D1B2866B500C0B299 /* Frameworks */,
0AA1021E1B2866B500C0B299 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = Meow;
productName = Meow;
productReference = 0AA102201B2866B500C0B299 /* Meow.app */;
productType = "com.apple.product-type.application";
};
0AA102341B2866B500C0B299 /* MeowTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 0AA102421B2866B500C0B299 /* Build configuration list for PBXNativeTarget "MeowTests" */;
buildPhases = (
0AA102311B2866B500C0B299 /* Sources */,
0AA102321B2866B500C0B299 /* Frameworks */,
0AA102331B2866B500C0B299 /* Resources */,
);
buildRules = (
);
dependencies = (
0AA102371B2866B500C0B299 /* PBXTargetDependency */,
);
name = MeowTests;
productName = MeowTests;
productReference = 0AA102351B2866B500C0B299 /* MeowTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
0AA102181B2866B500C0B299 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = kevinzhow;
TargetAttributes = {
0AA1021F1B2866B500C0B299 = {
CreatedOnToolsVersion = 6.3.2;
LastSwiftMigration = 1010;
};
0AA102341B2866B500C0B299 = {
CreatedOnToolsVersion = 6.3.2;
LastSwiftMigration = 1010;
TestTargetID = 0AA1021F1B2866B500C0B299;
};
};
};
buildConfigurationList = 0AA1021B1B2866B500C0B299 /* Build configuration list for PBXProject "Meow" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 0AA102171B2866B500C0B299;
productRefGroup = 0AA102211B2866B500C0B299 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
0AA1021F1B2866B500C0B299 /* Meow */,
0AA102341B2866B500C0B299 /* MeowTests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
0AA1021E1B2866B500C0B299 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0AA1022B1B2866B500C0B299 /* Main.storyboard in Resources */,
0AA102301B2866B500C0B299 /* LaunchScreen.xib in Resources */,
0AA1022D1B2866B500C0B299 /* Images.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
0AA102331B2866B500C0B299 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
0AA1021C1B2866B500C0B299 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0AA102281B2866B500C0B299 /* ViewController.swift in Sources */,
0AA102261B2866B500C0B299 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
0AA102311B2866B500C0B299 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0AA1023C1B2866B500C0B299 /* MeowTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
0AA102371B2866B500C0B299 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 0AA1021F1B2866B500C0B299 /* Meow */;
targetProxy = 0AA102361B2866B500C0B299 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
0AA102291B2866B500C0B299 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
0AA1022A1B2866B500C0B299 /* Base */,
);
name = Main.storyboard;
sourceTree = "";
};
0AA1022E1B2866B500C0B299 /* LaunchScreen.xib */ = {
isa = PBXVariantGroup;
children = (
0AA1022F1B2866B500C0B299 /* Base */,
);
name = LaunchScreen.xib;
sourceTree = "";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
0AA1023D1B2866B500C0B299 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
0AA1023E1B2866B500C0B299 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
0AA102401B2866B500C0B299 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Meow/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "kevinzhow.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
0AA102411B2866B500C0B299 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Meow/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "kevinzhow.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Release;
};
0AA102431B2866B500C0B299 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = MeowTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "kevinzhow.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Meow.app/Meow";
};
name = Debug;
};
0AA102441B2866B500C0B299 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
INFOPLIST_FILE = MeowTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "kevinzhow.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Meow.app/Meow";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
0AA1021B1B2866B500C0B299 /* Build configuration list for PBXProject "Meow" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0AA1023D1B2866B500C0B299 /* Debug */,
0AA1023E1B2866B500C0B299 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0AA1023F1B2866B500C0B299 /* Build configuration list for PBXNativeTarget "Meow" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0AA102401B2866B500C0B299 /* Debug */,
0AA102411B2866B500C0B299 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0AA102421B2866B500C0B299 /* Build configuration list for PBXNativeTarget "MeowTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0AA102431B2866B500C0B299 /* Debug */,
0AA102441B2866B500C0B299 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 0AA102181B2866B500C0B299 /* Project object */;
}
================================================
FILE: Example Codes/AutoLayout/TextView/Meow.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
================================================
FILE: Example Codes/AutoLayout/TextView/Meow.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
================================================
IDEDidComputeMac32BitWarning
================================================
FILE: Example Codes/AutoLayout/TextView/Meow.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/Meow.xcscheme
================================================
================================================
FILE: Example Codes/AutoLayout/TextView/Meow.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Meow.xcscheme
orderHint
0
SuppressBuildableAutocreation
0AA1021F1B2866B500C0B299
primary
0AA102341B2866B500C0B299
primary
================================================
FILE: Example Codes/AutoLayout/TextView/Meow.xcodeproj/xcuserdata/zhoukaiwen.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Meow.xcscheme_^#shared#^_
orderHint
0
================================================
FILE: Example Codes/AutoLayout/TextView/Meow.xcodeproj/xcuserdata/zhowkevin.xcuserdatad/xcschemes/Meow.xcscheme
================================================
================================================
FILE: Example Codes/AutoLayout/TextView/Meow.xcodeproj/xcuserdata/zhowkevin.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Meow.xcscheme
orderHint
0
SuppressBuildableAutocreation
0AA1021F1B2866B500C0B299
primary
0AA102341B2866B500C0B299
primary
================================================
FILE: Example Codes/AutoLayout/TextView/MeowTests/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
BNDL
CFBundleShortVersionString
1.0
CFBundleSignature
????
CFBundleVersion
1
================================================
FILE: Example Codes/AutoLayout/TextView/MeowTests/MeowTests.swift
================================================
//
// MeowTests.swift
// MeowTests
//
// Created by kevinzhow on 15/6/10.
// Copyright (c) 2015年 kevinzhow. All rights reserved.
//
import UIKit
import XCTest
class MeowTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
XCTAssert(true, "Pass")
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure() {
// Put the code you want to measure the time of here.
}
}
}
================================================
FILE: Example Codes/AutoLayout/meow_0/Meow/AppDelegate.swift
================================================
//
// AppDelegate.swift
// Meow
//
// Created by kevinzhow on 15/6/10.
// Copyright (c) 2015年 kevinzhow. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// 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.
// 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.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// 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.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// 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.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// 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.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
================================================
FILE: Example Codes/AutoLayout/meow_0/Meow/Base.lproj/LaunchScreen.xib
================================================
================================================
FILE: Example Codes/AutoLayout/meow_0/Meow/Base.lproj/Main.storyboard
================================================
================================================
FILE: Example Codes/AutoLayout/meow_0/Meow/Images.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/AutoLayout/meow_0/Meow/Images.xcassets/cat_cart.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "cat_cart.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/AutoLayout/meow_0/Meow/Images.xcassets/cat_eyes.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "cat_eyes.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/AutoLayout/meow_0/Meow/Images.xcassets/cat_fat.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "cat_fat.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/AutoLayout/meow_0/Meow/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
kevinzhow.$(PRODUCT_NAME:rfc1034identifier)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
CFBundleSignature
????
CFBundleVersion
1
LSRequiresIPhoneOS
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
Main
UIRequiredDeviceCapabilities
armv7
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
UISupportedInterfaceOrientations~ipad
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
================================================
FILE: Example Codes/AutoLayout/meow_0/Meow/ViewController.swift
================================================
//
// ViewController.swift
// Meow
//
// Created by kevinzhow on 15/6/10.
// Copyright (c) 2015年 kevinzhow. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
================================================
FILE: Example Codes/AutoLayout/meow_0/Meow.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
0AA102261B2866B500C0B299 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA102251B2866B500C0B299 /* AppDelegate.swift */; };
0AA102281B2866B500C0B299 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA102271B2866B500C0B299 /* ViewController.swift */; };
0AA1022B1B2866B500C0B299 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0AA102291B2866B500C0B299 /* Main.storyboard */; };
0AA1022D1B2866B500C0B299 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0AA1022C1B2866B500C0B299 /* Images.xcassets */; };
0AA102301B2866B500C0B299 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0AA1022E1B2866B500C0B299 /* LaunchScreen.xib */; };
0AA1023C1B2866B500C0B299 /* MeowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA1023B1B2866B500C0B299 /* MeowTests.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
0AA102361B2866B500C0B299 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0AA102181B2866B500C0B299 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 0AA1021F1B2866B500C0B299;
remoteInfo = Meow;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
0AA102201B2866B500C0B299 /* Meow.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Meow.app; sourceTree = BUILT_PRODUCTS_DIR; };
0AA102241B2866B500C0B299 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
0AA102251B2866B500C0B299 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
0AA102271B2866B500C0B299 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
0AA1022A1B2866B500C0B299 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
0AA1022C1B2866B500C0B299 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
0AA1022F1B2866B500C0B299 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
0AA102351B2866B500C0B299 /* MeowTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MeowTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
0AA1023A1B2866B500C0B299 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
0AA1023B1B2866B500C0B299 /* MeowTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeowTests.swift; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
0AA1021D1B2866B500C0B299 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
0AA102321B2866B500C0B299 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
0AA102171B2866B500C0B299 = {
isa = PBXGroup;
children = (
0AA102221B2866B500C0B299 /* Meow */,
0AA102381B2866B500C0B299 /* MeowTests */,
0AA102211B2866B500C0B299 /* Products */,
);
sourceTree = "";
};
0AA102211B2866B500C0B299 /* Products */ = {
isa = PBXGroup;
children = (
0AA102201B2866B500C0B299 /* Meow.app */,
0AA102351B2866B500C0B299 /* MeowTests.xctest */,
);
name = Products;
sourceTree = "";
};
0AA102221B2866B500C0B299 /* Meow */ = {
isa = PBXGroup;
children = (
0AA102251B2866B500C0B299 /* AppDelegate.swift */,
0AA102271B2866B500C0B299 /* ViewController.swift */,
0AA102291B2866B500C0B299 /* Main.storyboard */,
0AA1022C1B2866B500C0B299 /* Images.xcassets */,
0AA1022E1B2866B500C0B299 /* LaunchScreen.xib */,
0AA102231B2866B500C0B299 /* Supporting Files */,
);
path = Meow;
sourceTree = "";
};
0AA102231B2866B500C0B299 /* Supporting Files */ = {
isa = PBXGroup;
children = (
0AA102241B2866B500C0B299 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "";
};
0AA102381B2866B500C0B299 /* MeowTests */ = {
isa = PBXGroup;
children = (
0AA1023B1B2866B500C0B299 /* MeowTests.swift */,
0AA102391B2866B500C0B299 /* Supporting Files */,
);
path = MeowTests;
sourceTree = "";
};
0AA102391B2866B500C0B299 /* Supporting Files */ = {
isa = PBXGroup;
children = (
0AA1023A1B2866B500C0B299 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
0AA1021F1B2866B500C0B299 /* Meow */ = {
isa = PBXNativeTarget;
buildConfigurationList = 0AA1023F1B2866B500C0B299 /* Build configuration list for PBXNativeTarget "Meow" */;
buildPhases = (
0AA1021C1B2866B500C0B299 /* Sources */,
0AA1021D1B2866B500C0B299 /* Frameworks */,
0AA1021E1B2866B500C0B299 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = Meow;
productName = Meow;
productReference = 0AA102201B2866B500C0B299 /* Meow.app */;
productType = "com.apple.product-type.application";
};
0AA102341B2866B500C0B299 /* MeowTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 0AA102421B2866B500C0B299 /* Build configuration list for PBXNativeTarget "MeowTests" */;
buildPhases = (
0AA102311B2866B500C0B299 /* Sources */,
0AA102321B2866B500C0B299 /* Frameworks */,
0AA102331B2866B500C0B299 /* Resources */,
);
buildRules = (
);
dependencies = (
0AA102371B2866B500C0B299 /* PBXTargetDependency */,
);
name = MeowTests;
productName = MeowTests;
productReference = 0AA102351B2866B500C0B299 /* MeowTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
0AA102181B2866B500C0B299 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0630;
ORGANIZATIONNAME = kevinzhow;
TargetAttributes = {
0AA1021F1B2866B500C0B299 = {
CreatedOnToolsVersion = 6.3.2;
LastSwiftMigration = 1010;
};
0AA102341B2866B500C0B299 = {
CreatedOnToolsVersion = 6.3.2;
LastSwiftMigration = 1010;
TestTargetID = 0AA1021F1B2866B500C0B299;
};
};
};
buildConfigurationList = 0AA1021B1B2866B500C0B299 /* Build configuration list for PBXProject "Meow" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 0AA102171B2866B500C0B299;
productRefGroup = 0AA102211B2866B500C0B299 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
0AA1021F1B2866B500C0B299 /* Meow */,
0AA102341B2866B500C0B299 /* MeowTests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
0AA1021E1B2866B500C0B299 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0AA1022B1B2866B500C0B299 /* Main.storyboard in Resources */,
0AA102301B2866B500C0B299 /* LaunchScreen.xib in Resources */,
0AA1022D1B2866B500C0B299 /* Images.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
0AA102331B2866B500C0B299 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
0AA1021C1B2866B500C0B299 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0AA102281B2866B500C0B299 /* ViewController.swift in Sources */,
0AA102261B2866B500C0B299 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
0AA102311B2866B500C0B299 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0AA1023C1B2866B500C0B299 /* MeowTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
0AA102371B2866B500C0B299 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 0AA1021F1B2866B500C0B299 /* Meow */;
targetProxy = 0AA102361B2866B500C0B299 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
0AA102291B2866B500C0B299 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
0AA1022A1B2866B500C0B299 /* Base */,
);
name = Main.storyboard;
sourceTree = "";
};
0AA1022E1B2866B500C0B299 /* LaunchScreen.xib */ = {
isa = PBXVariantGroup;
children = (
0AA1022F1B2866B500C0B299 /* Base */,
);
name = LaunchScreen.xib;
sourceTree = "";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
0AA1023D1B2866B500C0B299 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
0AA1023E1B2866B500C0B299 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
0AA102401B2866B500C0B299 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Meow/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
0AA102411B2866B500C0B299 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Meow/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Release;
};
0AA102431B2866B500C0B299 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = MeowTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Meow.app/Meow";
};
name = Debug;
};
0AA102441B2866B500C0B299 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
INFOPLIST_FILE = MeowTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Meow.app/Meow";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
0AA1021B1B2866B500C0B299 /* Build configuration list for PBXProject "Meow" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0AA1023D1B2866B500C0B299 /* Debug */,
0AA1023E1B2866B500C0B299 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0AA1023F1B2866B500C0B299 /* Build configuration list for PBXNativeTarget "Meow" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0AA102401B2866B500C0B299 /* Debug */,
0AA102411B2866B500C0B299 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0AA102421B2866B500C0B299 /* Build configuration list for PBXNativeTarget "MeowTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0AA102431B2866B500C0B299 /* Debug */,
0AA102441B2866B500C0B299 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 0AA102181B2866B500C0B299 /* Project object */;
}
================================================
FILE: Example Codes/AutoLayout/meow_0/Meow.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
================================================
FILE: Example Codes/AutoLayout/meow_0/Meow.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
================================================
IDEDidComputeMac32BitWarning
================================================
FILE: Example Codes/AutoLayout/meow_0/Meow.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/Meow.xcscheme
================================================
================================================
FILE: Example Codes/AutoLayout/meow_0/Meow.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Meow.xcscheme
orderHint
0
SuppressBuildableAutocreation
0AA1021F1B2866B500C0B299
primary
0AA102341B2866B500C0B299
primary
================================================
FILE: Example Codes/AutoLayout/meow_0/Meow.xcodeproj/xcuserdata/zhoukaiwen.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Meow.xcscheme_^#shared#^_
orderHint
0
================================================
FILE: Example Codes/AutoLayout/meow_0/Meow.xcodeproj/xcuserdata/zhowkevin.xcuserdatad/xcschemes/Meow.xcscheme
================================================
================================================
FILE: Example Codes/AutoLayout/meow_0/Meow.xcodeproj/xcuserdata/zhowkevin.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Meow.xcscheme
orderHint
0
SuppressBuildableAutocreation
0AA1021F1B2866B500C0B299
primary
0AA102341B2866B500C0B299
primary
================================================
FILE: Example Codes/AutoLayout/meow_0/MeowTests/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
kevinzhow.$(PRODUCT_NAME:rfc1034identifier)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
BNDL
CFBundleShortVersionString
1.0
CFBundleSignature
????
CFBundleVersion
1
================================================
FILE: Example Codes/AutoLayout/meow_0/MeowTests/MeowTests.swift
================================================
//
// MeowTests.swift
// MeowTests
//
// Created by kevinzhow on 15/6/10.
// Copyright (c) 2015年 kevinzhow. All rights reserved.
//
import UIKit
import XCTest
class MeowTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
XCTAssert(true, "Pass")
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure() {
// Put the code you want to measure the time of here.
}
}
}
================================================
FILE: Example Codes/AutoLayout/meow_1/Meow/AppDelegate.swift
================================================
//
// AppDelegate.swift
// Meow
//
// Created by kevinzhow on 15/6/10.
// Copyright (c) 2015年 kevinzhow. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// 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.
// 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.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// 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.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// 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.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// 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.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
================================================
FILE: Example Codes/AutoLayout/meow_1/Meow/Base.lproj/LaunchScreen.xib
================================================
================================================
FILE: Example Codes/AutoLayout/meow_1/Meow/Base.lproj/Main.storyboard
================================================
================================================
FILE: Example Codes/AutoLayout/meow_1/Meow/Images.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/AutoLayout/meow_1/Meow/Images.xcassets/cat_cart.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "cat_cart.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/AutoLayout/meow_1/Meow/Images.xcassets/cat_eyes.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "cat_eyes.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/AutoLayout/meow_1/Meow/Images.xcassets/cat_fat.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "cat_fat.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/AutoLayout/meow_1/Meow/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
kevinzhow.$(PRODUCT_NAME:rfc1034identifier)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
CFBundleSignature
????
CFBundleVersion
1
LSRequiresIPhoneOS
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
Main
UIRequiredDeviceCapabilities
armv7
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
UISupportedInterfaceOrientations~ipad
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
================================================
FILE: Example Codes/AutoLayout/meow_1/Meow/ViewController.swift
================================================
//
// ViewController.swift
// Meow
//
// Created by kevinzhow on 15/6/10.
// Copyright (c) 2015年 kevinzhow. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
================================================
FILE: Example Codes/AutoLayout/meow_1/Meow.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
0AA102261B2866B500C0B299 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA102251B2866B500C0B299 /* AppDelegate.swift */; };
0AA102281B2866B500C0B299 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA102271B2866B500C0B299 /* ViewController.swift */; };
0AA1022B1B2866B500C0B299 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0AA102291B2866B500C0B299 /* Main.storyboard */; };
0AA1022D1B2866B500C0B299 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0AA1022C1B2866B500C0B299 /* Images.xcassets */; };
0AA102301B2866B500C0B299 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0AA1022E1B2866B500C0B299 /* LaunchScreen.xib */; };
0AA1023C1B2866B500C0B299 /* MeowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA1023B1B2866B500C0B299 /* MeowTests.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
0AA102361B2866B500C0B299 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0AA102181B2866B500C0B299 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 0AA1021F1B2866B500C0B299;
remoteInfo = Meow;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
0AA102201B2866B500C0B299 /* Meow.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Meow.app; sourceTree = BUILT_PRODUCTS_DIR; };
0AA102241B2866B500C0B299 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
0AA102251B2866B500C0B299 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
0AA102271B2866B500C0B299 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
0AA1022A1B2866B500C0B299 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
0AA1022C1B2866B500C0B299 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
0AA1022F1B2866B500C0B299 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
0AA102351B2866B500C0B299 /* MeowTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MeowTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
0AA1023A1B2866B500C0B299 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
0AA1023B1B2866B500C0B299 /* MeowTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeowTests.swift; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
0AA1021D1B2866B500C0B299 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
0AA102321B2866B500C0B299 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
0AA102171B2866B500C0B299 = {
isa = PBXGroup;
children = (
0AA102221B2866B500C0B299 /* Meow */,
0AA102381B2866B500C0B299 /* MeowTests */,
0AA102211B2866B500C0B299 /* Products */,
);
sourceTree = "";
};
0AA102211B2866B500C0B299 /* Products */ = {
isa = PBXGroup;
children = (
0AA102201B2866B500C0B299 /* Meow.app */,
0AA102351B2866B500C0B299 /* MeowTests.xctest */,
);
name = Products;
sourceTree = "";
};
0AA102221B2866B500C0B299 /* Meow */ = {
isa = PBXGroup;
children = (
0AA102251B2866B500C0B299 /* AppDelegate.swift */,
0AA102271B2866B500C0B299 /* ViewController.swift */,
0AA102291B2866B500C0B299 /* Main.storyboard */,
0AA1022C1B2866B500C0B299 /* Images.xcassets */,
0AA1022E1B2866B500C0B299 /* LaunchScreen.xib */,
0AA102231B2866B500C0B299 /* Supporting Files */,
);
path = Meow;
sourceTree = "";
};
0AA102231B2866B500C0B299 /* Supporting Files */ = {
isa = PBXGroup;
children = (
0AA102241B2866B500C0B299 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "";
};
0AA102381B2866B500C0B299 /* MeowTests */ = {
isa = PBXGroup;
children = (
0AA1023B1B2866B500C0B299 /* MeowTests.swift */,
0AA102391B2866B500C0B299 /* Supporting Files */,
);
path = MeowTests;
sourceTree = "";
};
0AA102391B2866B500C0B299 /* Supporting Files */ = {
isa = PBXGroup;
children = (
0AA1023A1B2866B500C0B299 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
0AA1021F1B2866B500C0B299 /* Meow */ = {
isa = PBXNativeTarget;
buildConfigurationList = 0AA1023F1B2866B500C0B299 /* Build configuration list for PBXNativeTarget "Meow" */;
buildPhases = (
0AA1021C1B2866B500C0B299 /* Sources */,
0AA1021D1B2866B500C0B299 /* Frameworks */,
0AA1021E1B2866B500C0B299 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = Meow;
productName = Meow;
productReference = 0AA102201B2866B500C0B299 /* Meow.app */;
productType = "com.apple.product-type.application";
};
0AA102341B2866B500C0B299 /* MeowTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 0AA102421B2866B500C0B299 /* Build configuration list for PBXNativeTarget "MeowTests" */;
buildPhases = (
0AA102311B2866B500C0B299 /* Sources */,
0AA102321B2866B500C0B299 /* Frameworks */,
0AA102331B2866B500C0B299 /* Resources */,
);
buildRules = (
);
dependencies = (
0AA102371B2866B500C0B299 /* PBXTargetDependency */,
);
name = MeowTests;
productName = MeowTests;
productReference = 0AA102351B2866B500C0B299 /* MeowTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
0AA102181B2866B500C0B299 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0630;
ORGANIZATIONNAME = kevinzhow;
TargetAttributes = {
0AA1021F1B2866B500C0B299 = {
CreatedOnToolsVersion = 6.3.2;
LastSwiftMigration = 1010;
};
0AA102341B2866B500C0B299 = {
CreatedOnToolsVersion = 6.3.2;
LastSwiftMigration = 1010;
TestTargetID = 0AA1021F1B2866B500C0B299;
};
};
};
buildConfigurationList = 0AA1021B1B2866B500C0B299 /* Build configuration list for PBXProject "Meow" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 0AA102171B2866B500C0B299;
productRefGroup = 0AA102211B2866B500C0B299 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
0AA1021F1B2866B500C0B299 /* Meow */,
0AA102341B2866B500C0B299 /* MeowTests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
0AA1021E1B2866B500C0B299 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0AA1022B1B2866B500C0B299 /* Main.storyboard in Resources */,
0AA102301B2866B500C0B299 /* LaunchScreen.xib in Resources */,
0AA1022D1B2866B500C0B299 /* Images.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
0AA102331B2866B500C0B299 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
0AA1021C1B2866B500C0B299 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0AA102281B2866B500C0B299 /* ViewController.swift in Sources */,
0AA102261B2866B500C0B299 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
0AA102311B2866B500C0B299 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0AA1023C1B2866B500C0B299 /* MeowTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
0AA102371B2866B500C0B299 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 0AA1021F1B2866B500C0B299 /* Meow */;
targetProxy = 0AA102361B2866B500C0B299 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
0AA102291B2866B500C0B299 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
0AA1022A1B2866B500C0B299 /* Base */,
);
name = Main.storyboard;
sourceTree = "";
};
0AA1022E1B2866B500C0B299 /* LaunchScreen.xib */ = {
isa = PBXVariantGroup;
children = (
0AA1022F1B2866B500C0B299 /* Base */,
);
name = LaunchScreen.xib;
sourceTree = "";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
0AA1023D1B2866B500C0B299 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
0AA1023E1B2866B500C0B299 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
0AA102401B2866B500C0B299 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Meow/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
0AA102411B2866B500C0B299 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Meow/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Release;
};
0AA102431B2866B500C0B299 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = MeowTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Meow.app/Meow";
};
name = Debug;
};
0AA102441B2866B500C0B299 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
INFOPLIST_FILE = MeowTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Meow.app/Meow";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
0AA1021B1B2866B500C0B299 /* Build configuration list for PBXProject "Meow" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0AA1023D1B2866B500C0B299 /* Debug */,
0AA1023E1B2866B500C0B299 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0AA1023F1B2866B500C0B299 /* Build configuration list for PBXNativeTarget "Meow" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0AA102401B2866B500C0B299 /* Debug */,
0AA102411B2866B500C0B299 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0AA102421B2866B500C0B299 /* Build configuration list for PBXNativeTarget "MeowTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0AA102431B2866B500C0B299 /* Debug */,
0AA102441B2866B500C0B299 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 0AA102181B2866B500C0B299 /* Project object */;
}
================================================
FILE: Example Codes/AutoLayout/meow_1/Meow.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
================================================
FILE: Example Codes/AutoLayout/meow_1/Meow.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
================================================
IDEDidComputeMac32BitWarning
================================================
FILE: Example Codes/AutoLayout/meow_1/Meow.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/Meow.xcscheme
================================================
================================================
FILE: Example Codes/AutoLayout/meow_1/Meow.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Meow.xcscheme
orderHint
0
SuppressBuildableAutocreation
0AA1021F1B2866B500C0B299
primary
0AA102341B2866B500C0B299
primary
================================================
FILE: Example Codes/AutoLayout/meow_1/Meow.xcodeproj/xcuserdata/zhoukaiwen.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Meow.xcscheme_^#shared#^_
orderHint
0
================================================
FILE: Example Codes/AutoLayout/meow_1/Meow.xcodeproj/xcuserdata/zhowkevin.xcuserdatad/xcschemes/Meow.xcscheme
================================================
================================================
FILE: Example Codes/AutoLayout/meow_1/Meow.xcodeproj/xcuserdata/zhowkevin.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Meow.xcscheme
orderHint
0
SuppressBuildableAutocreation
0AA1021F1B2866B500C0B299
primary
0AA102341B2866B500C0B299
primary
================================================
FILE: Example Codes/AutoLayout/meow_1/MeowTests/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
kevinzhow.$(PRODUCT_NAME:rfc1034identifier)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
BNDL
CFBundleShortVersionString
1.0
CFBundleSignature
????
CFBundleVersion
1
================================================
FILE: Example Codes/AutoLayout/meow_1/MeowTests/MeowTests.swift
================================================
//
// MeowTests.swift
// MeowTests
//
// Created by kevinzhow on 15/6/10.
// Copyright (c) 2015年 kevinzhow. All rights reserved.
//
import UIKit
import XCTest
class MeowTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
XCTAssert(true, "Pass")
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure() {
// Put the code you want to measure the time of here.
}
}
}
================================================
FILE: Example Codes/AutoLayout/meow_2/Meow/AppDelegate.swift
================================================
//
// AppDelegate.swift
// Meow
//
// Created by kevinzhow on 15/6/10.
// Copyright (c) 2015年 kevinzhow. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// 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.
// 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.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// 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.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// 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.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// 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.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
================================================
FILE: Example Codes/AutoLayout/meow_2/Meow/Base.lproj/LaunchScreen.xib
================================================
================================================
FILE: Example Codes/AutoLayout/meow_2/Meow/Base.lproj/Main.storyboard
================================================
================================================
FILE: Example Codes/AutoLayout/meow_2/Meow/Images.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/AutoLayout/meow_2/Meow/Images.xcassets/cat_cart.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "cat_cart.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/AutoLayout/meow_2/Meow/Images.xcassets/cat_eyes.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "cat_eyes.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/AutoLayout/meow_2/Meow/Images.xcassets/cat_fat.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "cat_fat.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/AutoLayout/meow_2/Meow/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
CFBundleSignature
????
CFBundleVersion
1
LSRequiresIPhoneOS
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
Main
UIRequiredDeviceCapabilities
armv7
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
UISupportedInterfaceOrientations~ipad
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
================================================
FILE: Example Codes/AutoLayout/meow_2/Meow/ViewController.swift
================================================
//
// ViewController.swift
// Meow
//
// Created by kevinzhow on 15/6/10.
// Copyright (c) 2015年 kevinzhow. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
================================================
FILE: Example Codes/AutoLayout/meow_2/Meow.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
0AA102261B2866B500C0B299 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA102251B2866B500C0B299 /* AppDelegate.swift */; };
0AA102281B2866B500C0B299 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA102271B2866B500C0B299 /* ViewController.swift */; };
0AA1022B1B2866B500C0B299 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0AA102291B2866B500C0B299 /* Main.storyboard */; };
0AA1022D1B2866B500C0B299 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0AA1022C1B2866B500C0B299 /* Images.xcassets */; };
0AA102301B2866B500C0B299 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0AA1022E1B2866B500C0B299 /* LaunchScreen.xib */; };
0AA1023C1B2866B500C0B299 /* MeowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA1023B1B2866B500C0B299 /* MeowTests.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
0AA102361B2866B500C0B299 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0AA102181B2866B500C0B299 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 0AA1021F1B2866B500C0B299;
remoteInfo = Meow;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
0AA102201B2866B500C0B299 /* Meow.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Meow.app; sourceTree = BUILT_PRODUCTS_DIR; };
0AA102241B2866B500C0B299 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
0AA102251B2866B500C0B299 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
0AA102271B2866B500C0B299 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
0AA1022A1B2866B500C0B299 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
0AA1022C1B2866B500C0B299 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
0AA1022F1B2866B500C0B299 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
0AA102351B2866B500C0B299 /* MeowTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MeowTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
0AA1023A1B2866B500C0B299 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
0AA1023B1B2866B500C0B299 /* MeowTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeowTests.swift; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
0AA1021D1B2866B500C0B299 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
0AA102321B2866B500C0B299 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
0AA102171B2866B500C0B299 = {
isa = PBXGroup;
children = (
0AA102221B2866B500C0B299 /* Meow */,
0AA102381B2866B500C0B299 /* MeowTests */,
0AA102211B2866B500C0B299 /* Products */,
);
sourceTree = "";
};
0AA102211B2866B500C0B299 /* Products */ = {
isa = PBXGroup;
children = (
0AA102201B2866B500C0B299 /* Meow.app */,
0AA102351B2866B500C0B299 /* MeowTests.xctest */,
);
name = Products;
sourceTree = "";
};
0AA102221B2866B500C0B299 /* Meow */ = {
isa = PBXGroup;
children = (
0AA102251B2866B500C0B299 /* AppDelegate.swift */,
0AA102271B2866B500C0B299 /* ViewController.swift */,
0AA102291B2866B500C0B299 /* Main.storyboard */,
0AA1022C1B2866B500C0B299 /* Images.xcassets */,
0AA1022E1B2866B500C0B299 /* LaunchScreen.xib */,
0AA102231B2866B500C0B299 /* Supporting Files */,
);
path = Meow;
sourceTree = "";
};
0AA102231B2866B500C0B299 /* Supporting Files */ = {
isa = PBXGroup;
children = (
0AA102241B2866B500C0B299 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "";
};
0AA102381B2866B500C0B299 /* MeowTests */ = {
isa = PBXGroup;
children = (
0AA1023B1B2866B500C0B299 /* MeowTests.swift */,
0AA102391B2866B500C0B299 /* Supporting Files */,
);
path = MeowTests;
sourceTree = "";
};
0AA102391B2866B500C0B299 /* Supporting Files */ = {
isa = PBXGroup;
children = (
0AA1023A1B2866B500C0B299 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
0AA1021F1B2866B500C0B299 /* Meow */ = {
isa = PBXNativeTarget;
buildConfigurationList = 0AA1023F1B2866B500C0B299 /* Build configuration list for PBXNativeTarget "Meow" */;
buildPhases = (
0AA1021C1B2866B500C0B299 /* Sources */,
0AA1021D1B2866B500C0B299 /* Frameworks */,
0AA1021E1B2866B500C0B299 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = Meow;
productName = Meow;
productReference = 0AA102201B2866B500C0B299 /* Meow.app */;
productType = "com.apple.product-type.application";
};
0AA102341B2866B500C0B299 /* MeowTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 0AA102421B2866B500C0B299 /* Build configuration list for PBXNativeTarget "MeowTests" */;
buildPhases = (
0AA102311B2866B500C0B299 /* Sources */,
0AA102321B2866B500C0B299 /* Frameworks */,
0AA102331B2866B500C0B299 /* Resources */,
);
buildRules = (
);
dependencies = (
0AA102371B2866B500C0B299 /* PBXTargetDependency */,
);
name = MeowTests;
productName = MeowTests;
productReference = 0AA102351B2866B500C0B299 /* MeowTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
0AA102181B2866B500C0B299 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = kevinzhow;
TargetAttributes = {
0AA1021F1B2866B500C0B299 = {
CreatedOnToolsVersion = 6.3.2;
LastSwiftMigration = 1010;
};
0AA102341B2866B500C0B299 = {
CreatedOnToolsVersion = 6.3.2;
LastSwiftMigration = 1010;
TestTargetID = 0AA1021F1B2866B500C0B299;
};
};
};
buildConfigurationList = 0AA1021B1B2866B500C0B299 /* Build configuration list for PBXProject "Meow" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 0AA102171B2866B500C0B299;
productRefGroup = 0AA102211B2866B500C0B299 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
0AA1021F1B2866B500C0B299 /* Meow */,
0AA102341B2866B500C0B299 /* MeowTests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
0AA1021E1B2866B500C0B299 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0AA1022B1B2866B500C0B299 /* Main.storyboard in Resources */,
0AA102301B2866B500C0B299 /* LaunchScreen.xib in Resources */,
0AA1022D1B2866B500C0B299 /* Images.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
0AA102331B2866B500C0B299 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
0AA1021C1B2866B500C0B299 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0AA102281B2866B500C0B299 /* ViewController.swift in Sources */,
0AA102261B2866B500C0B299 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
0AA102311B2866B500C0B299 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0AA1023C1B2866B500C0B299 /* MeowTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
0AA102371B2866B500C0B299 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 0AA1021F1B2866B500C0B299 /* Meow */;
targetProxy = 0AA102361B2866B500C0B299 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
0AA102291B2866B500C0B299 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
0AA1022A1B2866B500C0B299 /* Base */,
);
name = Main.storyboard;
sourceTree = "";
};
0AA1022E1B2866B500C0B299 /* LaunchScreen.xib */ = {
isa = PBXVariantGroup;
children = (
0AA1022F1B2866B500C0B299 /* Base */,
);
name = LaunchScreen.xib;
sourceTree = "";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
0AA1023D1B2866B500C0B299 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
0AA1023E1B2866B500C0B299 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
0AA102401B2866B500C0B299 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Meow/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "kevinzhow.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
0AA102411B2866B500C0B299 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Meow/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "kevinzhow.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Release;
};
0AA102431B2866B500C0B299 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = MeowTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "kevinzhow.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Meow.app/Meow";
};
name = Debug;
};
0AA102441B2866B500C0B299 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
INFOPLIST_FILE = MeowTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "kevinzhow.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Meow.app/Meow";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
0AA1021B1B2866B500C0B299 /* Build configuration list for PBXProject "Meow" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0AA1023D1B2866B500C0B299 /* Debug */,
0AA1023E1B2866B500C0B299 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0AA1023F1B2866B500C0B299 /* Build configuration list for PBXNativeTarget "Meow" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0AA102401B2866B500C0B299 /* Debug */,
0AA102411B2866B500C0B299 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0AA102421B2866B500C0B299 /* Build configuration list for PBXNativeTarget "MeowTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0AA102431B2866B500C0B299 /* Debug */,
0AA102441B2866B500C0B299 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 0AA102181B2866B500C0B299 /* Project object */;
}
================================================
FILE: Example Codes/AutoLayout/meow_2/Meow.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
================================================
FILE: Example Codes/AutoLayout/meow_2/Meow.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
================================================
IDEDidComputeMac32BitWarning
================================================
FILE: Example Codes/AutoLayout/meow_2/Meow.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/Meow.xcscheme
================================================
================================================
FILE: Example Codes/AutoLayout/meow_2/Meow.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Meow.xcscheme
orderHint
0
SuppressBuildableAutocreation
0AA1021F1B2866B500C0B299
primary
0AA102341B2866B500C0B299
primary
================================================
FILE: Example Codes/AutoLayout/meow_2/Meow.xcodeproj/xcuserdata/zhoukaiwen.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Meow.xcscheme_^#shared#^_
orderHint
0
================================================
FILE: Example Codes/AutoLayout/meow_2/Meow.xcodeproj/xcuserdata/zhowkevin.xcuserdatad/xcschemes/Meow.xcscheme
================================================
================================================
FILE: Example Codes/AutoLayout/meow_2/Meow.xcodeproj/xcuserdata/zhowkevin.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Meow.xcscheme
orderHint
0
SuppressBuildableAutocreation
0AA1021F1B2866B500C0B299
primary
0AA102341B2866B500C0B299
primary
================================================
FILE: Example Codes/AutoLayout/meow_2/MeowTests/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
BNDL
CFBundleShortVersionString
1.0
CFBundleSignature
????
CFBundleVersion
1
================================================
FILE: Example Codes/AutoLayout/meow_2/MeowTests/MeowTests.swift
================================================
//
// MeowTests.swift
// MeowTests
//
// Created by kevinzhow on 15/6/10.
// Copyright (c) 2015年 kevinzhow. All rights reserved.
//
import UIKit
import XCTest
class MeowTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
XCTAssert(true, "Pass")
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure() {
// Put the code you want to measure the time of here.
}
}
}
================================================
FILE: Example Codes/Diary/Diary_0/Diary/AppDelegate.swift
================================================
//
// AppDelegate.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// 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.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// 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.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// 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.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
================================================
FILE: Example Codes/Diary/Diary_0/Diary/Assets.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Diary/Diary_0/Diary/Base.lproj/LaunchScreen.storyboard
================================================
================================================
FILE: Example Codes/Diary/Diary_0/Diary/Base.lproj/Main.storyboard
================================================
================================================
FILE: Example Codes/Diary/Diary_0/Diary/DiaryLabel.swift
================================================
//
// DiaryLabel.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
func sizeHeightWithText(labelText: String,
fontSize: CGFloat,
textAttributes: [NSAttributedString.Key: AnyObject]) -> CGRect {
return labelText.boundingRect(
with: CGSize(width:fontSize, height:480),
options: NSStringDrawingOptions.usesLineFragmentOrigin,
attributes: textAttributes, context: nil)
}
class DiaryLabel: UILabel {
var textAttributes: [NSAttributedString.Key: AnyObject]!
convenience init(fontname:String,
labelText:String,
fontSize : CGFloat,
lineHeight: CGFloat){
self.init(frame: CGRect(x:0, y:0, width:0, height:0))
let font = UIFont(name: fontname,
size: fontSize)
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = lineHeight
textAttributes = [NSAttributedString.Key.font: font!,
NSAttributedString.Key.paragraphStyle: paragraphStyle]
let labelSize = sizeHeightWithText(labelText: labelText,
fontSize: fontSize ,
textAttributes: textAttributes)
self.frame = CGRect(x: 0, y: 0, width: labelSize.width,
height: labelSize.height)
self.attributedText = NSAttributedString(
string: labelText,
attributes: textAttributes)
self.lineBreakMode = NSLineBreakMode.byCharWrapping
self.numberOfLines = 0
}
}
================================================
FILE: Example Codes/Diary/Diary_0/Diary/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
CFBundleVersion
1
LSRequiresIPhoneOS
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
Main
UIRequiredDeviceCapabilities
armv7
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
UISupportedInterfaceOrientations~ipad
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
================================================
FILE: Example Codes/Diary/Diary_0/Diary/ViewController.swift
================================================
//
// ViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
================================================
FILE: Example Codes/Diary/Diary_0/Diary.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
0A5EA7371DB2B0F500B4665B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7361DB2B0F500B4665B /* AppDelegate.swift */; };
0A5EA7391DB2B0F500B4665B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7381DB2B0F500B4665B /* ViewController.swift */; };
0A5EA73C1DB2B0F500B4665B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA73A1DB2B0F500B4665B /* Main.storyboard */; };
0A5EA73E1DB2B0F500B4665B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA73D1DB2B0F500B4665B /* Assets.xcassets */; };
0A5EA7411DB2B0F500B4665B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA73F1DB2B0F500B4665B /* LaunchScreen.storyboard */; };
0A5EA7491DB2B2E200B4665B /* DiaryLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7481DB2B2E200B4665B /* DiaryLabel.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
0A5EA7331DB2B0F500B4665B /* Diary.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Diary.app; sourceTree = BUILT_PRODUCTS_DIR; };
0A5EA7361DB2B0F500B4665B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
0A5EA7381DB2B0F500B4665B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
0A5EA73B1DB2B0F500B4665B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
0A5EA73D1DB2B0F500B4665B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
0A5EA7401DB2B0F500B4665B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
0A5EA7421DB2B0F500B4665B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
0A5EA7481DB2B2E200B4665B /* DiaryLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryLabel.swift; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
0A5EA7301DB2B0F500B4665B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
0A5EA72A1DB2B0F500B4665B = {
isa = PBXGroup;
children = (
0A5EA7351DB2B0F500B4665B /* Diary */,
0A5EA7341DB2B0F500B4665B /* Products */,
);
sourceTree = "";
};
0A5EA7341DB2B0F500B4665B /* Products */ = {
isa = PBXGroup;
children = (
0A5EA7331DB2B0F500B4665B /* Diary.app */,
);
name = Products;
sourceTree = "";
};
0A5EA7351DB2B0F500B4665B /* Diary */ = {
isa = PBXGroup;
children = (
0A5EA7361DB2B0F500B4665B /* AppDelegate.swift */,
0A5EA7481DB2B2E200B4665B /* DiaryLabel.swift */,
0A5EA7381DB2B0F500B4665B /* ViewController.swift */,
0A5EA73A1DB2B0F500B4665B /* Main.storyboard */,
0A5EA73D1DB2B0F500B4665B /* Assets.xcassets */,
0A5EA73F1DB2B0F500B4665B /* LaunchScreen.storyboard */,
0A5EA7421DB2B0F500B4665B /* Info.plist */,
);
path = Diary;
sourceTree = "";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
0A5EA7321DB2B0F500B4665B /* Diary */ = {
isa = PBXNativeTarget;
buildConfigurationList = 0A5EA7451DB2B0F500B4665B /* Build configuration list for PBXNativeTarget "Diary" */;
buildPhases = (
0A5EA72F1DB2B0F500B4665B /* Sources */,
0A5EA7301DB2B0F500B4665B /* Frameworks */,
0A5EA7311DB2B0F500B4665B /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = Diary;
productName = Diary;
productReference = 0A5EA7331DB2B0F500B4665B /* Diary.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
0A5EA72B1DB2B0F500B4665B /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0800;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = kevinzhow;
TargetAttributes = {
0A5EA7321DB2B0F500B4665B = {
CreatedOnToolsVersion = 8.0;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 0A5EA72E1DB2B0F500B4665B /* Build configuration list for PBXProject "Diary" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 0A5EA72A1DB2B0F500B4665B;
productRefGroup = 0A5EA7341DB2B0F500B4665B /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
0A5EA7321DB2B0F500B4665B /* Diary */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
0A5EA7311DB2B0F500B4665B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0A5EA7411DB2B0F500B4665B /* LaunchScreen.storyboard in Resources */,
0A5EA73E1DB2B0F500B4665B /* Assets.xcassets in Resources */,
0A5EA73C1DB2B0F500B4665B /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
0A5EA72F1DB2B0F500B4665B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0A5EA7391DB2B0F500B4665B /* ViewController.swift in Sources */,
0A5EA7371DB2B0F500B4665B /* AppDelegate.swift in Sources */,
0A5EA7491DB2B2E200B4665B /* DiaryLabel.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
0A5EA73A1DB2B0F500B4665B /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
0A5EA73B1DB2B0F500B4665B /* Base */,
);
name = Main.storyboard;
sourceTree = "";
};
0A5EA73F1DB2B0F500B4665B /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
0A5EA7401DB2B0F500B4665B /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
0A5EA7431DB2B0F500B4665B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
0A5EA7441DB2B0F500B4665B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
0A5EA7461DB2B0F500B4665B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Diary/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = kevinzhow.Diary;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
};
name = Debug;
};
0A5EA7471DB2B0F500B4665B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Diary/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = kevinzhow.Diary;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
0A5EA72E1DB2B0F500B4665B /* Build configuration list for PBXProject "Diary" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0A5EA7431DB2B0F500B4665B /* Debug */,
0A5EA7441DB2B0F500B4665B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0A5EA7451DB2B0F500B4665B /* Build configuration list for PBXNativeTarget "Diary" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0A5EA7461DB2B0F500B4665B /* Debug */,
0A5EA7471DB2B0F500B4665B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 0A5EA72B1DB2B0F500B4665B /* Project object */;
}
================================================
FILE: Example Codes/Diary/Diary_0/Diary.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
================================================
FILE: Example Codes/Diary/Diary_0/Diary.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/Diary.xcscheme
================================================
================================================
FILE: Example Codes/Diary/Diary_0/Diary.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Diary.xcscheme
orderHint
0
SuppressBuildableAutocreation
0A5EA7321DB2B0F500B4665B
primary
================================================
FILE: Example Codes/Diary/Diary_1/Diary/AppDelegate.swift
================================================
//
// AppDelegate.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// 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.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// 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.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// 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.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
================================================
FILE: Example Codes/Diary/Diary_1/Diary/Assets.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Diary/Diary_1/Diary/Base.lproj/LaunchScreen.storyboard
================================================
================================================
FILE: Example Codes/Diary/Diary_1/Diary/Base.lproj/Main.storyboard
================================================
================================================
FILE: Example Codes/Diary/Diary_1/Diary/DiaryLabel.swift
================================================
//
// DiaryLabel.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
func sizeHeightWithText(labelText: String,
fontSize: CGFloat,
textAttributes: [NSAttributedString.Key: AnyObject]) -> CGRect {
return labelText.boundingRect(
with: CGSize(width:fontSize, height:480),
options: NSStringDrawingOptions.usesLineFragmentOrigin,
attributes: textAttributes, context: nil)
}
class DiaryLabel: UILabel {
var textAttributes: [NSAttributedString.Key: AnyObject]!
convenience init(fontname:String,
labelText:String,
fontSize : CGFloat,
lineHeight: CGFloat){
self.init(frame: CGRect(x:0, y:0, width:0, height:0))
let font = UIFont(name: fontname,
size: fontSize)
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = lineHeight
textAttributes = [NSAttributedString.Key.font: font!,
NSAttributedString.Key.paragraphStyle: paragraphStyle]
let labelSize = sizeHeightWithText(labelText: labelText,
fontSize: fontSize ,
textAttributes: textAttributes)
self.frame = CGRect(x: 0, y: 0, width: labelSize.width,
height: labelSize.height)
self.attributedText = NSAttributedString(
string: labelText,
attributes: textAttributes)
self.lineBreakMode = NSLineBreakMode.byCharWrapping
self.numberOfLines = 0
}
}
================================================
FILE: Example Codes/Diary/Diary_1/Diary/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
CFBundleVersion
1
LSRequiresIPhoneOS
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
Main
UIRequiredDeviceCapabilities
armv7
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
UIAppFonts
Wyue-GutiFangsong-NC_deliverable.otf
TpldKhangXiDictTrial.otf
UISupportedInterfaceOrientations~ipad
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
================================================
FILE: Example Codes/Diary/Diary_1/Diary/ViewController.swift
================================================
//
// ViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
================================================
FILE: Example Codes/Diary/Diary_1/Diary/Wyue-GutiFangsong-NC_deliverable.otf
================================================
[File too large to display: 21.5 MB]
================================================
FILE: Example Codes/Diary/Diary_1/Diary.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
0A5EA7371DB2B0F500B4665B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7361DB2B0F500B4665B /* AppDelegate.swift */; };
0A5EA7391DB2B0F500B4665B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7381DB2B0F500B4665B /* ViewController.swift */; };
0A5EA73C1DB2B0F500B4665B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA73A1DB2B0F500B4665B /* Main.storyboard */; };
0A5EA73E1DB2B0F500B4665B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA73D1DB2B0F500B4665B /* Assets.xcassets */; };
0A5EA7411DB2B0F500B4665B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA73F1DB2B0F500B4665B /* LaunchScreen.storyboard */; };
0A5EA7491DB2B2E200B4665B /* DiaryLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7481DB2B2E200B4665B /* DiaryLabel.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
0A5EA7331DB2B0F500B4665B /* Diary.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Diary.app; sourceTree = BUILT_PRODUCTS_DIR; };
0A5EA7361DB2B0F500B4665B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
0A5EA7381DB2B0F500B4665B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
0A5EA73B1DB2B0F500B4665B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
0A5EA73D1DB2B0F500B4665B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
0A5EA7401DB2B0F500B4665B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
0A5EA7421DB2B0F500B4665B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
0A5EA7481DB2B2E200B4665B /* DiaryLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryLabel.swift; sourceTree = ""; };
0A5EA74A1DB2B4BA00B4665B /* TpldKhangXiDictTrial.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = TpldKhangXiDictTrial.otf; sourceTree = ""; };
0A5EA74B1DB2B4BA00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Wyue-GutiFangsong-NC_deliverable.otf"; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
0A5EA7301DB2B0F500B4665B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
0A5EA72A1DB2B0F500B4665B = {
isa = PBXGroup;
children = (
0A5EA7351DB2B0F500B4665B /* Diary */,
0A5EA7341DB2B0F500B4665B /* Products */,
);
sourceTree = "";
};
0A5EA7341DB2B0F500B4665B /* Products */ = {
isa = PBXGroup;
children = (
0A5EA7331DB2B0F500B4665B /* Diary.app */,
);
name = Products;
sourceTree = "";
};
0A5EA7351DB2B0F500B4665B /* Diary */ = {
isa = PBXGroup;
children = (
0A5EA7361DB2B0F500B4665B /* AppDelegate.swift */,
0A5EA7481DB2B2E200B4665B /* DiaryLabel.swift */,
0A5EA7381DB2B0F500B4665B /* ViewController.swift */,
0A5EA73A1DB2B0F500B4665B /* Main.storyboard */,
0A5EA74A1DB2B4BA00B4665B /* TpldKhangXiDictTrial.otf */,
0A5EA74B1DB2B4BA00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf */,
0A5EA73D1DB2B0F500B4665B /* Assets.xcassets */,
0A5EA73F1DB2B0F500B4665B /* LaunchScreen.storyboard */,
0A5EA7421DB2B0F500B4665B /* Info.plist */,
);
path = Diary;
sourceTree = "";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
0A5EA7321DB2B0F500B4665B /* Diary */ = {
isa = PBXNativeTarget;
buildConfigurationList = 0A5EA7451DB2B0F500B4665B /* Build configuration list for PBXNativeTarget "Diary" */;
buildPhases = (
0A5EA72F1DB2B0F500B4665B /* Sources */,
0A5EA7301DB2B0F500B4665B /* Frameworks */,
0A5EA7311DB2B0F500B4665B /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = Diary;
productName = Diary;
productReference = 0A5EA7331DB2B0F500B4665B /* Diary.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
0A5EA72B1DB2B0F500B4665B /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0800;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = kevinzhow;
TargetAttributes = {
0A5EA7321DB2B0F500B4665B = {
CreatedOnToolsVersion = 8.0;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 0A5EA72E1DB2B0F500B4665B /* Build configuration list for PBXProject "Diary" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 0A5EA72A1DB2B0F500B4665B;
productRefGroup = 0A5EA7341DB2B0F500B4665B /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
0A5EA7321DB2B0F500B4665B /* Diary */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
0A5EA7311DB2B0F500B4665B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0A5EA7411DB2B0F500B4665B /* LaunchScreen.storyboard in Resources */,
0A5EA73E1DB2B0F500B4665B /* Assets.xcassets in Resources */,
0A5EA73C1DB2B0F500B4665B /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
0A5EA72F1DB2B0F500B4665B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0A5EA7391DB2B0F500B4665B /* ViewController.swift in Sources */,
0A5EA7371DB2B0F500B4665B /* AppDelegate.swift in Sources */,
0A5EA7491DB2B2E200B4665B /* DiaryLabel.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
0A5EA73A1DB2B0F500B4665B /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
0A5EA73B1DB2B0F500B4665B /* Base */,
);
name = Main.storyboard;
sourceTree = "";
};
0A5EA73F1DB2B0F500B4665B /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
0A5EA7401DB2B0F500B4665B /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
0A5EA7431DB2B0F500B4665B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
0A5EA7441DB2B0F500B4665B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
0A5EA7461DB2B0F500B4665B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Diary/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = kevinzhow.Diary;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
};
name = Debug;
};
0A5EA7471DB2B0F500B4665B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Diary/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = kevinzhow.Diary;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
0A5EA72E1DB2B0F500B4665B /* Build configuration list for PBXProject "Diary" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0A5EA7431DB2B0F500B4665B /* Debug */,
0A5EA7441DB2B0F500B4665B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0A5EA7451DB2B0F500B4665B /* Build configuration list for PBXNativeTarget "Diary" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0A5EA7461DB2B0F500B4665B /* Debug */,
0A5EA7471DB2B0F500B4665B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 0A5EA72B1DB2B0F500B4665B /* Project object */;
}
================================================
FILE: Example Codes/Diary/Diary_1/Diary.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
================================================
FILE: Example Codes/Diary/Diary_1/Diary.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
================================================
IDEDidComputeMac32BitWarning
================================================
FILE: Example Codes/Diary/Diary_1/Diary.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/Diary.xcscheme
================================================
================================================
FILE: Example Codes/Diary/Diary_1/Diary.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Diary.xcscheme
orderHint
0
SuppressBuildableAutocreation
0A5EA7321DB2B0F500B4665B
primary
================================================
FILE: Example Codes/Diary/Diary_1/Diary.xcodeproj/xcuserdata/zhoukaiwen.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Diary.xcscheme_^#shared#^_
orderHint
0
================================================
FILE: Example Codes/Diary/Diary_10/Diary/AppDelegate.swift
================================================
//
// AppDelegate.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
// Coredata
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let managedContext = appDelegate.managedObjectContext!
let itemHeight: CGFloat = 150.0
// Cell的高度
let itemWidth: CGFloat = 60
// Cell的宽度
let collectionViewWidth = itemWidth * 3
// 同时显示3个Cell时候
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
lazy var managedObjectModel: NSManagedObjectModel = {
// 描述数据模型描述文件存储位置
let modelURL = Bundle.main.url(forResource: "Diary", withExtension: "momd")!
return NSManagedObjectModel(contentsOf: modelURL)!
}()
lazy var applicationDocumentsDirectory: URL = {
// 数据库文件的存放文件夹
let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
return urls[urls.count-1]
}()
lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator? = {
// 通过 managedObjectModel 创建持久化管理
var coordinator: NSPersistentStoreCoordinator? =
NSPersistentStoreCoordinator(managedObjectModel:
self.managedObjectModel)
let url = self.applicationDocumentsDirectory.appendingPathComponent("Diary.sqlite")
// 设定数据库存储位置
var error: NSError? = nil
var failureReason = "载入程序存储的数据出错."
do {
try coordinator!.addPersistentStore(
ofType: NSSQLiteStoreType, configurationName: nil,
at: url, options: nil)
// 创建NSSQLiteStoreType类型持久化存储
} catch var error1 as NSError {
error = error1
coordinator = nil
// 报告错误
var dict = [String: AnyObject]()
dict[NSLocalizedDescriptionKey] = "无法初始化程序存储的数据" as AnyObject?
dict[NSLocalizedFailureReasonErrorKey] = failureReason as AnyObject?
dict[NSUnderlyingErrorKey] = error
error = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
NSLog("发现错误 \(error), \(error!.userInfo)")
abort()
} catch {
fatalError()
}
return coordinator
}()
lazy var managedObjectContext: NSManagedObjectContext? = {
let coordinator = self.persistentStoreCoordinator
if coordinator == nil {
return nil
}
var managedObjectContext = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
managedObjectContext.persistentStoreCoordinator = coordinator
return managedObjectContext
}()
}
================================================
FILE: Example Codes/Diary/Diary_10/Diary/Assets.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Diary/Diary_10/Diary/Assets.xcassets/Contents.json
================================================
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Diary/Diary_10/Diary/Assets.xcassets/Oval.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"filename" : "Oval.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Oval@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Oval@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Diary/Diary_10/Diary/Assets.xcassets/Oval_pressed.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"filename" : "Oval_pressed.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Oval_pressed@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Oval_pressed@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Diary/Diary_10/Diary/Base.lproj/LaunchScreen.storyboard
================================================
================================================
FILE: Example Codes/Diary/Diary_10/Diary/Base.lproj/Main.storyboard
================================================
================================================
FILE: Example Codes/Diary/Diary_10/Diary/Diary.xcdatamodeld/Diary.xcdatamodel/contents
================================================
================================================
FILE: Example Codes/Diary/Diary_10/Diary/DiaryAnimator.swift
================================================
//
// DiaryAnimator.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class DiaryAnimator: NSObject, UIViewControllerAnimatedTransitioning {
var operation: UINavigationController.Operation!
// 转场时长
func transitionDuration(using transitionContext:
UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.4
}
func animateTransition(using transitionContext:
UIViewControllerContextTransitioning)
{
// 获取转场舞台
let containerView = transitionContext.containerView
let fromVC = transitionContext.viewController(
forKey: UITransitionContextViewControllerKey.from)
// 获取从哪个场景开始转
let fromView = fromVC!.view
let toVC = transitionContext.viewController(
forKey: UITransitionContextViewControllerKey.to)
// 获取要转去哪个场景
let toView = toVC!.view
// 设置新场景透明度
toView?.alpha = 0.0
// UINavigationControllerOperation.Pop用来判断是转入还是转出
if operation == UINavigationController.Operation.pop {
// 如果是返回旧场景,那么设置要转入的场景初始缩放为原始大小
toView?.transform = CGAffineTransform(scaleX: 1.0,y: 1.0)
}else{
// 如果是转到新场景,设置新场景初始缩放为0.3
toView?.transform = CGAffineTransform(scaleX: 0.3,y: 0.3);
}
// 在舞台上插入场景
containerView.insertSubview(toView!, aboveSubview: fromView!)
UIView.animate(
withDuration: transitionDuration(using: transitionContext),
delay: 0,
options: UIView.AnimationOptions.curveEaseInOut,
animations:
{
if self.operation == UINavigationController.Operation.pop {
// 放大要转出的场景
fromView?.transform = CGAffineTransform(scaleX: 3.3,y: 3.3)
} else {
// 设置新场景为原始大小
toView?.transform = CGAffineTransform(scaleX: 1.0,y: 1.0)
}
toView?.alpha = 1.0
}, completion: { finished in
// 通知NavigationController已经完成转场
transitionContext.completeTransition(true)
})
}
}
================================================
FILE: Example Codes/Diary/Diary_10/Diary/DiaryCell.swift
================================================
//
// DiaryCell.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class DiaryCell: UICollectionViewCell {
var textLabel: DiaryLabel!
var textInt: Int = 0
var labelText: String = "" {
didSet {
textLabel.updateText(labelText: labelText)
}
}
override func awakeFromNib() {
super.awakeFromNib()
// 界面载入内存
self.textLabel = DiaryLabel(
fontname: "Wyue-GutiFangsong-NC",
labelText: labelText,
fontSize: 16.0,
lineHeight: 5.0,
color: UIColor.black)
self.contentView.addSubview(textLabel)
}
override func layoutSubviews() {
super.layoutSubviews() // 当对子视图进行布局时
self.textLabel.center = CGPoint(x: itemWidth/2.0, y: 150.0/2.0)
}
}
================================================
FILE: Example Codes/Diary/Diary_10/Diary/DiaryComposeViewController.swift
================================================
//
// DiaryComposeViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
let titleTextViewHeight:CGFloat = 30.0
let contentMargin:CGFloat = 20.0
var defaultFont = "Wyue-GutiFangsong-NC"
let DiaryFont = UIFont(name: defaultFont, size: 18)!
let DiaryLocationFont = UIFont(name: defaultFont, size: 16)!
let DiaryTitleFont = UIFont(name: defaultFont, size: 18)!
class DiaryComposeViewController: UIViewController {
var diary: Diary?
var composeView:UITextView!
var locationTextView:UITextView!
var titleTextView:UITextView!
var finishButton:UIButton!
var keyboardSize:CGSize = CGSize(width: 0, height: 0)
var locationHelper: DiaryLocationHelper = DiaryLocationHelper()
override func viewDidLoad() {
super.viewDidLoad()
// 创建正文输入框
composeView = UITextView(frame: CGRect(x: 0, y: contentMargin + titleTextViewHeight, width: screenSize.width, height: screenSize.height))
composeView.font = DiaryFont
composeView.isEditable = true
composeView.isUserInteractionEnabled = true
composeView.textContainerInset = UIEdgeInsets(top: contentMargin, left: contentMargin, bottom: contentMargin, right: contentMargin)
// 创建地址输入框
locationTextView = UITextView(frame: CGRect(x: 0, y: composeView.frame.size.height - 30.0, width: screenSize.width - 60.0, height: 30.0))
locationTextView.font = DiaryLocationFont
locationTextView.isEditable = true
locationTextView.isUserInteractionEnabled = true
locationTextView.bounces = false
// 创建标题输入框
titleTextView = UITextView(frame: CGRect(x: contentMargin, y: contentMargin/2, width: screenSize.width - 60.0, height: titleTextViewHeight))
titleTextView.font = DiaryTitleFont
titleTextView.isEditable = true
titleTextView.isUserInteractionEnabled = true
titleTextView.bounces = false
self.view.addSubview(composeView)
self.view.addSubview(locationTextView)
self.view.addSubview(titleTextView)
if let diary = diary {
composeView.text = diary.content
locationTextView.text = diary.location
if let title = diary.title {
titleTextView.text = title
}
}
// 创建完成按钮
finishButton = diaryButtonWith(text: "完", fontSize: 18.0, width: 50.0, normalImageName: "Oval", highlightedImageName: "Oval_pressed")
finishButton.center = CGPoint(x: screenSize.width - 20, y: screenSize.height - 30)
self.view.addSubview(finishButton)
self.finishButton.center = CGPoint(x: self.view.frame.width - self.finishButton.frame.size.height/2.0 - 10, y: self.view.frame.height - self.finishButton.frame.size.height/2.0 - 10)
self.finishButton.addTarget(self, action: #selector(finishCompose(_:)), for: UIControl.Event.touchUpInside)
self.locationTextView.center = CGPoint(x: self.locationTextView.frame.size.width/2.0 + 20.0, y: self.finishButton.center.y)
// 监听键盘事件
NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidShow(_:)), name: UIWindow.keyboardDidShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(updateAddress(_:)), name: NSNotification.Name(rawValue: "DiaryLocationUpdated"), object: nil)
}
@objc func finishCompose(_ button: UIButton) {
// 取消输入框的编辑状态,收起键盘
self.composeView.endEditing(true)
self.locationTextView.endEditing(true)
// 确保有文字内容才保存
if (composeView.text.lengthOfBytes(using: String.Encoding.utf8) > 1){
// 如果是修改 Diary,则保存到原日记中
if let diary = diary {
diary.content = composeView.text
diary.location = locationTextView.text
diary.title = titleTextView.text
}else{
let entity = NSEntityDescription.entity(forEntityName: "Diary", in: managedContext)
let newdiary = Diary(entity: entity!,
insertInto:managedContext)
newdiary.content = composeView.text
if let address = locationHelper.address {
newdiary.location = address
}
if let title = titleTextView.text {
newdiary.title = title
}
newdiary.updateTimeWithDate(Date())
}
do {
try managedContext.save()
} catch let error as NSError {
print("Could not save \(error.description)")
}
}
self.dismiss(animated: true, completion: nil)
}
@objc func updateAddress(_ notification: Notification) {
if let address = notification.object as? String {
locationTextView.text = "于 \(address)"
locationHelper.locationManager.stopUpdatingLocation()
}
}
@objc func keyboardDidShow(_ notification: Notification) {
// 取出键盘的高度
if let rectValue = (notification as NSNotification).userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue {
keyboardSize = rectValue.cgRectValue.size
//更新完成按钮和地址输入框的位置
updateTextViewSizeForKeyboardHeight(keyboardSize.height)
}
}
func updateTextViewSizeForKeyboardHeight(_ keyboardHeight: CGFloat) {
let newKeyboardHeight = keyboardHeight
UIView.animate(withDuration: 1.0, delay: 0, options: UIView.AnimationOptions(), animations:
{
if (self.locationTextView.text == nil) {
self.composeView.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height - newKeyboardHeight)
}else{
self.composeView.frame = CGRect(x: 0, y: contentMargin + titleTextViewHeight, width: self.composeView.frame.size.width, height: self.view.frame.height - newKeyboardHeight - 40.0 - self.finishButton.frame.size.height/2.0 - (contentMargin + titleTextViewHeight))
}
self.finishButton.center = CGPoint(x: self.view.frame.width - self.finishButton.frame.size.height/2.0 - 10, y: self.view.frame.height - newKeyboardHeight - self.finishButton.frame.size.height/2.0 - 10)
self.locationTextView.center = CGPoint(x: self.locationTextView.frame.size.width/2.0 + 20.0, y: self.finishButton.center.y)
}, completion: nil)
}
}
================================================
FILE: Example Codes/Diary/Diary_10/Diary/DiaryLabel.swift
================================================
//
// DiaryLabel.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
func sizeHeightWithText(labelText: String,
fontSize: CGFloat,
textAttributes: [NSAttributedString.Key: AnyObject]) -> CGRect {
return labelText.boundingRect(
with: CGSize(width:fontSize, height:480),
options: NSStringDrawingOptions.usesLineFragmentOrigin,
attributes: textAttributes, context: nil)
}
class DiaryLabel: UILabel {
var textAttributes: [NSAttributedString.Key: AnyObject]!
convenience init(fontname:String,
labelText:String,
fontSize : CGFloat,
lineHeight: CGFloat,
color: UIColor){
self.init(frame: CGRect(x:0, y:0, width:0, height:0))
let font = UIFont(name: fontname,
size: fontSize)
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = lineHeight
textAttributes = [NSAttributedString.Key.font: font!,
NSAttributedString.Key.foregroundColor: color,
NSAttributedString.Key.paragraphStyle: paragraphStyle]
let labelSize = sizeHeightWithText(labelText: labelText,
fontSize: fontSize ,
textAttributes: textAttributes)
self.frame = CGRect(x: 0, y: 0, width: labelSize.width,
height: labelSize.height)
self.attributedText = NSAttributedString(
string: labelText,
attributes: textAttributes)
self.lineBreakMode = NSLineBreakMode.byCharWrapping
self.numberOfLines = 0
}
func updateText(labelText: String) {
let labelSize = sizeHeightWithText(labelText: labelText,
fontSize: self.font.pointSize,
textAttributes: textAttributes)
self.frame = CGRect(x:0,y: 0, width:labelSize.width,
height:labelSize.height)
self.attributedText = NSAttributedString(
string: labelText,
attributes: textAttributes)
}
}
================================================
FILE: Example Codes/Diary/Diary_10/Diary/DiaryLayout.swift
================================================
//
// DiaryLayout.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
let screenSize = UIWindow().screen.bounds
class DiaryLayout: UICollectionViewFlowLayout {
override func prepare() {
super.prepare() //准备布局
// Cell 大小
let itemSize = CGSize(width: itemWidth,height: itemHeight)
self.itemSize = itemSize
// Cell 左右间距
self.minimumInteritemSpacing = 0.0
// Cell 行间距
self.minimumLineSpacing = 0
// 增加内嵌
self.sectionInset = UIEdgeInsets(top: (screenSize.height/2.0) - (itemHeight/2.0), left: (screenSize.width/2.0) - (itemWidth/2.0), bottom: (screenSize.height/2.0) - (itemHeight/2.0), right: (screenSize.height/2.0) - (itemHeight/2.0))
// 滚动方向
scrollDirection = UICollectionView.ScrollDirection.horizontal
}
}
================================================
FILE: Example Codes/Diary/Diary_10/Diary/DiaryLocationHelper.swift
================================================
//
// DiaryLocationHelper.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import CoreLocation
class DiaryLocationHelper: NSObject, CLLocationManagerDelegate {
var locationManager:CLLocationManager = CLLocationManager()
var currentLocation:CLLocation?
var address:String?
var geocoder = CLGeocoder()
override init() {
super.init()
// 设置委托
locationManager.delegate = self
// 请求位置授权
locationManager.requestWhenInUseAuthorization()
if (CLLocationManager.locationServicesEnabled()){
//开始获取位置
locationManager.startUpdatingLocation()
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
// 根据经纬度查询位置名称
geocoder.reverseGeocodeLocation(locations[0], completionHandler: { (placemarks, error) in
if let error = error {
print("查询失败: \(error.localizedDescription)")
}
// placemarks里包括了位置的国家、省份、地区等信息
if let pm = placemarks {
if pm.count > 0 {
let placemark = pm.first
self.address = placemark?.locality
// 广播位置信息
NotificationCenter.default.post(name: Notification.Name(rawValue: "DiaryLocationUpdated"), object: self.address)
}
}
})
}
}
================================================
FILE: Example Codes/Diary/Diary_10/Diary/DiaryMonthCollectionViewController.swift
================================================
//
// DiaryMonthCollectionViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
let DiaryRed = UIColor(red: 192.0/255.0, green: 23/255.0, blue: 48.0/255.0, alpha: 1)
class DiaryMonthCollectionViewController: UICollectionViewController {
var year: Int!
var month: Int!
var yearLabel: DiaryLabel!
var monthLabel: DiaryLabel!
var fetchedResultsController : NSFetchedResultsController!
var diarys = [Diary]()
override func viewDidLoad() {
super.viewDidLoad()
let layout = DiaryLayout()
layout.scrollDirection = UICollectionView.ScrollDirection.horizontal
self.collectionView?.setCollectionViewLayout(layout, animated: false)
yearLabel = DiaryLabel(
fontname: "TpldKhangXiDictTrial",
labelText: "二零一五年",
fontSize: 16.0,
lineHeight: 5.0,
color: UIColor.black)
yearLabel.frame = CGRect(x: screenSize.width - yearLabel.frame.size.width - 20, y: 20, width: yearLabel.frame.size.width, height: yearLabel.frame.size.height)
self.view.addSubview(yearLabel)
monthLabel = DiaryLabel(
fontname: "Wyue-GutiFangsong-NC",
labelText: "三月",
fontSize: 16.0,
lineHeight: 5.0,
color: DiaryRed)
monthLabel.frame = CGRect(x: screenSize.width - monthLabel.frame.size.width - 20, y: screenSize.height/2.0 - monthLabel.frame.size.height/2.0, width: monthLabel.frame.size.width, height: monthLabel.frame.size.height)
self.view.addSubview(monthLabel)
// 添加按钮
let composeButton = diaryButtonWith(text: "撰",
fontSize: 14.0,
width: 40.0,
normalImageName: "Oval",
highlightedImageName: "Oval_pressed")
composeButton.center = CGPoint(x: yearLabel.center.x,
y: 38 + yearLabel.frame.size.height + 26.0/2.0)
composeButton.addTarget(self, action: #selector(newCompose),
for: UIControl.Event.touchUpInside)
self.view.addSubview(composeButton)
// 查询数据
do {
// 新建查询
let fetchRequest = NSFetchRequest(entityName:"Diary")
// 增加过滤条件
fetchRequest.predicate = NSPredicate(format:"year = \(year!) AND month = \(month!)")
// 排序方式
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "created_at", ascending: true)]
fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest,
managedObjectContext: managedContext, sectionNameKeyPath: nil,
cacheName: nil)
// 建立委托关系
fetchedResultsController.delegate = self
// 尝试查询
try self.fetchedResultsController.performFetch()
if (fetchedResultsController.fetchedObjects!.count == 0){
print("没有存储结果")
}else{
diarys = fetchedResultsController.fetchedObjects!
}
} catch let error as NSError {
NSLog("发现错误 \(error.localizedDescription)")
}
}
@objc func newCompose() {
let identifier = "DiaryComposeViewController"
let composeViewController = self.storyboard?.instantiateViewController(withIdentifier: identifier)
as! DiaryComposeViewController
self.present(composeViewController,
animated: true,
completion: nil)
}
override func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return diarys.count
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let identifier = "DiaryCell"
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as! DiaryCell
let diary = diarys[indexPath.row]
cell.labelText = diary.title!
return cell
}
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let dvc = self.storyboard?.instantiateViewController(withIdentifier: "DiaryViewController") as! DiaryViewController
dvc.diary = diarys[indexPath.row]
self.navigationController!.pushViewController(dvc, animated: true)
}
}
extension DiaryMonthCollectionViewController: NSFetchedResultsControllerDelegate {
// 响应数据变化
func controller(_ controller: NSFetchedResultsController, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
// 重置数据源
diarys = controller.fetchedObjects! as! [Diary]
// 重载数据
self.collectionView?.reloadData()
// 更新布局
self.collectionView?.setCollectionViewLayout(DiaryLayout(), animated: false)
}
}
================================================
FILE: Example Codes/Diary/Diary_10/Diary/DiaryTemplate.html
================================================
================================================
FILE: Example Codes/Diary/Diary_10/Diary/DiaryViewController.swift
================================================
//
// DiaryViewController.swift
// Diary
//
// Created by kevinzhow on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class DiaryViewController: UIViewController {
var diary:Diary!
var webview: UIWebView!
var saveButton:UIButton!
var deleteButton:UIButton!
var editButton:UIButton!
var buttonsView:UIView!
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
showButtons()
}
func setupUI() {
webview = UIWebView(frame: CGRect(x: 0,y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height))
webview.scrollView.bounces = true
webview.backgroundColor = UIColor.white
self.view.addSubview(self.webview)
// 读取模板的内容
let mainHTML = Bundle.main.url(forResource: "DiaryTemplate", withExtension:"html")
var contents: NSString = ""
do {
contents = try NSString(contentsOfFile: mainHTML!.path, encoding: String.Encoding.utf8.rawValue)
} catch let error as NSError {
print(error)
}
// 生成年的整数类型
let year = (Calendar.current as NSCalendar).component(NSCalendar.Unit.year, from: diary.created_at!)
// 生成月的整数类型
let month = (Calendar.current as NSCalendar).component(NSCalendar.Unit.month, from: diary.created_at!)
// 生成日的整数类型
let day = (Calendar.current as NSCalendar).component(NSCalendar.Unit.day, from: diary.created_at!)
let timeString = "\(numberToChinese(year))年 \(numberToChineseWithUnit(month))月 \(numberToChineseWithUnit(day))日"
// 替换字符串
contents = contents.replacingOccurrences(of: "#timeString#", with: timeString) as NSString
let newDiaryString = diary.content?.replacingOccurrences(of: "\n", with: "
", options: NSString.CompareOptions.literal, range: nil)
contents = contents.replacingOccurrences(of: "#newDiaryString#", with: newDiaryString!) as NSString
var title = ""
var contentWidthOffset = 140
var contentMargin:CGFloat = 10
if let titleStr = diary?.title {
let parsedTime = "\(numberToChineseWithUnit((Calendar.current as NSCalendar).component(NSCalendar.Unit.day, from: diary.created_at!))) 日"
if titleStr != parsedTime {
title = titleStr
contentWidthOffset = 205
contentMargin = 10
title = "\(title)
"
}
}
contents = contents.replacingOccurrences(of: "#contentMargin#", with: "\(contentMargin)") as NSString
contents = contents.replacingOccurrences(of: "#title#", with: title) as NSString
let minWidth = self.view.frame.size.width - CGFloat(contentWidthOffset)
contents = contents.replacingOccurrences(of: "#minWidth#", with: "\(minWidth)") as NSString
let fontStr = defaultFont
contents = contents.replacingOccurrences(of: "#fontStr#", with: fontStr) as NSString
let titleMarginRight:CGFloat = 15
contents = contents.replacingOccurrences(of: "#titleMarginRight#", with: "\(titleMarginRight)") as NSString
if let location = diary.location {
contents = contents.replacingOccurrences(of: "#location#", with: location) as NSString
} else {
contents = contents.replacingOccurrences(of: "#location#", with: "") as NSString
}
webview.loadHTMLString(contents as String, baseURL: nil)
// 添加存改删按钮
buttonsView = UIView(frame: CGRect(x: 0, y: screenSize.height, width: screenSize.width, height: 80.0))
buttonsView.backgroundColor = UIColor.clear
buttonsView.alpha = 0.0
let buttonFontSize:CGFloat = 18.0
saveButton = diaryButtonWith(text: "存", fontSize: buttonFontSize, width: 50.0, normalImageName: "Oval", highlightedImageName: "Oval_pressed")
saveButton.center = CGPoint(x: buttonsView.frame.width/2.0, y: buttonsView.frame.height/2.0)
saveButton.addTarget(self, action: #selector(saveToRoll), for: UIControl.Event.touchUpInside)
buttonsView.addSubview(saveButton)
editButton = diaryButtonWith(text: "改", fontSize: buttonFontSize, width: 50.0, normalImageName: "Oval", highlightedImageName: "Oval_pressed")
editButton.center = CGPoint(x: saveButton.center.x - 56.0, y: saveButton.center.y)
editButton.addTarget(self, action: #selector(editDiary), for: UIControl.Event.touchUpInside)
buttonsView.addSubview(editButton)
deleteButton = diaryButtonWith(text: "刪", fontSize: buttonFontSize, width: 50.0, normalImageName: "Oval", highlightedImageName: "Oval_pressed")
deleteButton.center = CGPoint(x: saveButton.center.x + 56.0, y: saveButton.center.y)
deleteButton.addTarget(self, action: #selector(deleteThisDiary), for: UIControl.Event.touchUpInside)
buttonsView.addSubview(deleteButton)
self.view.addSubview(buttonsView)
// 切换按钮的显示状态
let mTapUpRecognizer = UITapGestureRecognizer(target: self, action: #selector(showButtons))
mTapUpRecognizer.numberOfTapsRequired = 1
mTapUpRecognizer.delegate = self
self.webview.addGestureRecognizer(mTapUpRecognizer)
}
@objc func showButtons() {
if(buttonsView.alpha == 0.0) {
UIView.animate(withDuration: 0.2, delay: 0, options: UIView.AnimationOptions(), animations:
{
self.buttonsView.center = CGPoint(x: self.buttonsView.center.x, y: screenSize.height - self.buttonsView.frame.size.height/2.0)
self.buttonsView.alpha = 1.0
}, completion: nil)
}else{
UIView.animate(withDuration: 0.1, delay: 0, options: UIView.AnimationOptions(), animations:
{
self.buttonsView.center = CGPoint(x: self.buttonsView.center.x, y: screenSize.height + self.buttonsView.frame.size.height/2.0)
self.buttonsView.alpha = 0.0
}, completion: nil)
}
}
@objc func editDiary() {
let composeViewController = self.storyboard?.instantiateViewController(withIdentifier: "DiaryComposeViewController") as! DiaryComposeViewController
if let diary = diary {
composeViewController.diary = diary
}
self.present(composeViewController, animated: true, completion: nil)
}
@objc func saveToRoll() {
let offset = self.webview.scrollView.contentOffset.x
// 针对 WebView 截图
let image = webview.captureView()
self.webview.scrollView.contentOffset.x = offset
// 创建分享对象
var sharingItems = [AnyObject]()
// 给分享对象插入图片
sharingItems.append(image)
// 初始化分享组件
let activityViewController = UIActivityViewController(activityItems: sharingItems, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.saveButton
// 现实分享组件
self.present(activityViewController, animated: true, completion: nil)
}
@objc func deleteThisDiary() {
managedContext.delete(diary)
do {
try managedContext.save()
} catch _ {
}
hideDiary()
}
func hideDiary() {
self.navigationController?.popViewController(animated: true)
}
}
extension DiaryViewController: UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailBy otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
}
================================================
FILE: Example Codes/Diary/Diary_10/Diary/DiaryYearCollectionViewController.swift
================================================
//
// DiaryYearCollectionViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
class DiaryYearCollectionViewController: UICollectionViewController {
var year: Int!
var diarys = [Diary]()
var fetchedResultsController : NSFetchedResultsController!
var monthCount: Int = 1
var sectionsCount: Int = 0
override func viewDidLoad() {
super.viewDidLoad()
let layout = DiaryLayout()
layout.scrollDirection = UICollectionView.ScrollDirection.horizontal
self.collectionView?.setCollectionViewLayout(layout, animated: false)
do {
// 新建查询
let fetchRequest = NSFetchRequest(entityName:"Diary")
// 增加过滤条件
fetchRequest.predicate = NSPredicate(format:"year = \(year!)")
// 排序方式
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "created_at", ascending: true)]
fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest,
managedObjectContext: managedContext, sectionNameKeyPath: "month",
cacheName: nil)
// 尝试查询
try self.fetchedResultsController.performFetch()
if (fetchedResultsController.fetchedObjects!.count == 0){
print("没有存储结果")
}else{
if let sectionsCount = fetchedResultsController.sections?.count {
monthCount = sectionsCount
diarys = fetchedResultsController.fetchedObjects!
}else {
sectionsCount = 0
monthCount = 1
}
}
} catch let error as NSError {
NSLog("发现错误 \(error.localizedDescription)")
}
}
override func numberOfSections(in collectionView: UICollectionView) -> Int {
return monthCount
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 1
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let identifier = "DiaryCell"
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as! DiaryCell
// 获取当前月份
let components = Calendar.current.component(Calendar.Component.month, from: Date())
var month = components
if sectionsCount > 0 {
// 如果程序内有保存的日记,就使用保存的日记的月份
let sectionInfo = fetchedResultsController.sections![indexPath.section]
print("分组信息 \(sectionInfo.name)")
month = Int(sectionInfo.name)!
}
cell.textInt = month
cell.labelText = "\(numberToChinese(cell.textInt)) 月"
// Configure the cell
return cell
}
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
//super.collectionView(collectionView, didSelectItemAt: indexPath as IndexPath)
let identifier = "DiaryMonthCollectionViewController"
let dvc = self.storyboard?.instantiateViewController(withIdentifier: identifier) as! DiaryMonthCollectionViewController // 获取 DiaryMonthCollectionViewController
// 获取当前月份
let components = Calendar.current.component(Calendar.Component.month, from: Date())
var month = components
if sectionsCount > 0 {
// 如果程序内有保存的日记,就使用保存的日记的月份
let sectionInfo = fetchedResultsController.sections![indexPath.section]
print("分组信息 \(sectionInfo.name)")
month = Int(sectionInfo.name)!
}
// 指定是 2015 年的 1 月份
dvc.month = month
dvc.year = year
// 页面跳转
self.navigationController!.pushViewController(dvc, animated: true)
}
}
================================================
FILE: Example Codes/Diary/Diary_10/Diary/Helper.swift
================================================
//
// Helper.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
extension Diary {
func updateTimeWithDate(_ date: Date){
self.created_at = date
self.year = Int32(Calendar.current.component(Calendar.Component.year, from: date))
self.month = Int32(Calendar.current.component(Calendar.Component.month, from: date))
}
}
extension UIWebView {
func captureView() -> UIImage{
// 存储初始大小
let tmpFrame = self.frame
// 新的 Frame
var aFrame = self.frame
aFrame.size.width = self.sizeThatFits(UIScreen.main.bounds.size).width
// 展开 Frame
self.frame = aFrame
// 初始化 ImageContext
UIGraphicsBeginImageContextWithOptions(
self.sizeThatFits(UIScreen.main.bounds.size),
false,
UIScreen.main.scale)
// 创建新的 Context
let resizedContext = UIGraphicsGetCurrentContext()
self.layer.render(in: resizedContext!)
// 重新渲染到新的 resizedContext
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
// 还原 Frame
self.frame = tmpFrame
return image!
}
}
func diaryButtonWith(text: String,
fontSize: CGFloat,
width: CGFloat,
normalImageName: String,
highlightedImageName: String) -> UIButton {
// 创建自定义按钮
let button = UIButton(type: UIButton.ButtonType.custom)
// 设定按钮的大小
button.frame = CGRect(x: 0, y: 0, width: width, height: width)
let font = UIFont(name: "Wyue-GutiFangsong-NC", size: fontSize)
let textAttributes: [NSAttributedString.Key: AnyObject] = [
NSAttributedString.Key.font: font!,
NSAttributedString.Key.foregroundColor: UIColor.white]
// 设置按钮的字体
let attributedText = NSAttributedString(string: text, attributes: textAttributes)
button.setAttributedTitle(attributedText, for: UIControl.State.normal)
// 设置默认按钮的样式
button.setBackgroundImage(UIImage(
named: normalImageName),
for: UIControl.State.normal)
// 设置按钮被按下时的样式
button.setBackgroundImage(UIImage(
named: highlightedImageName),
for: UIControl.State.highlighted)
return button
}
func singleNumberToChinese(_ number:Character) -> String {
switch number {
case "0":
return "零"
case "1":
return "一"
case "2":
return "二"
case "3":
return "三"
case "4":
return "四"
case "5":
return "五"
case "6":
return "六"
case "7":
return "七"
case "8":
return "八"
case "9":
return "九"
default:
return ""
}
}
func numberToChinese(_ number:Int) -> String {
let numbers = String(number)
var finalString = ""
for singleNumber in numbers {
let string = singleNumberToChinese(singleNumber)
finalString = "\(finalString)\(string)"
}
return finalString
}
func numberToChineseWithUnit(_ number:Int) -> String {
let numbers = String(number)
var units = unitParser(numbers.count)
var finalString = ""
for (index, singleNumber) in numbers.enumerated() {
let string = singleNumberToChinese(singleNumber)
if (!(string == "零" && (index+1) == numbers.count)){
finalString = "\(finalString)\(string)\(units[index])"
}
}
return finalString
}
func unitParser(_ unit:Int) -> [String] {
var units = Array(["万","千","百","十",""].reversed())
let parsedUnits = units[0..<(unit)].reversed()
let slicedUnits: ArraySlice = ArraySlice(parsedUnits)
let final: [String] = Array(slicedUnits)
return final
}
================================================
FILE: Example Codes/Diary/Diary_10/Diary/HomeCollectionViewController.swift
================================================
//
// HomeCollectionViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
class HomeCollectionViewController: UICollectionViewController {
var diarys = [Diary]()
var fetchedResultsController : NSFetchedResultsController!
var yearsCount: Int = 1
var sectionsCount: Int = 0
override func viewDidLoad() {
super.viewDidLoad()
let yearLayout = DiaryLayout()
yearLayout.scrollDirection = UICollectionView.ScrollDirection.horizontal
self.collectionView?.setCollectionViewLayout(yearLayout, animated: false)
self.navigationController!.delegate = self
do {
// 新建查询
let fetchRequest = NSFetchRequest(entityName:"Diary")
// 排序方式
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "created_at", ascending: true)]
fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest,
managedObjectContext: managedContext, sectionNameKeyPath: "year",
cacheName: nil)
// 尝试查询
try self.fetchedResultsController.performFetch()
if (fetchedResultsController.fetchedObjects!.count == 0){
print("没有存储结果")
}else{
if let sectionsCount = fetchedResultsController.sections?.count {
yearsCount = sectionsCount
diarys = fetchedResultsController.fetchedObjects!
}else {
sectionsCount = 0
yearsCount = 1
}
}
} catch let error as NSError {
NSLog("发现错误 \(error.localizedDescription)")
}
}
override func numberOfSections(in collectionView: UICollectionView) -> Int {
return yearsCount
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 1
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let identifier = "HomeYearCollectionViewCell"
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as! HomeYearCollectionViewCell
// 获取当前月份
let components = Calendar.current.component(Calendar.Component.year, from: Date())
var year = components
if sectionsCount > 0 {
// 如果程序内有保存的日记,就使用保存的日记的年份
let sectionInfo = fetchedResultsController.sections![indexPath.section]
print("分组信息 \(sectionInfo.name)")
year = Int(sectionInfo.name)!
}
cell.textInt = year
cell.labelText = "\(numberToChinese(cell.textInt)) 年"
// Configure the cell
return cell
}
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
//super.collectionView(collectionView, didSelectItemAt: indexPath as IndexPath)
let identifier = "DiaryYearCollectionViewController"
let dvc = self.storyboard?.instantiateViewController(withIdentifier: identifier) as! DiaryYearCollectionViewController // 获取 DiaryYearCollectionViewController
let components = Calendar.current.component(Calendar.Component.year, from: Date())
var year = components
if sectionsCount > 0 {
let sectionInfo = fetchedResultsController.sections![(indexPath as NSIndexPath).row]
print("Section info \(sectionInfo.name)")
year = Int(sectionInfo.name)!
}
dvc.year = year
self.navigationController!.pushViewController(dvc, animated: true)
}
}
extension HomeCollectionViewController: UINavigationControllerDelegate {
func navigationController(_ navigationController:
UINavigationController,
animationControllerFor operation:
UINavigationController.Operation,
from fromVC: UIViewController,
to toVC: UIViewController) ->
UIViewControllerAnimatedTransitioning? {
let animator = DiaryAnimator()
animator.operation = operation
return animator
}
}
================================================
FILE: Example Codes/Diary/Diary_10/Diary/HomeYearCollectionViewCell.swift
================================================
//
// HomeYearCollectionViewCell.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class HomeYearCollectionViewCell: UICollectionViewCell {
var textLabel: DiaryLabel!
var textInt: Int = 0
var labelText: String = "" {
didSet {
textLabel.updateText(labelText: labelText)
}
}
override func awakeFromNib() {
super.awakeFromNib()
// 界面载入内存
self.textLabel = DiaryLabel(
fontname: "TpldKhangXiDictTrial",
labelText: labelText,
fontSize: 16.0,
lineHeight: 5.0,
color: UIColor.black)
self.contentView.addSubview(textLabel)
}
override func layoutSubviews() {
super.layoutSubviews() // 当对子视图进行布局时
self.textLabel.center = CGPoint(x: itemWidth/2.0, y: 150.0/2.0)
}
}
================================================
FILE: Example Codes/Diary/Diary_10/Diary/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
CFBundleVersion
1
LSRequiresIPhoneOS
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
Main
UIRequiredDeviceCapabilities
armv7
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
UIAppFonts
Wyue-GutiFangsong-NC_deliverable.otf
TpldKhangXiDictTrial.otf
NSLocationWhenInUseUsageDescription
在撰写日志的时候自动添加位置
UISupportedInterfaceOrientations~ipad
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
================================================
FILE: Example Codes/Diary/Diary_10/Diary/ViewController.swift
================================================
//
// ViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
================================================
FILE: Example Codes/Diary/Diary_10/Diary/Wyue-GutiFangsong-NC_deliverable.otf
================================================
[File too large to display: 21.5 MB]
================================================
FILE: Example Codes/Diary/Diary_10/Diary.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
0A5EA7371DB2B0F500B4665B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7361DB2B0F500B4665B /* AppDelegate.swift */; };
0A5EA7391DB2B0F500B4665B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7381DB2B0F500B4665B /* ViewController.swift */; };
0A5EA73C1DB2B0F500B4665B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA73A1DB2B0F500B4665B /* Main.storyboard */; };
0A5EA73E1DB2B0F500B4665B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA73D1DB2B0F500B4665B /* Assets.xcassets */; };
0A5EA7411DB2B0F500B4665B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA73F1DB2B0F500B4665B /* LaunchScreen.storyboard */; };
0A5EA7491DB2B2E200B4665B /* DiaryLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7481DB2B2E200B4665B /* DiaryLabel.swift */; };
0A5EA74F1DB2B81900B4665B /* HomeCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA74E1DB2B81900B4665B /* HomeCollectionViewController.swift */; };
0A5EA7511DB2B98D00B4665B /* HomeYearCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7501DB2B98D00B4665B /* HomeYearCollectionViewCell.swift */; };
0A5EA7551DB2BD1700B4665B /* DiaryLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7541DB2BD1700B4665B /* DiaryLayout.swift */; };
0A5EA75A1DB2C29800B4665B /* TpldKhangXiDictTrial.otf in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA74A1DB2B4BA00B4665B /* TpldKhangXiDictTrial.otf */; };
0A5EA75B1DB2C29B00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA74B1DB2B4BA00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf */; };
0A5EA75D1DB2E5E400B4665B /* DiaryYearCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA75C1DB2E5E400B4665B /* DiaryYearCollectionViewController.swift */; };
0A5EA75F1DB2E9BF00B4665B /* DiaryCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA75E1DB2E9BF00B4665B /* DiaryCell.swift */; };
0A5EA7611DB2EDDC00B4665B /* Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7601DB2EDDC00B4665B /* Helper.swift */; };
0A5EA7631DB2EF3E00B4665B /* DiaryMonthCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7621DB2EF3E00B4665B /* DiaryMonthCollectionViewController.swift */; };
0A5EA7651DB2F82E00B4665B /* DiaryAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7641DB2F82E00B4665B /* DiaryAnimator.swift */; };
0A5EA7671DB30D2000B4665B /* DiaryComposeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7661DB30D2000B4665B /* DiaryComposeViewController.swift */; };
0A5EA7691DB3131E00B4665B /* DiaryLocationHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7681DB3131E00B4665B /* DiaryLocationHelper.swift */; };
0A5EA76F1DB31A8500B4665B /* Diary.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA76D1DB31A8500B4665B /* Diary.xcdatamodeld */; };
9F74CDB71DB3A69300DD10E3 /* DiaryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F74CDB61DB3A69300DD10E3 /* DiaryViewController.swift */; };
9F74CDB91DB3A80700DD10E3 /* DiaryTemplate.html in Resources */ = {isa = PBXBuildFile; fileRef = 9F74CDB81DB3A80700DD10E3 /* DiaryTemplate.html */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
0A5EA7331DB2B0F500B4665B /* Diary.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Diary.app; sourceTree = BUILT_PRODUCTS_DIR; };
0A5EA7361DB2B0F500B4665B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
0A5EA7381DB2B0F500B4665B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
0A5EA73B1DB2B0F500B4665B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
0A5EA73D1DB2B0F500B4665B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
0A5EA7401DB2B0F500B4665B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
0A5EA7421DB2B0F500B4665B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
0A5EA7481DB2B2E200B4665B /* DiaryLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryLabel.swift; sourceTree = ""; };
0A5EA74A1DB2B4BA00B4665B /* TpldKhangXiDictTrial.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = TpldKhangXiDictTrial.otf; sourceTree = ""; };
0A5EA74B1DB2B4BA00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Wyue-GutiFangsong-NC_deliverable.otf"; sourceTree = ""; };
0A5EA74E1DB2B81900B4665B /* HomeCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeCollectionViewController.swift; sourceTree = ""; };
0A5EA7501DB2B98D00B4665B /* HomeYearCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeYearCollectionViewCell.swift; sourceTree = ""; };
0A5EA7541DB2BD1700B4665B /* DiaryLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryLayout.swift; sourceTree = ""; };
0A5EA75C1DB2E5E400B4665B /* DiaryYearCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryYearCollectionViewController.swift; sourceTree = ""; };
0A5EA75E1DB2E9BF00B4665B /* DiaryCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryCell.swift; sourceTree = ""; };
0A5EA7601DB2EDDC00B4665B /* Helper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Helper.swift; sourceTree = ""; };
0A5EA7621DB2EF3E00B4665B /* DiaryMonthCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryMonthCollectionViewController.swift; sourceTree = ""; };
0A5EA7641DB2F82E00B4665B /* DiaryAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryAnimator.swift; sourceTree = ""; };
0A5EA7661DB30D2000B4665B /* DiaryComposeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryComposeViewController.swift; sourceTree = ""; };
0A5EA7681DB3131E00B4665B /* DiaryLocationHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryLocationHelper.swift; sourceTree = ""; };
0A5EA76E1DB31A8500B4665B /* Diary.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Diary.xcdatamodel; sourceTree = ""; };
9F74CDB61DB3A69300DD10E3 /* DiaryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryViewController.swift; sourceTree = ""; };
9F74CDB81DB3A80700DD10E3 /* DiaryTemplate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DiaryTemplate.html; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
0A5EA7301DB2B0F500B4665B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
0A5EA72A1DB2B0F500B4665B = {
isa = PBXGroup;
children = (
0A5EA7351DB2B0F500B4665B /* Diary */,
0A5EA7341DB2B0F500B4665B /* Products */,
);
sourceTree = "";
};
0A5EA7341DB2B0F500B4665B /* Products */ = {
isa = PBXGroup;
children = (
0A5EA7331DB2B0F500B4665B /* Diary.app */,
);
name = Products;
sourceTree = "";
};
0A5EA7351DB2B0F500B4665B /* Diary */ = {
isa = PBXGroup;
children = (
9F74CDB81DB3A80700DD10E3 /* DiaryTemplate.html */,
9F74CDB61DB3A69300DD10E3 /* DiaryViewController.swift */,
0A5EA76D1DB31A8500B4665B /* Diary.xcdatamodeld */,
0A5EA7681DB3131E00B4665B /* DiaryLocationHelper.swift */,
0A5EA7661DB30D2000B4665B /* DiaryComposeViewController.swift */,
0A5EA7641DB2F82E00B4665B /* DiaryAnimator.swift */,
0A5EA7601DB2EDDC00B4665B /* Helper.swift */,
0A5EA7541DB2BD1700B4665B /* DiaryLayout.swift */,
0A5EA74E1DB2B81900B4665B /* HomeCollectionViewController.swift */,
0A5EA75C1DB2E5E400B4665B /* DiaryYearCollectionViewController.swift */,
0A5EA7621DB2EF3E00B4665B /* DiaryMonthCollectionViewController.swift */,
0A5EA75E1DB2E9BF00B4665B /* DiaryCell.swift */,
0A5EA7501DB2B98D00B4665B /* HomeYearCollectionViewCell.swift */,
0A5EA7361DB2B0F500B4665B /* AppDelegate.swift */,
0A5EA7481DB2B2E200B4665B /* DiaryLabel.swift */,
0A5EA7381DB2B0F500B4665B /* ViewController.swift */,
0A5EA73A1DB2B0F500B4665B /* Main.storyboard */,
0A5EA74A1DB2B4BA00B4665B /* TpldKhangXiDictTrial.otf */,
0A5EA74B1DB2B4BA00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf */,
0A5EA73D1DB2B0F500B4665B /* Assets.xcassets */,
0A5EA73F1DB2B0F500B4665B /* LaunchScreen.storyboard */,
0A5EA7421DB2B0F500B4665B /* Info.plist */,
);
path = Diary;
sourceTree = "";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
0A5EA7321DB2B0F500B4665B /* Diary */ = {
isa = PBXNativeTarget;
buildConfigurationList = 0A5EA7451DB2B0F500B4665B /* Build configuration list for PBXNativeTarget "Diary" */;
buildPhases = (
0A5EA72F1DB2B0F500B4665B /* Sources */,
0A5EA7301DB2B0F500B4665B /* Frameworks */,
0A5EA7311DB2B0F500B4665B /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = Diary;
productName = Diary;
productReference = 0A5EA7331DB2B0F500B4665B /* Diary.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
0A5EA72B1DB2B0F500B4665B /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0800;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = kevinzhow;
TargetAttributes = {
0A5EA7321DB2B0F500B4665B = {
CreatedOnToolsVersion = 8.0;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 0A5EA72E1DB2B0F500B4665B /* Build configuration list for PBXProject "Diary" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 0A5EA72A1DB2B0F500B4665B;
productRefGroup = 0A5EA7341DB2B0F500B4665B /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
0A5EA7321DB2B0F500B4665B /* Diary */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
0A5EA7311DB2B0F500B4665B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0A5EA7411DB2B0F500B4665B /* LaunchScreen.storyboard in Resources */,
0A5EA75A1DB2C29800B4665B /* TpldKhangXiDictTrial.otf in Resources */,
9F74CDB91DB3A80700DD10E3 /* DiaryTemplate.html in Resources */,
0A5EA73E1DB2B0F500B4665B /* Assets.xcassets in Resources */,
0A5EA73C1DB2B0F500B4665B /* Main.storyboard in Resources */,
0A5EA75B1DB2C29B00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
0A5EA72F1DB2B0F500B4665B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0A5EA7391DB2B0F500B4665B /* ViewController.swift in Sources */,
0A5EA75D1DB2E5E400B4665B /* DiaryYearCollectionViewController.swift in Sources */,
0A5EA74F1DB2B81900B4665B /* HomeCollectionViewController.swift in Sources */,
0A5EA7691DB3131E00B4665B /* DiaryLocationHelper.swift in Sources */,
0A5EA7631DB2EF3E00B4665B /* DiaryMonthCollectionViewController.swift in Sources */,
0A5EA75F1DB2E9BF00B4665B /* DiaryCell.swift in Sources */,
0A5EA7371DB2B0F500B4665B /* AppDelegate.swift in Sources */,
0A5EA7671DB30D2000B4665B /* DiaryComposeViewController.swift in Sources */,
0A5EA7611DB2EDDC00B4665B /* Helper.swift in Sources */,
0A5EA7491DB2B2E200B4665B /* DiaryLabel.swift in Sources */,
0A5EA7511DB2B98D00B4665B /* HomeYearCollectionViewCell.swift in Sources */,
9F74CDB71DB3A69300DD10E3 /* DiaryViewController.swift in Sources */,
0A5EA76F1DB31A8500B4665B /* Diary.xcdatamodeld in Sources */,
0A5EA7651DB2F82E00B4665B /* DiaryAnimator.swift in Sources */,
0A5EA7551DB2BD1700B4665B /* DiaryLayout.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
0A5EA73A1DB2B0F500B4665B /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
0A5EA73B1DB2B0F500B4665B /* Base */,
);
name = Main.storyboard;
sourceTree = "";
};
0A5EA73F1DB2B0F500B4665B /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
0A5EA7401DB2B0F500B4665B /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
0A5EA7431DB2B0F500B4665B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
0A5EA7441DB2B0F500B4665B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
0A5EA7461DB2B0F500B4665B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Diary/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = kevinzhow.Diary;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
};
name = Debug;
};
0A5EA7471DB2B0F500B4665B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Diary/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = kevinzhow.Diary;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
0A5EA72E1DB2B0F500B4665B /* Build configuration list for PBXProject "Diary" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0A5EA7431DB2B0F500B4665B /* Debug */,
0A5EA7441DB2B0F500B4665B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0A5EA7451DB2B0F500B4665B /* Build configuration list for PBXNativeTarget "Diary" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0A5EA7461DB2B0F500B4665B /* Debug */,
0A5EA7471DB2B0F500B4665B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCVersionGroup section */
0A5EA76D1DB31A8500B4665B /* Diary.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
0A5EA76E1DB31A8500B4665B /* Diary.xcdatamodel */,
);
currentVersion = 0A5EA76E1DB31A8500B4665B /* Diary.xcdatamodel */;
path = Diary.xcdatamodeld;
sourceTree = "";
versionGroupType = wrapper.xcdatamodel;
};
/* End XCVersionGroup section */
};
rootObject = 0A5EA72B1DB2B0F500B4665B /* Project object */;
}
================================================
FILE: Example Codes/Diary/Diary_10/Diary.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
================================================
FILE: Example Codes/Diary/Diary_10/Diary.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
================================================
IDEDidComputeMac32BitWarning
================================================
FILE: Example Codes/Diary/Diary_10/Diary.xcodeproj/xcuserdata/kevin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
================================================
================================================
FILE: Example Codes/Diary/Diary_10/Diary.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/Diary.xcscheme
================================================
================================================
FILE: Example Codes/Diary/Diary_10/Diary.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Diary.xcscheme
orderHint
0
SuppressBuildableAutocreation
0A5EA7321DB2B0F500B4665B
primary
================================================
FILE: Example Codes/Diary/Diary_10/Diary.xcodeproj/xcuserdata/kevinzhow.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
================================================
================================================
FILE: Example Codes/Diary/Diary_10/Diary.xcodeproj/xcuserdata/kevinzhow.xcuserdatad/xcschemes/Diary.xcscheme
================================================
================================================
FILE: Example Codes/Diary/Diary_10/Diary.xcodeproj/xcuserdata/kevinzhow.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Diary.xcscheme
orderHint
0
SuppressBuildableAutocreation
0A5EA7321DB2B0F500B4665B
primary
================================================
FILE: Example Codes/Diary/Diary_10/Diary.xcodeproj/xcuserdata/zhoukaiwen.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Diary.xcscheme_^#shared#^_
orderHint
0
================================================
FILE: Example Codes/Diary/Diary_11/Diary/AppDelegate.swift
================================================
//
// AppDelegate.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
// Coredata
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let managedContext = appDelegate.managedObjectContext!
let itemHeight: CGFloat = 150.0
// Cell的高度
let itemWidth: CGFloat = 60
// Cell的宽度
let collectionViewWidth = itemWidth * 3
// 同时显示3个Cell时候
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
lazy var managedObjectModel: NSManagedObjectModel = {
// 描述数据模型描述文件存储位置
let modelURL = Bundle.main.url(forResource: "Diary", withExtension: "momd")!
return NSManagedObjectModel(contentsOf: modelURL)!
}()
lazy var applicationDocumentsDirectory: URL = {
// 数据库文件的存放文件夹
let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
return urls[urls.count-1]
}()
lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator? = {
// 通过 managedObjectModel 创建持久化管理
var coordinator: NSPersistentStoreCoordinator? =
NSPersistentStoreCoordinator(managedObjectModel:
self.managedObjectModel)
let url = self.applicationDocumentsDirectory.appendingPathComponent("Diary.sqlite")
// 设定数据库存储位置
var error: NSError? = nil
var failureReason = "载入程序存储的数据出错."
do {
try coordinator!.addPersistentStore(
ofType: NSSQLiteStoreType, configurationName: nil,
at: url, options: nil)
// 创建NSSQLiteStoreType类型持久化存储
} catch var error1 as NSError {
error = error1
coordinator = nil
// 报告错误
var dict = [String: AnyObject]()
dict[NSLocalizedDescriptionKey] = "无法初始化程序存储的数据" as AnyObject?
dict[NSLocalizedFailureReasonErrorKey] = failureReason as AnyObject?
dict[NSUnderlyingErrorKey] = error
error = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
NSLog("发现错误 \(error), \(error!.userInfo)")
abort()
} catch {
fatalError()
}
return coordinator
}()
lazy var managedObjectContext: NSManagedObjectContext? = {
let coordinator = self.persistentStoreCoordinator
if coordinator == nil {
return nil
}
var managedObjectContext = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
managedObjectContext.persistentStoreCoordinator = coordinator
return managedObjectContext
}()
}
================================================
FILE: Example Codes/Diary/Diary_11/Diary/Assets.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Diary/Diary_11/Diary/Assets.xcassets/Contents.json
================================================
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Diary/Diary_11/Diary/Assets.xcassets/Oval.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"filename" : "Oval.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Oval@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Oval@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Diary/Diary_11/Diary/Assets.xcassets/Oval_pressed.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"filename" : "Oval_pressed.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Oval_pressed@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Oval_pressed@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Diary/Diary_11/Diary/Base.lproj/LaunchScreen.storyboard
================================================
================================================
FILE: Example Codes/Diary/Diary_11/Diary/Base.lproj/Main.storyboard
================================================
================================================
FILE: Example Codes/Diary/Diary_11/Diary/Diary.xcdatamodeld/Diary.xcdatamodel/contents
================================================
================================================
FILE: Example Codes/Diary/Diary_11/Diary/DiaryAnimator.swift
================================================
//
// DiaryAnimator.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class DiaryAnimator: NSObject, UIViewControllerAnimatedTransitioning {
var operation: UINavigationController.Operation!
// 转场时长
func transitionDuration(using transitionContext:
UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.4
}
func animateTransition(using transitionContext:
UIViewControllerContextTransitioning)
{
// 获取转场舞台
let containerView = transitionContext.containerView
let fromVC = transitionContext.viewController(
forKey: UITransitionContextViewControllerKey.from)
// 获取从哪个场景开始转
let fromView = fromVC!.view
let toVC = transitionContext.viewController(
forKey: UITransitionContextViewControllerKey.to)
// 获取要转去哪个场景
let toView = toVC!.view
// 设置新场景透明度
toView?.alpha = 0.0
// UINavigationControllerOperation.Pop用来判断是转入还是转出
if operation == UINavigationController.Operation.pop {
// 如果是返回旧场景,那么设置要转入的场景初始缩放为原始大小
toView?.transform = CGAffineTransform(scaleX: 1.0,y: 1.0)
}else{
// 如果是转到新场景,设置新场景初始缩放为0.3
toView?.transform = CGAffineTransform(scaleX: 0.3,y: 0.3);
}
// 在舞台上插入场景
containerView.insertSubview(toView!, aboveSubview: fromView!)
UIView.animate(
withDuration: transitionDuration(using: transitionContext),
delay: 0,
options: UIView.AnimationOptions.curveEaseInOut,
animations:
{
if self.operation == UINavigationController.Operation.pop {
// 放大要转出的场景
fromView?.transform = CGAffineTransform(scaleX: 3.3,y: 3.3)
} else {
// 设置新场景为原始大小
toView?.transform = CGAffineTransform(scaleX: 1.0,y: 1.0)
}
toView?.alpha = 1.0
}, completion: { finished in
// 通知NavigationController已经完成转场
transitionContext.completeTransition(true)
})
}
}
================================================
FILE: Example Codes/Diary/Diary_11/Diary/DiaryCell.swift
================================================
//
// DiaryCell.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class DiaryCell: UICollectionViewCell {
var textLabel: DiaryLabel!
var textInt: Int = 0
var labelText: String = "" {
didSet {
textLabel.updateText(labelText: labelText)
}
}
override func awakeFromNib() {
super.awakeFromNib()
// 界面载入内存
self.textLabel = DiaryLabel(
fontname: "Wyue-GutiFangsong-NC",
labelText: labelText,
fontSize: 16.0,
lineHeight: 5.0,
color: UIColor.black)
self.contentView.addSubview(textLabel)
}
override func layoutSubviews() {
super.layoutSubviews() // 当对子视图进行布局时
self.textLabel.center = CGPoint(x: itemWidth/2.0, y: 150.0/2.0)
}
}
================================================
FILE: Example Codes/Diary/Diary_11/Diary/DiaryComposeViewController.swift
================================================
//
// DiaryComposeViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
let titleTextViewHeight:CGFloat = 30.0
let contentMargin:CGFloat = 20.0
var defaultFont = "Wyue-GutiFangsong-NC"
let DiaryFont = UIFont(name: defaultFont, size: 18)!
let DiaryLocationFont = UIFont(name: defaultFont, size: 16)!
let DiaryTitleFont = UIFont(name: defaultFont, size: 18)!
class DiaryComposeViewController: UIViewController {
var diary: Diary?
var composeView:UITextView!
var locationTextView:UITextView!
var titleTextView:UITextView!
var finishButton:UIButton!
var keyboardSize:CGSize = CGSize(width: 0, height: 0)
var locationHelper: DiaryLocationHelper = DiaryLocationHelper()
override func viewDidLoad() {
super.viewDidLoad()
// 创建正文输入框
composeView = UITextView(frame: CGRect(x: 0, y: contentMargin + titleTextViewHeight, width: screenSize.width, height: screenSize.height))
composeView.font = DiaryFont
composeView.isEditable = true
composeView.isUserInteractionEnabled = true
composeView.textContainerInset = UIEdgeInsets(top: contentMargin, left: contentMargin, bottom: contentMargin, right: contentMargin)
// 创建地址输入框
locationTextView = UITextView(frame: CGRect(x: 0, y: composeView.frame.size.height - 30.0, width: screenSize.width - 60.0, height: 30.0))
locationTextView.font = DiaryLocationFont
locationTextView.isEditable = true
locationTextView.isUserInteractionEnabled = true
locationTextView.bounces = false
// 创建标题输入框
titleTextView = UITextView(frame: CGRect(x: contentMargin, y: contentMargin/2, width: screenSize.width - 60.0, height: titleTextViewHeight))
titleTextView.font = DiaryTitleFont
titleTextView.isEditable = true
titleTextView.isUserInteractionEnabled = true
titleTextView.bounces = false
self.view.addSubview(composeView)
self.view.addSubview(locationTextView)
self.view.addSubview(titleTextView)
if let diary = diary {
composeView.text = diary.content
locationTextView.text = diary.location
if let title = diary.title {
titleTextView.text = title
}
}
// 创建完成按钮
finishButton = diaryButtonWith(text: "完", fontSize: 18.0, width: 50.0, normalImageName: "Oval", highlightedImageName: "Oval_pressed")
finishButton.center = CGPoint(x: screenSize.width - 20, y: screenSize.height - 30)
self.view.addSubview(finishButton)
self.finishButton.center = CGPoint(x: self.view.frame.width - self.finishButton.frame.size.height/2.0 - 10, y: self.view.frame.height - self.finishButton.frame.size.height/2.0 - 10)
self.finishButton.addTarget(self, action: #selector(finishCompose(_:)), for: UIControl.Event.touchUpInside)
self.locationTextView.center = CGPoint(x: self.locationTextView.frame.size.width/2.0 + 20.0, y: self.finishButton.center.y)
// 监听键盘事件
NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidShow(_:)), name: UIWindow.keyboardDidShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(updateAddress(_:)), name: NSNotification.Name(rawValue: "DiaryLocationUpdated"), object: nil)
}
@objc func finishCompose(_ button: UIButton) {
// 取消输入框的编辑状态,收起键盘
self.composeView.endEditing(true)
self.locationTextView.endEditing(true)
// 确保有文字内容才保存
if (composeView.text.lengthOfBytes(using: String.Encoding.utf8) > 1){
// 如果是修改 Diary,则保存到原日记中
if let diary = diary {
diary.content = composeView.text
diary.location = locationTextView.text
diary.title = titleTextView.text
}else{
let entity = NSEntityDescription.entity(forEntityName: "Diary", in: managedContext)
let newdiary = Diary(entity: entity!,
insertInto:managedContext)
newdiary.content = composeView.text
if let address = locationHelper.address {
newdiary.location = address
}
if let title = titleTextView.text {
newdiary.title = title
}
newdiary.updateTimeWithDate(Date())
}
do {
try managedContext.save()
} catch let error as NSError {
print("Could not save \(error.description)")
}
}
self.dismiss(animated: true, completion: nil)
}
@objc func updateAddress(_ notification: Notification) {
if let address = notification.object as? String {
locationTextView.text = "于 \(address)"
locationHelper.locationManager.stopUpdatingLocation()
}
}
@objc func keyboardDidShow(_ notification: Notification) {
// 取出键盘的高度
if let rectValue = (notification as NSNotification).userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue {
keyboardSize = rectValue.cgRectValue.size
//更新完成按钮和地址输入框的位置
updateTextViewSizeForKeyboardHeight(keyboardSize.height)
}
}
func updateTextViewSizeForKeyboardHeight(_ keyboardHeight: CGFloat) {
let newKeyboardHeight = keyboardHeight
UIView.animate(withDuration: 1.0, delay: 0, options: UIView.AnimationOptions(), animations:
{
if (self.locationTextView.text == nil) {
self.composeView.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height - newKeyboardHeight)
}else{
self.composeView.frame = CGRect(x: 0, y: contentMargin + titleTextViewHeight, width: self.composeView.frame.size.width, height: self.view.frame.height - newKeyboardHeight - 40.0 - self.finishButton.frame.size.height/2.0 - (contentMargin + titleTextViewHeight))
}
self.finishButton.center = CGPoint(x: self.view.frame.width - self.finishButton.frame.size.height/2.0 - 10, y: self.view.frame.height - newKeyboardHeight - self.finishButton.frame.size.height/2.0 - 10)
self.locationTextView.center = CGPoint(x: self.locationTextView.frame.size.width/2.0 + 20.0, y: self.finishButton.center.y)
}, completion: nil)
}
}
================================================
FILE: Example Codes/Diary/Diary_11/Diary/DiaryLabel.swift
================================================
//
// DiaryLabel.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
func sizeHeightWithText(labelText: String,
fontSize: CGFloat,
textAttributes: [NSAttributedString.Key: AnyObject]) -> CGRect {
return labelText.boundingRect(
with: CGSize(width:fontSize, height:480),
options: NSStringDrawingOptions.usesLineFragmentOrigin,
attributes: textAttributes, context: nil)
}
class DiaryLabel: UILabel {
var textAttributes: [NSAttributedString.Key: AnyObject]!
convenience init(fontname:String,
labelText:String,
fontSize : CGFloat,
lineHeight: CGFloat,
color: UIColor){
self.init(frame: CGRect(x:0, y:0, width:0, height:0))
let font = UIFont(name: fontname,
size: fontSize)
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = lineHeight
textAttributes = [NSAttributedString.Key.font: font!,
NSAttributedString.Key.foregroundColor: color,
NSAttributedString.Key.paragraphStyle: paragraphStyle]
let labelSize = sizeHeightWithText(labelText: labelText,
fontSize: fontSize ,
textAttributes: textAttributes)
self.frame = CGRect(x: 0, y: 0, width: labelSize.width,
height: labelSize.height)
self.attributedText = NSAttributedString(
string: labelText,
attributes: textAttributes)
self.lineBreakMode = NSLineBreakMode.byCharWrapping
self.numberOfLines = 0
}
func updateText(labelText: String) {
let labelSize = sizeHeightWithText(labelText: labelText,
fontSize: self.font.pointSize,
textAttributes: textAttributes)
self.frame = CGRect(x:0,y: 0, width:labelSize.width,
height:labelSize.height)
self.attributedText = NSAttributedString(
string: labelText,
attributes: textAttributes)
}
}
================================================
FILE: Example Codes/Diary/Diary_11/Diary/DiaryLayout.swift
================================================
//
// DiaryLayout.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
let screenSize = UIWindow().screen.bounds
class DiaryLayout: UICollectionViewFlowLayout {
var edgeInsets = (screenSize.width - itemWidth)/2.0
override func prepare() {
super.prepare() //准备布局
// Cell 大小
let itemSize = CGSize(width: itemWidth,height: itemHeight)
self.itemSize = itemSize
// Cell 左右间距
self.minimumInteritemSpacing = 0.0
// Cell 行间距
self.minimumLineSpacing = 0
// 增加内嵌
self.sectionInset = UIEdgeInsets(top: (screenSize.height/2.0) - (itemHeight/2.0), left: edgeInsets, bottom: (screenSize.height/2.0) - (itemHeight/2.0), right: 0)
// 滚动方向
scrollDirection = UICollectionView.ScrollDirection.horizontal
}
// 每次Cell的位置发生变化的时候都会执行
// layoutAttributesForElementsInRect询问Cell应该放在什么位置
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
let layoutAttributes = super.layoutAttributesForElements(in: rect)
// 获取所有需要显示的Cell的位置信息
let contentOffset = collectionView!.contentOffset
// 获取collectionView的滑动情况
for attributes in layoutAttributes! {
let center = attributes.center
let cellPositinOnScreen = (center.x - itemWidth/2.0) - contentOffset.x
if cellPositinOnScreen >= (edgeInsets - itemWidth/2.0)
&& cellPositinOnScreen < (edgeInsets
+ collectionViewWidth ) {
// 计算Cell是不是在应该显示的区域
attributes.alpha = 1
} else {
attributes.alpha = 0
}
}
return layoutAttributes
}
override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool {
return true
}
}
func calInsets(numberOfCells: Int) -> UIEdgeInsets {
let insetLeft = (screenSize.width - collectionViewWidth)/2.0
var edgeInsets: CGFloat = 0
if (numberOfCells >= 3) {
edgeInsets = insetLeft
} else {
edgeInsets = insetLeft + (collectionViewWidth - (CGFloat(numberOfCells)*itemWidth))/2.0
}
return UIEdgeInsets(top: (screenSize.height/2.0) - (itemHeight/2.0), left: edgeInsets, bottom: (screenSize.height/2.0) - (itemHeight/2.0), right: 0)
}
================================================
FILE: Example Codes/Diary/Diary_11/Diary/DiaryLocationHelper.swift
================================================
//
// DiaryLocationHelper.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import CoreLocation
class DiaryLocationHelper: NSObject, CLLocationManagerDelegate {
var locationManager:CLLocationManager = CLLocationManager()
var currentLocation:CLLocation?
var address:String?
var geocoder = CLGeocoder()
override init() {
super.init()
// 设置委托
locationManager.delegate = self
// 请求位置授权
locationManager.requestWhenInUseAuthorization()
if (CLLocationManager.locationServicesEnabled()){
//开始获取位置
locationManager.startUpdatingLocation()
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
// 根据经纬度查询位置名称
geocoder.reverseGeocodeLocation(locations[0], completionHandler: { (placemarks, error) in
if let error = error {
print("查询失败: \(error.localizedDescription)")
}
// placemarks里包括了位置的国家、省份、地区等信息
if let pm = placemarks {
if pm.count > 0 {
let placemark = pm.first
self.address = placemark?.locality
// 广播位置信息
NotificationCenter.default.post(name: Notification.Name(rawValue: "DiaryLocationUpdated"), object: self.address)
}
}
})
}
}
================================================
FILE: Example Codes/Diary/Diary_11/Diary/DiaryMonthCollectionViewController.swift
================================================
//
// DiaryMonthCollectionViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
let DiaryRed = UIColor(red: 192.0/255.0, green: 23/255.0, blue: 48.0/255.0, alpha: 1)
class DiaryMonthCollectionViewController: UICollectionViewController {
var year: Int!
var month: Int!
var yearLabel: DiaryLabel!
var monthLabel: DiaryLabel!
var fetchedResultsController : NSFetchedResultsController!
var diarys = [Diary]()
override func viewDidLoad() {
super.viewDidLoad()
let layout = DiaryLayout()
layout.scrollDirection = UICollectionView.ScrollDirection.horizontal
self.collectionView?.setCollectionViewLayout(layout, animated: false)
yearLabel = DiaryLabel(
fontname: "TpldKhangXiDictTrial",
labelText: "二零一五年",
fontSize: 16.0,
lineHeight: 5.0,
color: UIColor.black)
yearLabel.frame = CGRect(x: screenSize.width - yearLabel.frame.size.width - 20, y: 20, width: yearLabel.frame.size.width, height: yearLabel.frame.size.height)
self.view.addSubview(yearLabel)
monthLabel = DiaryLabel(
fontname: "Wyue-GutiFangsong-NC",
labelText: "三月",
fontSize: 16.0,
lineHeight: 5.0,
color: DiaryRed)
monthLabel.frame = CGRect(x: screenSize.width - monthLabel.frame.size.width - 20, y: screenSize.height/2.0 - monthLabel.frame.size.height/2.0, width: monthLabel.frame.size.width, height: monthLabel.frame.size.height)
self.view.addSubview(monthLabel)
// 添加按钮
let composeButton = diaryButtonWith(text: "撰",
fontSize: 14.0,
width: 40.0,
normalImageName: "Oval",
highlightedImageName: "Oval_pressed")
composeButton.center = CGPoint(x: yearLabel.center.x,
y: 38 + yearLabel.frame.size.height + 26.0/2.0)
composeButton.addTarget(self, action: #selector(newCompose),
for: UIControl.Event.touchUpInside)
self.view.addSubview(composeButton)
// 查询数据
do {
// 新建查询
let fetchRequest = NSFetchRequest(entityName:"Diary")
// 增加过滤条件
fetchRequest.predicate = NSPredicate(format:"year = \(year!) AND month = \(month!)")
// 排序方式
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "created_at", ascending: true)]
fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest,
managedObjectContext: managedContext, sectionNameKeyPath: nil,
cacheName: nil)
// 建立委托关系
fetchedResultsController.delegate = self
// 尝试查询
try self.fetchedResultsController.performFetch()
if (fetchedResultsController.fetchedObjects!.count == 0){
print("没有存储结果")
}else{
diarys = fetchedResultsController.fetchedObjects!
}
} catch let error as NSError {
NSLog("发现错误 \(error.localizedDescription)")
}
resetCollectionView()
}
func resetCollectionView() {
let edgeInsets = calInsets(numberOfCells: diarys.count)
if let layout = collectionView!.collectionViewLayout as? DiaryLayout {
layout.edgeInsets = edgeInsets.left
}
self.collectionView!.contentOffset = CGPoint(x: -edgeInsets.left, y: 0)
self.collectionView!.reloadData()
view.layoutIfNeeded()
}
@objc func newCompose() {
let identifier = "DiaryComposeViewController"
let composeViewController = self.storyboard?.instantiateViewController(withIdentifier: identifier)
as! DiaryComposeViewController
self.present(composeViewController,
animated: true,
completion: nil)
}
override func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return diarys.count
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let identifier = "DiaryCell"
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as! DiaryCell
let diary = diarys[indexPath.row]
cell.labelText = diary.title!
return cell
}
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let dvc = self.storyboard?.instantiateViewController(withIdentifier: "DiaryViewController") as! DiaryViewController
dvc.diary = diarys[indexPath.row]
self.navigationController!.pushViewController(dvc, animated: true)
}
}
extension DiaryMonthCollectionViewController: NSFetchedResultsControllerDelegate {
// 响应数据变化
func controller(_ controller: NSFetchedResultsController, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
// 重置数据源
diarys = controller.fetchedObjects! as! [Diary]
// 重载数据
self.collectionView?.reloadData()
// 更新布局
self.collectionView?.setCollectionViewLayout(DiaryLayout(), animated: false)
}
}
================================================
FILE: Example Codes/Diary/Diary_11/Diary/DiaryTemplate.html
================================================
================================================
FILE: Example Codes/Diary/Diary_11/Diary/DiaryViewController.swift
================================================
//
// DiaryViewController.swift
// Diary
//
// Created by kevinzhow on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class DiaryViewController: UIViewController {
var diary:Diary!
var webview: UIWebView!
var saveButton:UIButton!
var deleteButton:UIButton!
var editButton:UIButton!
var buttonsView:UIView!
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
showButtons()
}
func setupUI() {
webview = UIWebView(frame: CGRect(x: 0,y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height))
webview.scrollView.bounces = true
webview.backgroundColor = UIColor.white
self.view.addSubview(self.webview)
// 读取模板的内容
let mainHTML = Bundle.main.url(forResource: "DiaryTemplate", withExtension:"html")
var contents: NSString = ""
do {
contents = try NSString(contentsOfFile: mainHTML!.path, encoding: String.Encoding.utf8.rawValue)
} catch let error as NSError {
print(error)
}
// 生成年的整数类型
let year = (Calendar.current as NSCalendar).component(NSCalendar.Unit.year, from: diary.created_at!)
// 生成月的整数类型
let month = (Calendar.current as NSCalendar).component(NSCalendar.Unit.month, from: diary.created_at!)
// 生成日的整数类型
let day = (Calendar.current as NSCalendar).component(NSCalendar.Unit.day, from: diary.created_at!)
let timeString = "\(numberToChinese(year))年 \(numberToChineseWithUnit(month))月 \(numberToChineseWithUnit(day))日"
// 替换字符串
contents = contents.replacingOccurrences(of: "#timeString#", with: timeString) as NSString
let newDiaryString = diary.content?.replacingOccurrences(of: "\n", with: "
", options: NSString.CompareOptions.literal, range: nil)
contents = contents.replacingOccurrences(of: "#newDiaryString#", with: newDiaryString!) as NSString
var title = ""
var contentWidthOffset = 140
var contentMargin:CGFloat = 10
if let titleStr = diary?.title {
let parsedTime = "\(numberToChineseWithUnit((Calendar.current as NSCalendar).component(NSCalendar.Unit.day, from: diary.created_at!))) 日"
if titleStr != parsedTime {
title = titleStr
contentWidthOffset = 205
contentMargin = 10
title = "\(title)
"
}
}
contents = contents.replacingOccurrences(of: "#contentMargin#", with: "\(contentMargin)") as NSString
contents = contents.replacingOccurrences(of: "#title#", with: title) as NSString
let minWidth = self.view.frame.size.width - CGFloat(contentWidthOffset)
contents = contents.replacingOccurrences(of: "#minWidth#", with: "\(minWidth)") as NSString
let fontStr = defaultFont
contents = contents.replacingOccurrences(of: "#fontStr#", with: fontStr) as NSString
let titleMarginRight:CGFloat = 15
contents = contents.replacingOccurrences(of: "#titleMarginRight#", with: "\(titleMarginRight)") as NSString
if let location = diary.location {
contents = contents.replacingOccurrences(of: "#location#", with: location) as NSString
} else {
contents = contents.replacingOccurrences(of: "#location#", with: "") as NSString
}
webview.loadHTMLString(contents as String, baseURL: nil)
// 添加存改删按钮
buttonsView = UIView(frame: CGRect(x: 0, y: screenSize.height, width: screenSize.width, height: 80.0))
buttonsView.backgroundColor = UIColor.clear
buttonsView.alpha = 0.0
let buttonFontSize:CGFloat = 18.0
saveButton = diaryButtonWith(text: "存", fontSize: buttonFontSize, width: 50.0, normalImageName: "Oval", highlightedImageName: "Oval_pressed")
saveButton.center = CGPoint(x: buttonsView.frame.width/2.0, y: buttonsView.frame.height/2.0)
saveButton.addTarget(self, action: #selector(saveToRoll), for: UIControl.Event.touchUpInside)
buttonsView.addSubview(saveButton)
editButton = diaryButtonWith(text: "改", fontSize: buttonFontSize, width: 50.0, normalImageName: "Oval", highlightedImageName: "Oval_pressed")
editButton.center = CGPoint(x: saveButton.center.x - 56.0, y: saveButton.center.y)
editButton.addTarget(self, action: #selector(editDiary), for: UIControl.Event.touchUpInside)
buttonsView.addSubview(editButton)
deleteButton = diaryButtonWith(text: "刪", fontSize: buttonFontSize, width: 50.0, normalImageName: "Oval", highlightedImageName: "Oval_pressed")
deleteButton.center = CGPoint(x: saveButton.center.x + 56.0, y: saveButton.center.y)
deleteButton.addTarget(self, action: #selector(deleteThisDiary), for: UIControl.Event.touchUpInside)
buttonsView.addSubview(deleteButton)
self.view.addSubview(buttonsView)
// 切换按钮的显示状态
let mTapUpRecognizer = UITapGestureRecognizer(target: self, action: #selector(showButtons))
mTapUpRecognizer.numberOfTapsRequired = 1
mTapUpRecognizer.delegate = self
self.webview.addGestureRecognizer(mTapUpRecognizer)
}
@objc func showButtons() {
if(buttonsView.alpha == 0.0) {
UIView.animate(withDuration: 0.2, delay: 0, options: UIView.AnimationOptions(), animations:
{
self.buttonsView.center = CGPoint(x: self.buttonsView.center.x, y: screenSize.height - self.buttonsView.frame.size.height/2.0)
self.buttonsView.alpha = 1.0
}, completion: nil)
}else{
UIView.animate(withDuration: 0.1, delay: 0, options: UIView.AnimationOptions(), animations:
{
self.buttonsView.center = CGPoint(x: self.buttonsView.center.x, y: screenSize.height + self.buttonsView.frame.size.height/2.0)
self.buttonsView.alpha = 0.0
}, completion: nil)
}
}
@objc func editDiary() {
let composeViewController = self.storyboard?.instantiateViewController(withIdentifier: "DiaryComposeViewController") as! DiaryComposeViewController
if let diary = diary {
composeViewController.diary = diary
}
self.present(composeViewController, animated: true, completion: nil)
}
@objc func saveToRoll() {
let offset = self.webview.scrollView.contentOffset.x
// 针对 WebView 截图
let image = webview.captureView()
self.webview.scrollView.contentOffset.x = offset
// 创建分享对象
var sharingItems = [AnyObject]()
// 给分享对象插入图片
sharingItems.append(image)
// 初始化分享组件
let activityViewController = UIActivityViewController(activityItems: sharingItems, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.saveButton
// 现实分享组件
self.present(activityViewController, animated: true, completion: nil)
}
@objc func deleteThisDiary() {
managedContext.delete(diary)
do {
try managedContext.save()
} catch _ {
}
hideDiary()
}
func hideDiary() {
self.navigationController?.popViewController(animated: true)
}
}
extension DiaryViewController: UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailBy otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
}
================================================
FILE: Example Codes/Diary/Diary_11/Diary/DiaryYearCollectionViewController.swift
================================================
//
// DiaryYearCollectionViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
class DiaryYearCollectionViewController: UICollectionViewController {
var year: Int!
var diarys = [Diary]()
var fetchedResultsController : NSFetchedResultsController!
var monthCount: Int = 1
var sectionsCount: Int = 0
override func viewDidLoad() {
super.viewDidLoad()
let layout = DiaryLayout()
layout.scrollDirection = UICollectionView.ScrollDirection.horizontal
self.collectionView?.setCollectionViewLayout(layout, animated: false)
do {
// 新建查询
let fetchRequest = NSFetchRequest(entityName:"Diary")
// 增加过滤条件
fetchRequest.predicate = NSPredicate(format:"year = \(year!)")
// 排序方式
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "created_at", ascending: true)]
fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest,
managedObjectContext: managedContext, sectionNameKeyPath: "month",
cacheName: nil)
// 尝试查询
try self.fetchedResultsController.performFetch()
if (fetchedResultsController.fetchedObjects!.count == 0){
print("没有存储结果")
}else{
if let sectionsCount = fetchedResultsController.sections?.count {
monthCount = sectionsCount
diarys = fetchedResultsController.fetchedObjects!
}else {
sectionsCount = 0
monthCount = 1
}
}
} catch let error as NSError {
NSLog("发现错误 \(error.localizedDescription)")
}
}
override func numberOfSections(in collectionView: UICollectionView) -> Int {
return monthCount
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 1
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let identifier = "DiaryCell"
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as! DiaryCell
// 获取当前月份
let components = Calendar.current.component(Calendar.Component.month, from: Date())
var month = components
if sectionsCount > 0 {
// 如果程序内有保存的日记,就使用保存的日记的月份
let sectionInfo = fetchedResultsController.sections![indexPath.section]
print("分组信息 \(sectionInfo.name)")
month = Int(sectionInfo.name)!
}
cell.textInt = month
cell.labelText = "\(numberToChinese(cell.textInt)) 月"
// Configure the cell
return cell
}
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
//super.collectionView(collectionView, didSelectItemAt: indexPath as IndexPath)
let identifier = "DiaryMonthCollectionViewController"
let dvc = self.storyboard?.instantiateViewController(withIdentifier: identifier) as! DiaryMonthCollectionViewController // 获取 DiaryMonthCollectionViewController
// 获取当前月份
let components = Calendar.current.component(Calendar.Component.month, from: Date())
var month = components
if sectionsCount > 0 {
// 如果程序内有保存的日记,就使用保存的日记的月份
let sectionInfo = fetchedResultsController.sections![indexPath.section]
print("分组信息 \(sectionInfo.name)")
month = Int(sectionInfo.name)!
}
// 指定是 2015 年的 1 月份
dvc.month = month
dvc.year = year
// 页面跳转
self.navigationController!.pushViewController(dvc, animated: true)
}
}
================================================
FILE: Example Codes/Diary/Diary_11/Diary/Helper.swift
================================================
//
// Helper.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
extension Diary {
func updateTimeWithDate(_ date: Date){
self.created_at = date
self.year = Int32(Calendar.current.component(Calendar.Component.year, from: date))
self.month = Int32(Calendar.current.component(Calendar.Component.month, from: date))
}
}
extension UIWebView {
func captureView() -> UIImage{
// 存储初始大小
let tmpFrame = self.frame
// 新的 Frame
var aFrame = self.frame
aFrame.size.width = self.sizeThatFits(UIScreen.main.bounds.size).width
// 展开 Frame
self.frame = aFrame
// 初始化 ImageContext
UIGraphicsBeginImageContextWithOptions(
self.sizeThatFits(UIScreen.main.bounds.size),
false,
UIScreen.main.scale)
// 创建新的 Context
let resizedContext = UIGraphicsGetCurrentContext()
self.layer.render(in: resizedContext!)
// 重新渲染到新的 resizedContext
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
// 还原 Frame
self.frame = tmpFrame
return image!
}
}
func diaryButtonWith(text: String,
fontSize: CGFloat,
width: CGFloat,
normalImageName: String,
highlightedImageName: String) -> UIButton {
// 创建自定义按钮
let button = UIButton(type: UIButton.ButtonType.custom)
// 设定按钮的大小
button.frame = CGRect(x: 0, y: 0, width: width, height: width)
let font = UIFont(name: "Wyue-GutiFangsong-NC", size: fontSize)
let textAttributes: [NSAttributedString.Key: AnyObject] = [
NSAttributedString.Key.font: font!,
NSAttributedString.Key.foregroundColor: UIColor.white]
// 设置按钮的字体
let attributedText = NSAttributedString(string: text, attributes: textAttributes)
button.setAttributedTitle(attributedText, for: UIControl.State.normal)
// 设置默认按钮的样式
button.setBackgroundImage(UIImage(
named: normalImageName),
for: UIControl.State.normal)
// 设置按钮被按下时的样式
button.setBackgroundImage(UIImage(
named: highlightedImageName),
for: UIControl.State.highlighted)
return button
}
func singleNumberToChinese(_ number:Character) -> String {
switch number {
case "0":
return "零"
case "1":
return "一"
case "2":
return "二"
case "3":
return "三"
case "4":
return "四"
case "5":
return "五"
case "6":
return "六"
case "7":
return "七"
case "8":
return "八"
case "9":
return "九"
default:
return ""
}
}
func numberToChinese(_ number:Int) -> String {
let numbers = String(number)
var finalString = ""
for singleNumber in numbers {
let string = singleNumberToChinese(singleNumber)
finalString = "\(finalString)\(string)"
}
return finalString
}
func numberToChineseWithUnit(_ number:Int) -> String {
let numbers = String(number)
var units = unitParser(numbers.count)
var finalString = ""
for (index, singleNumber) in numbers.enumerated() {
let string = singleNumberToChinese(singleNumber)
if (!(string == "零" && (index+1) == numbers.count)){
finalString = "\(finalString)\(string)\(units[index])"
}
}
return finalString
}
func unitParser(_ unit:Int) -> [String] {
var units = Array(["万","千","百","十",""].reversed())
let parsedUnits = units[0..<(unit)].reversed()
let slicedUnits: ArraySlice = ArraySlice(parsedUnits)
let final: [String] = Array(slicedUnits)
return final
}
================================================
FILE: Example Codes/Diary/Diary_11/Diary/HomeCollectionViewController.swift
================================================
//
// HomeCollectionViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
class HomeCollectionViewController: UICollectionViewController {
var diarys = [Diary]()
var fetchedResultsController : NSFetchedResultsController!
var yearsCount: Int = 1
var sectionsCount: Int = 0
override func viewDidLoad() {
super.viewDidLoad()
let yearLayout = DiaryLayout()
yearLayout.scrollDirection = UICollectionView.ScrollDirection.horizontal
self.collectionView?.setCollectionViewLayout(yearLayout, animated: false)
self.navigationController!.delegate = self
do {
// 新建查询
let fetchRequest = NSFetchRequest(entityName:"Diary")
// 排序方式
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "created_at", ascending: true)]
fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest,
managedObjectContext: managedContext, sectionNameKeyPath: "year",
cacheName: nil)
// 尝试查询
try self.fetchedResultsController.performFetch()
if (fetchedResultsController.fetchedObjects!.count == 0){
print("没有存储结果")
}else{
if let sectionsCount = fetchedResultsController.sections?.count {
yearsCount = sectionsCount
diarys = fetchedResultsController.fetchedObjects!
}else {
sectionsCount = 0
yearsCount = 1
}
}
} catch let error as NSError {
NSLog("发现错误 \(error.localizedDescription)")
}
}
override func numberOfSections(in collectionView: UICollectionView) -> Int {
return yearsCount
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 1
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let identifier = "HomeYearCollectionViewCell"
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as! HomeYearCollectionViewCell
// 获取当前月份
let components = Calendar.current.component(Calendar.Component.year, from: Date())
var year = components
if sectionsCount > 0 {
// 如果程序内有保存的日记,就使用保存的日记的年份
let sectionInfo = fetchedResultsController.sections![indexPath.section]
print("分组信息 \(sectionInfo.name)")
year = Int(sectionInfo.name)!
}
cell.textInt = year
cell.labelText = "\(numberToChinese(cell.textInt)) 年"
// Configure the cell
return cell
}
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
//super.collectionView(collectionView, didSelectItemAt: indexPath as IndexPath)
let identifier = "DiaryYearCollectionViewController"
let dvc = self.storyboard?.instantiateViewController(withIdentifier: identifier) as! DiaryYearCollectionViewController // 获取 DiaryYearCollectionViewController
let components = Calendar.current.component(Calendar.Component.year, from: Date())
var year = components
if sectionsCount > 0 {
let sectionInfo = fetchedResultsController.sections![(indexPath as NSIndexPath).row]
print("Section info \(sectionInfo.name)")
year = Int(sectionInfo.name)!
}
dvc.year = year
self.navigationController!.pushViewController(dvc, animated: true)
}
}
extension HomeCollectionViewController: UINavigationControllerDelegate {
func navigationController(_ navigationController:
UINavigationController,
animationControllerFor operation:
UINavigationController.Operation,
from fromVC: UIViewController,
to toVC: UIViewController) ->
UIViewControllerAnimatedTransitioning? {
let animator = DiaryAnimator()
animator.operation = operation
return animator
}
}
================================================
FILE: Example Codes/Diary/Diary_11/Diary/HomeYearCollectionViewCell.swift
================================================
//
// HomeYearCollectionViewCell.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class HomeYearCollectionViewCell: UICollectionViewCell {
var textLabel: DiaryLabel!
var textInt: Int = 0
var labelText: String = "" {
didSet {
textLabel.updateText(labelText: labelText)
}
}
override func awakeFromNib() {
super.awakeFromNib()
// 界面载入内存
self.textLabel = DiaryLabel(
fontname: "TpldKhangXiDictTrial",
labelText: labelText,
fontSize: 16.0,
lineHeight: 5.0,
color: UIColor.black)
self.contentView.addSubview(textLabel)
}
override func layoutSubviews() {
super.layoutSubviews() // 当对子视图进行布局时
self.textLabel.center = CGPoint(x: itemWidth/2.0, y: 150.0/2.0)
}
}
================================================
FILE: Example Codes/Diary/Diary_11/Diary/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
CFBundleVersion
1
LSRequiresIPhoneOS
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
Main
UIRequiredDeviceCapabilities
armv7
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
UIAppFonts
Wyue-GutiFangsong-NC_deliverable.otf
TpldKhangXiDictTrial.otf
NSLocationWhenInUseUsageDescription
在撰写日志的时候自动添加位置
UISupportedInterfaceOrientations~ipad
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
================================================
FILE: Example Codes/Diary/Diary_11/Diary/ViewController.swift
================================================
//
// ViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
================================================
FILE: Example Codes/Diary/Diary_11/Diary/Wyue-GutiFangsong-NC_deliverable.otf
================================================
[File too large to display: 21.5 MB]
================================================
FILE: Example Codes/Diary/Diary_11/Diary.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
0A5EA7371DB2B0F500B4665B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7361DB2B0F500B4665B /* AppDelegate.swift */; };
0A5EA7391DB2B0F500B4665B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7381DB2B0F500B4665B /* ViewController.swift */; };
0A5EA73C1DB2B0F500B4665B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA73A1DB2B0F500B4665B /* Main.storyboard */; };
0A5EA73E1DB2B0F500B4665B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA73D1DB2B0F500B4665B /* Assets.xcassets */; };
0A5EA7411DB2B0F500B4665B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA73F1DB2B0F500B4665B /* LaunchScreen.storyboard */; };
0A5EA7491DB2B2E200B4665B /* DiaryLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7481DB2B2E200B4665B /* DiaryLabel.swift */; };
0A5EA74F1DB2B81900B4665B /* HomeCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA74E1DB2B81900B4665B /* HomeCollectionViewController.swift */; };
0A5EA7511DB2B98D00B4665B /* HomeYearCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7501DB2B98D00B4665B /* HomeYearCollectionViewCell.swift */; };
0A5EA7551DB2BD1700B4665B /* DiaryLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7541DB2BD1700B4665B /* DiaryLayout.swift */; };
0A5EA75A1DB2C29800B4665B /* TpldKhangXiDictTrial.otf in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA74A1DB2B4BA00B4665B /* TpldKhangXiDictTrial.otf */; };
0A5EA75B1DB2C29B00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA74B1DB2B4BA00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf */; };
0A5EA75D1DB2E5E400B4665B /* DiaryYearCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA75C1DB2E5E400B4665B /* DiaryYearCollectionViewController.swift */; };
0A5EA75F1DB2E9BF00B4665B /* DiaryCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA75E1DB2E9BF00B4665B /* DiaryCell.swift */; };
0A5EA7611DB2EDDC00B4665B /* Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7601DB2EDDC00B4665B /* Helper.swift */; };
0A5EA7631DB2EF3E00B4665B /* DiaryMonthCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7621DB2EF3E00B4665B /* DiaryMonthCollectionViewController.swift */; };
0A5EA7651DB2F82E00B4665B /* DiaryAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7641DB2F82E00B4665B /* DiaryAnimator.swift */; };
0A5EA7671DB30D2000B4665B /* DiaryComposeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7661DB30D2000B4665B /* DiaryComposeViewController.swift */; };
0A5EA7691DB3131E00B4665B /* DiaryLocationHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7681DB3131E00B4665B /* DiaryLocationHelper.swift */; };
0A5EA76F1DB31A8500B4665B /* Diary.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA76D1DB31A8500B4665B /* Diary.xcdatamodeld */; };
9F74CDB71DB3A69300DD10E3 /* DiaryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F74CDB61DB3A69300DD10E3 /* DiaryViewController.swift */; };
9F74CDB91DB3A80700DD10E3 /* DiaryTemplate.html in Resources */ = {isa = PBXBuildFile; fileRef = 9F74CDB81DB3A80700DD10E3 /* DiaryTemplate.html */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
0A5EA7331DB2B0F500B4665B /* Diary.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Diary.app; sourceTree = BUILT_PRODUCTS_DIR; };
0A5EA7361DB2B0F500B4665B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
0A5EA7381DB2B0F500B4665B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
0A5EA73B1DB2B0F500B4665B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
0A5EA73D1DB2B0F500B4665B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
0A5EA7401DB2B0F500B4665B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
0A5EA7421DB2B0F500B4665B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
0A5EA7481DB2B2E200B4665B /* DiaryLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryLabel.swift; sourceTree = ""; };
0A5EA74A1DB2B4BA00B4665B /* TpldKhangXiDictTrial.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = TpldKhangXiDictTrial.otf; sourceTree = ""; };
0A5EA74B1DB2B4BA00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Wyue-GutiFangsong-NC_deliverable.otf"; sourceTree = ""; };
0A5EA74E1DB2B81900B4665B /* HomeCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeCollectionViewController.swift; sourceTree = ""; };
0A5EA7501DB2B98D00B4665B /* HomeYearCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeYearCollectionViewCell.swift; sourceTree = ""; };
0A5EA7541DB2BD1700B4665B /* DiaryLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryLayout.swift; sourceTree = ""; };
0A5EA75C1DB2E5E400B4665B /* DiaryYearCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryYearCollectionViewController.swift; sourceTree = ""; };
0A5EA75E1DB2E9BF00B4665B /* DiaryCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryCell.swift; sourceTree = ""; };
0A5EA7601DB2EDDC00B4665B /* Helper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Helper.swift; sourceTree = ""; };
0A5EA7621DB2EF3E00B4665B /* DiaryMonthCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryMonthCollectionViewController.swift; sourceTree = ""; };
0A5EA7641DB2F82E00B4665B /* DiaryAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryAnimator.swift; sourceTree = ""; };
0A5EA7661DB30D2000B4665B /* DiaryComposeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryComposeViewController.swift; sourceTree = ""; };
0A5EA7681DB3131E00B4665B /* DiaryLocationHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryLocationHelper.swift; sourceTree = ""; };
0A5EA76E1DB31A8500B4665B /* Diary.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Diary.xcdatamodel; sourceTree = ""; };
9F74CDB61DB3A69300DD10E3 /* DiaryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryViewController.swift; sourceTree = ""; };
9F74CDB81DB3A80700DD10E3 /* DiaryTemplate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DiaryTemplate.html; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
0A5EA7301DB2B0F500B4665B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
0A5EA72A1DB2B0F500B4665B = {
isa = PBXGroup;
children = (
0A5EA7351DB2B0F500B4665B /* Diary */,
0A5EA7341DB2B0F500B4665B /* Products */,
);
sourceTree = "";
};
0A5EA7341DB2B0F500B4665B /* Products */ = {
isa = PBXGroup;
children = (
0A5EA7331DB2B0F500B4665B /* Diary.app */,
);
name = Products;
sourceTree = "";
};
0A5EA7351DB2B0F500B4665B /* Diary */ = {
isa = PBXGroup;
children = (
9F74CDB81DB3A80700DD10E3 /* DiaryTemplate.html */,
9F74CDB61DB3A69300DD10E3 /* DiaryViewController.swift */,
0A5EA76D1DB31A8500B4665B /* Diary.xcdatamodeld */,
0A5EA7681DB3131E00B4665B /* DiaryLocationHelper.swift */,
0A5EA7661DB30D2000B4665B /* DiaryComposeViewController.swift */,
0A5EA7641DB2F82E00B4665B /* DiaryAnimator.swift */,
0A5EA7601DB2EDDC00B4665B /* Helper.swift */,
0A5EA7541DB2BD1700B4665B /* DiaryLayout.swift */,
0A5EA74E1DB2B81900B4665B /* HomeCollectionViewController.swift */,
0A5EA75C1DB2E5E400B4665B /* DiaryYearCollectionViewController.swift */,
0A5EA7621DB2EF3E00B4665B /* DiaryMonthCollectionViewController.swift */,
0A5EA75E1DB2E9BF00B4665B /* DiaryCell.swift */,
0A5EA7501DB2B98D00B4665B /* HomeYearCollectionViewCell.swift */,
0A5EA7361DB2B0F500B4665B /* AppDelegate.swift */,
0A5EA7481DB2B2E200B4665B /* DiaryLabel.swift */,
0A5EA7381DB2B0F500B4665B /* ViewController.swift */,
0A5EA73A1DB2B0F500B4665B /* Main.storyboard */,
0A5EA74A1DB2B4BA00B4665B /* TpldKhangXiDictTrial.otf */,
0A5EA74B1DB2B4BA00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf */,
0A5EA73D1DB2B0F500B4665B /* Assets.xcassets */,
0A5EA73F1DB2B0F500B4665B /* LaunchScreen.storyboard */,
0A5EA7421DB2B0F500B4665B /* Info.plist */,
);
path = Diary;
sourceTree = "";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
0A5EA7321DB2B0F500B4665B /* Diary */ = {
isa = PBXNativeTarget;
buildConfigurationList = 0A5EA7451DB2B0F500B4665B /* Build configuration list for PBXNativeTarget "Diary" */;
buildPhases = (
0A5EA72F1DB2B0F500B4665B /* Sources */,
0A5EA7301DB2B0F500B4665B /* Frameworks */,
0A5EA7311DB2B0F500B4665B /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = Diary;
productName = Diary;
productReference = 0A5EA7331DB2B0F500B4665B /* Diary.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
0A5EA72B1DB2B0F500B4665B /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0800;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = kevinzhow;
TargetAttributes = {
0A5EA7321DB2B0F500B4665B = {
CreatedOnToolsVersion = 8.0;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 0A5EA72E1DB2B0F500B4665B /* Build configuration list for PBXProject "Diary" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 0A5EA72A1DB2B0F500B4665B;
productRefGroup = 0A5EA7341DB2B0F500B4665B /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
0A5EA7321DB2B0F500B4665B /* Diary */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
0A5EA7311DB2B0F500B4665B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0A5EA7411DB2B0F500B4665B /* LaunchScreen.storyboard in Resources */,
0A5EA75A1DB2C29800B4665B /* TpldKhangXiDictTrial.otf in Resources */,
9F74CDB91DB3A80700DD10E3 /* DiaryTemplate.html in Resources */,
0A5EA73E1DB2B0F500B4665B /* Assets.xcassets in Resources */,
0A5EA73C1DB2B0F500B4665B /* Main.storyboard in Resources */,
0A5EA75B1DB2C29B00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
0A5EA72F1DB2B0F500B4665B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0A5EA7391DB2B0F500B4665B /* ViewController.swift in Sources */,
0A5EA75D1DB2E5E400B4665B /* DiaryYearCollectionViewController.swift in Sources */,
0A5EA74F1DB2B81900B4665B /* HomeCollectionViewController.swift in Sources */,
0A5EA7691DB3131E00B4665B /* DiaryLocationHelper.swift in Sources */,
0A5EA7631DB2EF3E00B4665B /* DiaryMonthCollectionViewController.swift in Sources */,
0A5EA75F1DB2E9BF00B4665B /* DiaryCell.swift in Sources */,
0A5EA7371DB2B0F500B4665B /* AppDelegate.swift in Sources */,
0A5EA7671DB30D2000B4665B /* DiaryComposeViewController.swift in Sources */,
0A5EA7611DB2EDDC00B4665B /* Helper.swift in Sources */,
0A5EA7491DB2B2E200B4665B /* DiaryLabel.swift in Sources */,
0A5EA7511DB2B98D00B4665B /* HomeYearCollectionViewCell.swift in Sources */,
9F74CDB71DB3A69300DD10E3 /* DiaryViewController.swift in Sources */,
0A5EA76F1DB31A8500B4665B /* Diary.xcdatamodeld in Sources */,
0A5EA7651DB2F82E00B4665B /* DiaryAnimator.swift in Sources */,
0A5EA7551DB2BD1700B4665B /* DiaryLayout.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
0A5EA73A1DB2B0F500B4665B /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
0A5EA73B1DB2B0F500B4665B /* Base */,
);
name = Main.storyboard;
sourceTree = "";
};
0A5EA73F1DB2B0F500B4665B /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
0A5EA7401DB2B0F500B4665B /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
0A5EA7431DB2B0F500B4665B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
0A5EA7441DB2B0F500B4665B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
0A5EA7461DB2B0F500B4665B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Diary/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = kevinzhow.Diary;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
};
name = Debug;
};
0A5EA7471DB2B0F500B4665B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Diary/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = kevinzhow.Diary;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
0A5EA72E1DB2B0F500B4665B /* Build configuration list for PBXProject "Diary" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0A5EA7431DB2B0F500B4665B /* Debug */,
0A5EA7441DB2B0F500B4665B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0A5EA7451DB2B0F500B4665B /* Build configuration list for PBXNativeTarget "Diary" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0A5EA7461DB2B0F500B4665B /* Debug */,
0A5EA7471DB2B0F500B4665B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCVersionGroup section */
0A5EA76D1DB31A8500B4665B /* Diary.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
0A5EA76E1DB31A8500B4665B /* Diary.xcdatamodel */,
);
currentVersion = 0A5EA76E1DB31A8500B4665B /* Diary.xcdatamodel */;
path = Diary.xcdatamodeld;
sourceTree = "";
versionGroupType = wrapper.xcdatamodel;
};
/* End XCVersionGroup section */
};
rootObject = 0A5EA72B1DB2B0F500B4665B /* Project object */;
}
================================================
FILE: Example Codes/Diary/Diary_11/Diary.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
================================================
FILE: Example Codes/Diary/Diary_11/Diary.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
================================================
IDEDidComputeMac32BitWarning
================================================
FILE: Example Codes/Diary/Diary_11/Diary.xcodeproj/xcuserdata/kevin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
================================================
================================================
FILE: Example Codes/Diary/Diary_11/Diary.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/Diary.xcscheme
================================================
================================================
FILE: Example Codes/Diary/Diary_11/Diary.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Diary.xcscheme
orderHint
0
SuppressBuildableAutocreation
0A5EA7321DB2B0F500B4665B
primary
================================================
FILE: Example Codes/Diary/Diary_11/Diary.xcodeproj/xcuserdata/kevinzhow.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
================================================
================================================
FILE: Example Codes/Diary/Diary_11/Diary.xcodeproj/xcuserdata/kevinzhow.xcuserdatad/xcschemes/Diary.xcscheme
================================================
================================================
FILE: Example Codes/Diary/Diary_11/Diary.xcodeproj/xcuserdata/kevinzhow.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Diary.xcscheme
orderHint
0
SuppressBuildableAutocreation
0A5EA7321DB2B0F500B4665B
primary
================================================
FILE: Example Codes/Diary/Diary_11/Diary.xcodeproj/xcuserdata/zhoukaiwen.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Diary.xcscheme_^#shared#^_
orderHint
0
================================================
FILE: Example Codes/Diary/Diary_12/Diary/AppDelegate.swift
================================================
//
// AppDelegate.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
// Coredata
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let managedContext = appDelegate.managedObjectContext!
let itemHeight: CGFloat = 150.0
// Cell的高度
let itemWidth: CGFloat = 60
// Cell的宽度
let collectionViewWidth = itemWidth * 3
// 同时显示3个Cell时候
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
lazy var managedObjectModel: NSManagedObjectModel = {
// 描述数据模型描述文件存储位置
let modelURL = Bundle.main.url(forResource: "Diary", withExtension: "momd")!
return NSManagedObjectModel(contentsOf: modelURL)!
}()
lazy var applicationDocumentsDirectory: URL = {
// 数据库文件的存放文件夹
let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
return urls[urls.count-1]
}()
lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator? = {
// 通过 managedObjectModel 创建持久化管理
var coordinator: NSPersistentStoreCoordinator? =
NSPersistentStoreCoordinator(managedObjectModel:
self.managedObjectModel)
let url = self.applicationDocumentsDirectory.appendingPathComponent("Diary.sqlite")
// 设定数据库存储位置
var error: NSError? = nil
var failureReason = "载入程序存储的数据出错."
do {
try coordinator!.addPersistentStore(
ofType: NSSQLiteStoreType, configurationName: nil,
at: url, options: nil)
// 创建NSSQLiteStoreType类型持久化存储
} catch var error1 as NSError {
error = error1
coordinator = nil
// 报告错误
var dict = [String: AnyObject]()
dict[NSLocalizedDescriptionKey] = "无法初始化程序存储的数据" as AnyObject?
dict[NSLocalizedFailureReasonErrorKey] = failureReason as AnyObject?
dict[NSUnderlyingErrorKey] = error
error = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
NSLog("发现错误 \(error), \(error!.userInfo)")
abort()
} catch {
fatalError()
}
return coordinator
}()
lazy var managedObjectContext: NSManagedObjectContext? = {
let coordinator = self.persistentStoreCoordinator
if coordinator == nil {
return nil
}
var managedObjectContext = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
managedObjectContext.persistentStoreCoordinator = coordinator
return managedObjectContext
}()
}
================================================
FILE: Example Codes/Diary/Diary_12/Diary/Assets.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Diary/Diary_12/Diary/Assets.xcassets/Contents.json
================================================
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Diary/Diary_12/Diary/Assets.xcassets/Oval.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"filename" : "Oval.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Oval@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Oval@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Diary/Diary_12/Diary/Assets.xcassets/Oval_pressed.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"filename" : "Oval_pressed.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Oval_pressed@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Oval_pressed@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Diary/Diary_12/Diary/Base.lproj/LaunchScreen.storyboard
================================================
================================================
FILE: Example Codes/Diary/Diary_12/Diary/Base.lproj/Main.storyboard
================================================
================================================
FILE: Example Codes/Diary/Diary_12/Diary/Diary.xcdatamodeld/Diary.xcdatamodel/contents
================================================
================================================
FILE: Example Codes/Diary/Diary_12/Diary/DiaryAnimator.swift
================================================
//
// DiaryAnimator.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class DiaryAnimator: NSObject, UIViewControllerAnimatedTransitioning {
var operation: UINavigationController.Operation!
// 转场时长
func transitionDuration(using transitionContext:
UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.4
}
func animateTransition(using transitionContext:
UIViewControllerContextTransitioning)
{
// 获取转场舞台
let containerView = transitionContext.containerView
let fromVC = transitionContext.viewController(
forKey: UITransitionContextViewControllerKey.from)
// 获取从哪个场景开始转
let fromView = fromVC!.view
let toVC = transitionContext.viewController(
forKey: UITransitionContextViewControllerKey.to)
// 获取要转去哪个场景
let toView = toVC!.view
// 设置新场景透明度
toView?.alpha = 0.0
// UINavigationControllerOperation.Pop用来判断是转入还是转出
if operation == UINavigationController.Operation.pop {
// 如果是返回旧场景,那么设置要转入的场景初始缩放为原始大小
toView?.transform = CGAffineTransform(scaleX: 1.0,y: 1.0)
}else{
// 如果是转到新场景,设置新场景初始缩放为0.3
toView?.transform = CGAffineTransform(scaleX: 0.3,y: 0.3);
}
// 在舞台上插入场景
containerView.insertSubview(toView!, aboveSubview: fromView!)
UIView.animate(
withDuration: transitionDuration(using: transitionContext),
delay: 0,
options: UIView.AnimationOptions.curveEaseInOut,
animations:
{
if self.operation == UINavigationController.Operation.pop {
// 放大要转出的场景
fromView?.transform = CGAffineTransform(scaleX: 3.3,y: 3.3)
} else {
// 设置新场景为原始大小
toView?.transform = CGAffineTransform(scaleX: 1.0,y: 1.0)
}
toView?.alpha = 1.0
}, completion: { finished in
// 通知NavigationController已经完成转场
transitionContext.completeTransition(true)
})
}
}
================================================
FILE: Example Codes/Diary/Diary_12/Diary/DiaryCell.swift
================================================
//
// DiaryCell.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class DiaryCell: UICollectionViewCell {
var textLabel: DiaryLabel!
var textInt: Int = 0
var labelText: String = "" {
didSet {
textLabel.updateText(labelText: labelText)
}
}
override func awakeFromNib() {
super.awakeFromNib()
// 界面载入内存
self.textLabel = DiaryLabel(
fontname: "Wyue-GutiFangsong-NC",
labelText: labelText,
fontSize: 16.0,
lineHeight: 5.0,
color: UIColor.black)
self.contentView.addSubview(textLabel)
}
override func layoutSubviews() {
super.layoutSubviews() // 当对子视图进行布局时
self.textLabel.center = CGPoint(x: itemWidth/2.0, y: 150.0/2.0)
}
}
================================================
FILE: Example Codes/Diary/Diary_12/Diary/DiaryComposeViewController.swift
================================================
//
// DiaryComposeViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
let titleTextViewHeight:CGFloat = 30.0
let contentMargin:CGFloat = 20.0
var defaultFont = "Wyue-GutiFangsong-NC"
let DiaryFont = UIFont(name: defaultFont, size: 18)!
let DiaryLocationFont = UIFont(name: defaultFont, size: 16)!
let DiaryTitleFont = UIFont(name: defaultFont, size: 18)!
class DiaryComposeViewController: UIViewController {
var diary: Diary?
var composeView:UITextView!
var locationTextView:UITextView!
var titleTextView:UITextView!
var finishButton:UIButton!
var keyboardSize:CGSize = CGSize(width: 0, height: 0)
var locationHelper: DiaryLocationHelper = DiaryLocationHelper()
override func viewDidLoad() {
super.viewDidLoad()
// 创建正文输入框
composeView = UITextView(frame: CGRect(x: 0, y: contentMargin + titleTextViewHeight, width: screenSize.width, height: screenSize.height))
composeView.font = DiaryFont
composeView.isEditable = true
composeView.isUserInteractionEnabled = true
composeView.textContainerInset = UIEdgeInsets(top: contentMargin, left: contentMargin, bottom: contentMargin, right: contentMargin)
// 创建地址输入框
locationTextView = UITextView(frame: CGRect(x: 0, y: composeView.frame.size.height - 30.0, width: screenSize.width - 60.0, height: 30.0))
locationTextView.font = DiaryLocationFont
locationTextView.isEditable = true
locationTextView.isUserInteractionEnabled = true
locationTextView.bounces = false
// 创建标题输入框
titleTextView = UITextView(frame: CGRect(x: contentMargin, y: contentMargin/2, width: screenSize.width - 60.0, height: titleTextViewHeight))
titleTextView.font = DiaryTitleFont
titleTextView.isEditable = true
titleTextView.isUserInteractionEnabled = true
titleTextView.bounces = false
self.view.addSubview(composeView)
self.view.addSubview(locationTextView)
self.view.addSubview(titleTextView)
if let diary = diary {
composeView.text = diary.content
locationTextView.text = diary.location
if let title = diary.title {
titleTextView.text = title
}
}
// 创建完成按钮
finishButton = diaryButtonWith(text: "完", fontSize: 18.0, width: 50.0, normalImageName: "Oval", highlightedImageName: "Oval_pressed")
finishButton.center = CGPoint(x: screenSize.width - 20, y: screenSize.height - 30)
self.view.addSubview(finishButton)
self.finishButton.center = CGPoint(x: self.view.frame.width - self.finishButton.frame.size.height/2.0 - 10, y: self.view.frame.height - self.finishButton.frame.size.height/2.0 - 10)
self.finishButton.addTarget(self, action: #selector(finishCompose(_:)), for: UIControl.Event.touchUpInside)
self.locationTextView.center = CGPoint(x: self.locationTextView.frame.size.width/2.0 + 20.0, y: self.finishButton.center.y)
// 监听键盘事件
NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidShow(_:)), name: UIWindow.keyboardDidShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(updateAddress(_:)), name: NSNotification.Name(rawValue: "DiaryLocationUpdated"), object: nil)
}
@objc func finishCompose(_ button: UIButton) {
// 取消输入框的编辑状态,收起键盘
self.composeView.endEditing(true)
self.locationTextView.endEditing(true)
// 确保有文字内容才保存
if (composeView.text.lengthOfBytes(using: String.Encoding.utf8) > 1){
// 如果是修改 Diary,则保存到原日记中
if let diary = diary {
diary.content = composeView.text
diary.location = locationTextView.text
diary.title = titleTextView.text
}else{
let entity = NSEntityDescription.entity(forEntityName: "Diary", in: managedContext)
let newdiary = Diary(entity: entity!,
insertInto:managedContext)
newdiary.content = composeView.text
if let address = locationHelper.address {
newdiary.location = address
}
if let title = titleTextView.text {
newdiary.title = title
}
newdiary.updateTimeWithDate(Date())
}
do {
try managedContext.save()
} catch let error as NSError {
print("Could not save \(error.description)")
}
}
self.dismiss(animated: true, completion: nil)
}
@objc func updateAddress(_ notification: Notification) {
if let address = notification.object as? String {
locationTextView.text = "于 \(address)"
locationHelper.locationManager.stopUpdatingLocation()
}
}
@objc func keyboardDidShow(_ notification: Notification) {
// 取出键盘的高度
if let rectValue = (notification as NSNotification).userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue {
keyboardSize = rectValue.cgRectValue.size
//更新完成按钮和地址输入框的位置
updateTextViewSizeForKeyboardHeight(keyboardSize.height)
}
}
func updateTextViewSizeForKeyboardHeight(_ keyboardHeight: CGFloat) {
let newKeyboardHeight = keyboardHeight
UIView.animate(withDuration: 1.0, delay: 0, options: UIView.AnimationOptions(), animations:
{
if (self.locationTextView.text == nil) {
self.composeView.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height - newKeyboardHeight)
}else{
self.composeView.frame = CGRect(x: 0, y: contentMargin + titleTextViewHeight, width: self.composeView.frame.size.width, height: self.view.frame.height - newKeyboardHeight - 40.0 - self.finishButton.frame.size.height/2.0 - (contentMargin + titleTextViewHeight))
}
self.finishButton.center = CGPoint(x: self.view.frame.width - self.finishButton.frame.size.height/2.0 - 10, y: self.view.frame.height - newKeyboardHeight - self.finishButton.frame.size.height/2.0 - 10)
self.locationTextView.center = CGPoint(x: self.locationTextView.frame.size.width/2.0 + 20.0, y: self.finishButton.center.y)
}, completion: nil)
}
}
================================================
FILE: Example Codes/Diary/Diary_12/Diary/DiaryLabel.swift
================================================
//
// DiaryLabel.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
func sizeHeightWithText(labelText: String,
fontSize: CGFloat,
textAttributes: [NSAttributedString.Key: AnyObject]) -> CGRect {
return labelText.boundingRect(
with: CGSize(width:fontSize, height:480),
options: NSStringDrawingOptions.usesLineFragmentOrigin,
attributes: textAttributes, context: nil)
}
class DiaryLabel: UILabel {
var textAttributes: [NSAttributedString.Key: AnyObject]!
convenience init(fontname:String,
labelText:String,
fontSize : CGFloat,
lineHeight: CGFloat,
color: UIColor){
self.init(frame: CGRect(x:0, y:0, width:0, height:0))
let font = UIFont(name: fontname,
size: fontSize)
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = lineHeight
textAttributes = [NSAttributedString.Key.font: font!,
NSAttributedString.Key.foregroundColor: color,
NSAttributedString.Key.paragraphStyle: paragraphStyle]
let labelSize = sizeHeightWithText(labelText: labelText,
fontSize: fontSize ,
textAttributes: textAttributes)
self.frame = CGRect(x: 0, y: 0, width: labelSize.width,
height: labelSize.height)
self.attributedText = NSAttributedString(
string: labelText,
attributes: textAttributes)
self.lineBreakMode = NSLineBreakMode.byCharWrapping
self.numberOfLines = 0
self.isUserInteractionEnabled = true
}
func updateText(labelText: String) {
let labelSize = sizeHeightWithText(labelText: labelText,
fontSize: self.font.pointSize,
textAttributes: textAttributes)
self.frame = CGRect(x:0,y: 0, width:labelSize.width,
height:labelSize.height)
self.attributedText = NSAttributedString(
string: labelText,
attributes: textAttributes)
}
override func touchesBegan(_ touches: Set, with event: UIEvent?) {
UIView.animate(withDuration: 0.3, delay: 0, options: UIView.AnimationOptions(), animations: {
self.transform = CGAffineTransform(scaleX: 0.9, y: 0.9)
}, completion: nil)
super.touchesBegan(touches, with: event)
}
override func touchesEnded(_ touches: Set, with event: UIEvent?) {
UIView.animate(withDuration: 0.3, delay: 0, options: UIView.AnimationOptions(), animations: {
self.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
}, completion: nil)
super.touchesEnded(touches, with: event)
}
}
================================================
FILE: Example Codes/Diary/Diary_12/Diary/DiaryLayout.swift
================================================
//
// DiaryLayout.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
let screenSize = UIWindow().screen.bounds
class DiaryLayout: UICollectionViewFlowLayout {
var edgeInsets = (screenSize.width - itemWidth)/2.0
override func prepare() {
super.prepare() //准备布局
// Cell 大小
let itemSize = CGSize(width: itemWidth,height: itemHeight)
self.itemSize = itemSize
// Cell 左右间距
self.minimumInteritemSpacing = 0.0
// Cell 行间距
self.minimumLineSpacing = 0
// 增加内嵌
self.sectionInset = UIEdgeInsets(top: (screenSize.height/2.0) - (itemHeight/2.0), left: edgeInsets, bottom: (screenSize.height/2.0) - (itemHeight/2.0), right: 0)
// 滚动方向
scrollDirection = UICollectionView.ScrollDirection.horizontal
}
// 每次Cell的位置发生变化的时候都会执行
// layoutAttributesForElementsInRect询问Cell应该放在什么位置
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
let layoutAttributes = super.layoutAttributesForElements(in: rect)
// 获取所有需要显示的Cell的位置信息
let contentOffset = collectionView!.contentOffset
// 获取collectionView的滑动情况
for attributes in layoutAttributes! {
let center = attributes.center
let cellPositinOnScreen = (center.x - itemWidth/2.0) - contentOffset.x
if cellPositinOnScreen >= (edgeInsets - itemWidth/2.0)
&& cellPositinOnScreen < (edgeInsets
+ collectionViewWidth ) {
// 计算Cell是不是在应该显示的区域
attributes.alpha = 1
} else {
attributes.alpha = 0
}
}
return layoutAttributes
}
override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool {
return true
}
}
func calInsets(numberOfCells: Int) -> UIEdgeInsets {
let insetLeft = (screenSize.width - collectionViewWidth)/2.0
var edgeInsets: CGFloat = 0
if (numberOfCells >= 3) {
edgeInsets = insetLeft
} else {
edgeInsets = insetLeft + (collectionViewWidth - (CGFloat(numberOfCells)*itemWidth))/2.0
}
return UIEdgeInsets(top: (screenSize.height/2.0) - (itemHeight/2.0), left: edgeInsets, bottom: (screenSize.height/2.0) - (itemHeight/2.0), right: 0)
}
================================================
FILE: Example Codes/Diary/Diary_12/Diary/DiaryLocationHelper.swift
================================================
//
// DiaryLocationHelper.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import CoreLocation
class DiaryLocationHelper: NSObject, CLLocationManagerDelegate {
var locationManager:CLLocationManager = CLLocationManager()
var currentLocation:CLLocation?
var address:String?
var geocoder = CLGeocoder()
override init() {
super.init()
// 设置委托
locationManager.delegate = self
// 请求位置授权
locationManager.requestWhenInUseAuthorization()
if (CLLocationManager.locationServicesEnabled()){
//开始获取位置
locationManager.startUpdatingLocation()
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
// 根据经纬度查询位置名称
geocoder.reverseGeocodeLocation(locations[0], completionHandler: { (placemarks, error) in
if let error = error {
print("查询失败: \(error.localizedDescription)")
}
// placemarks里包括了位置的国家、省份、地区等信息
if let pm = placemarks {
if pm.count > 0 {
let placemark = pm.first
self.address = placemark?.locality
// 广播位置信息
NotificationCenter.default.post(name: Notification.Name(rawValue: "DiaryLocationUpdated"), object: self.address)
}
}
})
}
}
================================================
FILE: Example Codes/Diary/Diary_12/Diary/DiaryMonthCollectionViewController.swift
================================================
//
// DiaryMonthCollectionViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
let DiaryRed = UIColor(red: 192.0/255.0, green: 23/255.0, blue: 48.0/255.0, alpha: 1)
class DiaryMonthCollectionViewController: UICollectionViewController {
var year: Int!
var month: Int!
var yearLabel: DiaryLabel!
var monthLabel: DiaryLabel!
var fetchedResultsController : NSFetchedResultsController!
var diarys = [Diary]()
override func viewDidLoad() {
super.viewDidLoad()
let layout = DiaryLayout()
layout.scrollDirection = UICollectionView.ScrollDirection.horizontal
self.collectionView?.setCollectionViewLayout(layout, animated: false)
yearLabel = DiaryLabel(
fontname: "TpldKhangXiDictTrial",
labelText: "二零一五年",
fontSize: 16.0,
lineHeight: 5.0,
color: UIColor.black)
yearLabel.frame = CGRect(x: screenSize.width - yearLabel.frame.size.width - 20, y: 20, width: yearLabel.frame.size.width, height: yearLabel.frame.size.height)
self.view.addSubview(yearLabel)
monthLabel = DiaryLabel(
fontname: "Wyue-GutiFangsong-NC",
labelText: "三月",
fontSize: 16.0,
lineHeight: 5.0,
color: DiaryRed)
monthLabel.frame = CGRect(x: screenSize.width - monthLabel.frame.size.width - 20, y: screenSize.height/2.0 - monthLabel.frame.size.height/2.0, width: monthLabel.frame.size.width, height: monthLabel.frame.size.height)
self.view.addSubview(monthLabel)
// 添加按钮
let composeButton = diaryButtonWith(text: "撰",
fontSize: 14.0,
width: 40.0,
normalImageName: "Oval",
highlightedImageName: "Oval_pressed")
composeButton.center = CGPoint(x: yearLabel.center.x,
y: 38 + yearLabel.frame.size.height + 26.0/2.0)
composeButton.addTarget(self, action: #selector(newCompose),
for: UIControl.Event.touchUpInside)
self.view.addSubview(composeButton)
// 查询数据
do {
// 新建查询
let fetchRequest = NSFetchRequest(entityName:"Diary")
// 增加过滤条件
fetchRequest.predicate = NSPredicate(format:"year = \(year!) AND month = \(month!)")
// 排序方式
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "created_at", ascending: true)]
fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest,
managedObjectContext: managedContext, sectionNameKeyPath: nil,
cacheName: nil)
// 建立委托关系
fetchedResultsController.delegate = self
// 尝试查询
try self.fetchedResultsController.performFetch()
if (fetchedResultsController.fetchedObjects!.count == 0){
print("没有存储结果")
}else{
diarys = fetchedResultsController.fetchedObjects!
}
} catch let error as NSError {
NSLog("发现错误 \(error.localizedDescription)")
}
resetCollectionView()
}
func resetCollectionView() {
let edgeInsets = calInsets(numberOfCells: diarys.count)
if let layout = collectionView!.collectionViewLayout as? DiaryLayout {
layout.edgeInsets = edgeInsets.left
}
self.collectionView!.contentOffset = CGPoint(x: -edgeInsets.left, y: 0)
self.collectionView!.reloadData()
view.layoutIfNeeded()
}
@objc func newCompose() {
let identifier = "DiaryComposeViewController"
let composeViewController = self.storyboard?.instantiateViewController(withIdentifier: identifier)
as! DiaryComposeViewController
self.present(composeViewController,
animated: true,
completion: nil)
}
override func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return diarys.count
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let identifier = "DiaryCell"
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as! DiaryCell
let diary = diarys[indexPath.row]
cell.labelText = diary.title!
return cell
}
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let dvc = self.storyboard?.instantiateViewController(withIdentifier: "DiaryViewController") as! DiaryViewController
dvc.diary = diarys[indexPath.row]
self.navigationController!.pushViewController(dvc, animated: true)
}
}
extension DiaryMonthCollectionViewController: NSFetchedResultsControllerDelegate {
// 响应数据变化
func controller(_ controller: NSFetchedResultsController, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
// 重置数据源
diarys = controller.fetchedObjects! as! [Diary]
// 重载数据
self.collectionView?.reloadData()
// 更新布局
self.collectionView?.setCollectionViewLayout(DiaryLayout(), animated: false)
}
}
================================================
FILE: Example Codes/Diary/Diary_12/Diary/DiaryTemplate.html
================================================
================================================
FILE: Example Codes/Diary/Diary_12/Diary/DiaryViewController.swift
================================================
//
// DiaryViewController.swift
// Diary
//
// Created by kevinzhow on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class DiaryViewController: UIViewController {
var diary:Diary!
var webview: UIWebView!
var saveButton:UIButton!
var deleteButton:UIButton!
var editButton:UIButton!
var buttonsView:UIView!
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
showButtons()
}
func setupUI() {
webview = UIWebView(frame: CGRect(x: 0,y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height))
webview.scrollView.bounces = true
webview.backgroundColor = UIColor.white
self.view.addSubview(self.webview)
// 读取模板的内容
let mainHTML = Bundle.main.url(forResource: "DiaryTemplate", withExtension:"html")
var contents: NSString = ""
do {
contents = try NSString(contentsOfFile: mainHTML!.path, encoding: String.Encoding.utf8.rawValue)
} catch let error as NSError {
print(error)
}
// 生成年的整数类型
let year = (Calendar.current as NSCalendar).component(NSCalendar.Unit.year, from: diary.created_at!)
// 生成月的整数类型
let month = (Calendar.current as NSCalendar).component(NSCalendar.Unit.month, from: diary.created_at!)
// 生成日的整数类型
let day = (Calendar.current as NSCalendar).component(NSCalendar.Unit.day, from: diary.created_at!)
let timeString = "\(numberToChinese(year))年 \(numberToChineseWithUnit(month))月 \(numberToChineseWithUnit(day))日"
// 替换字符串
contents = contents.replacingOccurrences(of: "#timeString#", with: timeString) as NSString
let newDiaryString = diary.content?.replacingOccurrences(of: "\n", with: "
", options: NSString.CompareOptions.literal, range: nil)
contents = contents.replacingOccurrences(of: "#newDiaryString#", with: newDiaryString!) as NSString
var title = ""
var contentWidthOffset = 140
var contentMargin:CGFloat = 10
if let titleStr = diary?.title {
let parsedTime = "\(numberToChineseWithUnit((Calendar.current as NSCalendar).component(NSCalendar.Unit.day, from: diary.created_at!))) 日"
if titleStr != parsedTime {
title = titleStr
contentWidthOffset = 205
contentMargin = 10
title = "\(title)
"
}
}
contents = contents.replacingOccurrences(of: "#contentMargin#", with: "\(contentMargin)") as NSString
contents = contents.replacingOccurrences(of: "#title#", with: title) as NSString
let minWidth = self.view.frame.size.width - CGFloat(contentWidthOffset)
contents = contents.replacingOccurrences(of: "#minWidth#", with: "\(minWidth)") as NSString
let fontStr = defaultFont
contents = contents.replacingOccurrences(of: "#fontStr#", with: fontStr) as NSString
let titleMarginRight:CGFloat = 15
contents = contents.replacingOccurrences(of: "#titleMarginRight#", with: "\(titleMarginRight)") as NSString
if let location = diary.location {
contents = contents.replacingOccurrences(of: "#location#", with: location) as NSString
} else {
contents = contents.replacingOccurrences(of: "#location#", with: "") as NSString
}
webview.loadHTMLString(contents as String, baseURL: nil)
// 添加存改删按钮
buttonsView = UIView(frame: CGRect(x: 0, y: screenSize.height, width: screenSize.width, height: 80.0))
buttonsView.backgroundColor = UIColor.clear
buttonsView.alpha = 0.0
let buttonFontSize:CGFloat = 18.0
saveButton = diaryButtonWith(text: "存", fontSize: buttonFontSize, width: 50.0, normalImageName: "Oval", highlightedImageName: "Oval_pressed")
saveButton.center = CGPoint(x: buttonsView.frame.width/2.0, y: buttonsView.frame.height/2.0)
saveButton.addTarget(self, action: #selector(saveToRoll), for: UIControl.Event.touchUpInside)
buttonsView.addSubview(saveButton)
editButton = diaryButtonWith(text: "改", fontSize: buttonFontSize, width: 50.0, normalImageName: "Oval", highlightedImageName: "Oval_pressed")
editButton.center = CGPoint(x: saveButton.center.x - 56.0, y: saveButton.center.y)
editButton.addTarget(self, action: #selector(editDiary), for: UIControl.Event.touchUpInside)
buttonsView.addSubview(editButton)
deleteButton = diaryButtonWith(text: "刪", fontSize: buttonFontSize, width: 50.0, normalImageName: "Oval", highlightedImageName: "Oval_pressed")
deleteButton.center = CGPoint(x: saveButton.center.x + 56.0, y: saveButton.center.y)
deleteButton.addTarget(self, action: #selector(deleteThisDiary), for: UIControl.Event.touchUpInside)
buttonsView.addSubview(deleteButton)
self.view.addSubview(buttonsView)
// 切换按钮的显示状态
let mTapUpRecognizer = UITapGestureRecognizer(target: self, action: #selector(showButtons))
mTapUpRecognizer.numberOfTapsRequired = 1
mTapUpRecognizer.delegate = self
self.webview.addGestureRecognizer(mTapUpRecognizer)
}
@objc func showButtons() {
if(buttonsView.alpha == 0.0) {
UIView.animate(withDuration: 0.2, delay: 0, options: UIView.AnimationOptions(), animations:
{
self.buttonsView.center = CGPoint(x: self.buttonsView.center.x, y: screenSize.height - self.buttonsView.frame.size.height/2.0)
self.buttonsView.alpha = 1.0
}, completion: nil)
}else{
UIView.animate(withDuration: 0.1, delay: 0, options: UIView.AnimationOptions(), animations:
{
self.buttonsView.center = CGPoint(x: self.buttonsView.center.x, y: screenSize.height + self.buttonsView.frame.size.height/2.0)
self.buttonsView.alpha = 0.0
}, completion: nil)
}
}
@objc func editDiary() {
let composeViewController = self.storyboard?.instantiateViewController(withIdentifier: "DiaryComposeViewController") as! DiaryComposeViewController
if let diary = diary {
composeViewController.diary = diary
}
self.present(composeViewController, animated: true, completion: nil)
}
@objc func saveToRoll() {
let offset = self.webview.scrollView.contentOffset.x
// 针对 WebView 截图
let image = webview.captureView()
self.webview.scrollView.contentOffset.x = offset
// 创建分享对象
var sharingItems = [AnyObject]()
// 给分享对象插入图片
sharingItems.append(image)
// 初始化分享组件
let activityViewController = UIActivityViewController(activityItems: sharingItems, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.saveButton
// 现实分享组件
self.present(activityViewController, animated: true, completion: nil)
}
@objc func deleteThisDiary() {
managedContext.delete(diary)
do {
try managedContext.save()
} catch _ {
}
hideDiary()
}
func hideDiary() {
self.navigationController?.popViewController(animated: true)
}
}
extension DiaryViewController: UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailBy otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
}
================================================
FILE: Example Codes/Diary/Diary_12/Diary/DiaryYearCollectionViewController.swift
================================================
//
// DiaryYearCollectionViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
class DiaryYearCollectionViewController: UICollectionViewController {
var year: Int!
var diarys = [Diary]()
var fetchedResultsController : NSFetchedResultsController!
var monthCount: Int = 1
var sectionsCount: Int = 0
override func viewDidLoad() {
super.viewDidLoad()
let layout = DiaryLayout()
layout.scrollDirection = UICollectionView.ScrollDirection.horizontal
self.collectionView?.setCollectionViewLayout(layout, animated: false)
do {
// 新建查询
let fetchRequest = NSFetchRequest(entityName:"Diary")
// 增加过滤条件
fetchRequest.predicate = NSPredicate(format:"year = \(year!)")
// 排序方式
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "created_at", ascending: true)]
fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest,
managedObjectContext: managedContext, sectionNameKeyPath: "month",
cacheName: nil)
// 尝试查询
try self.fetchedResultsController.performFetch()
if (fetchedResultsController.fetchedObjects!.count == 0){
print("没有存储结果")
}else{
if let sectionsCount = fetchedResultsController.sections?.count {
monthCount = sectionsCount
diarys = fetchedResultsController.fetchedObjects!
}else {
sectionsCount = 0
monthCount = 1
}
}
} catch let error as NSError {
NSLog("发现错误 \(error.localizedDescription)")
}
}
override func numberOfSections(in collectionView: UICollectionView) -> Int {
return monthCount
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 1
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let identifier = "DiaryCell"
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as! DiaryCell
// 获取当前月份
let components = Calendar.current.component(Calendar.Component.month, from: Date())
var month = components
if sectionsCount > 0 {
// 如果程序内有保存的日记,就使用保存的日记的月份
let sectionInfo = fetchedResultsController.sections![indexPath.section]
print("分组信息 \(sectionInfo.name)")
month = Int(sectionInfo.name)!
}
cell.textInt = month
cell.labelText = "\(numberToChinese(cell.textInt)) 月"
// Configure the cell
return cell
}
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
//super.collectionView(collectionView, didSelectItemAt: indexPath as IndexPath)
let identifier = "DiaryMonthCollectionViewController"
let dvc = self.storyboard?.instantiateViewController(withIdentifier: identifier) as! DiaryMonthCollectionViewController // 获取 DiaryMonthCollectionViewController
// 获取当前月份
let components = Calendar.current.component(Calendar.Component.month, from: Date())
var month = components
if sectionsCount > 0 {
// 如果程序内有保存的日记,就使用保存的日记的月份
let sectionInfo = fetchedResultsController.sections![indexPath.section]
print("分组信息 \(sectionInfo.name)")
month = Int(sectionInfo.name)!
}
// 指定是 2015 年的 1 月份
dvc.month = month
dvc.year = year
// 页面跳转
self.navigationController!.pushViewController(dvc, animated: true)
}
}
================================================
FILE: Example Codes/Diary/Diary_12/Diary/Helper.swift
================================================
//
// Helper.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
extension Diary {
func updateTimeWithDate(_ date: Date){
self.created_at = date
self.year = Int32(Calendar.current.component(Calendar.Component.year, from: date))
self.month = Int32(Calendar.current.component(Calendar.Component.month, from: date))
}
}
extension UIWebView {
func captureView() -> UIImage{
// 存储初始大小
let tmpFrame = self.frame
// 新的 Frame
var aFrame = self.frame
aFrame.size.width = self.sizeThatFits(UIScreen.main.bounds.size).width
// 展开 Frame
self.frame = aFrame
// 初始化 ImageContext
UIGraphicsBeginImageContextWithOptions(
self.sizeThatFits(UIScreen.main.bounds.size),
false,
UIScreen.main.scale)
// 创建新的 Context
let resizedContext = UIGraphicsGetCurrentContext()
self.layer.render(in: resizedContext!)
// 重新渲染到新的 resizedContext
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
// 还原 Frame
self.frame = tmpFrame
return image!
}
}
func diaryButtonWith(text: String,
fontSize: CGFloat,
width: CGFloat,
normalImageName: String,
highlightedImageName: String) -> UIButton {
// 创建自定义按钮
let button = UIButton(type: UIButton.ButtonType.custom)
// 设定按钮的大小
button.frame = CGRect(x: 0, y: 0, width: width, height: width)
let font = UIFont(name: "Wyue-GutiFangsong-NC", size: fontSize)
let textAttributes: [NSAttributedString.Key: AnyObject] = [
NSAttributedString.Key.font: font!,
NSAttributedString.Key.foregroundColor: UIColor.white]
// 设置按钮的字体
let attributedText = NSAttributedString(string: text, attributes: textAttributes)
button.setAttributedTitle(attributedText, for: UIControl.State.normal)
// 设置默认按钮的样式
button.setBackgroundImage(UIImage(
named: normalImageName),
for: UIControl.State.normal)
// 设置按钮被按下时的样式
button.setBackgroundImage(UIImage(
named: highlightedImageName),
for: UIControl.State.highlighted)
return button
}
func singleNumberToChinese(_ number:Character) -> String {
switch number {
case "0":
return "零"
case "1":
return "一"
case "2":
return "二"
case "3":
return "三"
case "4":
return "四"
case "5":
return "五"
case "6":
return "六"
case "7":
return "七"
case "8":
return "八"
case "9":
return "九"
default:
return ""
}
}
func numberToChinese(_ number:Int) -> String {
let numbers = String(number)
var finalString = ""
for singleNumber in numbers {
let string = singleNumberToChinese(singleNumber)
finalString = "\(finalString)\(string)"
}
return finalString
}
func numberToChineseWithUnit(_ number:Int) -> String {
let numbers = String(number)
var units = unitParser(numbers.count)
var finalString = ""
for (index, singleNumber) in numbers.enumerated() {
let string = singleNumberToChinese(singleNumber)
if (!(string == "零" && (index+1) == numbers.count)){
finalString = "\(finalString)\(string)\(units[index])"
}
}
return finalString
}
func unitParser(_ unit:Int) -> [String] {
var units = Array(["万","千","百","十",""].reversed())
let parsedUnits = units[0..<(unit)].reversed()
let slicedUnits: ArraySlice = ArraySlice(parsedUnits)
let final: [String] = Array(slicedUnits)
return final
}
================================================
FILE: Example Codes/Diary/Diary_12/Diary/HomeCollectionViewController.swift
================================================
//
// HomeCollectionViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
class HomeCollectionViewController: UICollectionViewController {
var diarys = [Diary]()
var fetchedResultsController : NSFetchedResultsController!
var yearsCount: Int = 1
var sectionsCount: Int = 0
override func viewDidLoad() {
super.viewDidLoad()
let yearLayout = DiaryLayout()
yearLayout.scrollDirection = UICollectionView.ScrollDirection.horizontal
self.collectionView?.setCollectionViewLayout(yearLayout, animated: false)
self.navigationController!.delegate = self
do {
// 新建查询
let fetchRequest = NSFetchRequest(entityName:"Diary")
// 排序方式
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "created_at", ascending: true)]
fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest,
managedObjectContext: managedContext, sectionNameKeyPath: "year",
cacheName: nil)
// 尝试查询
try self.fetchedResultsController.performFetch()
if (fetchedResultsController.fetchedObjects!.count == 0){
print("没有存储结果")
}else{
if let sectionsCount = fetchedResultsController.sections?.count {
yearsCount = sectionsCount
diarys = fetchedResultsController.fetchedObjects!
}else {
sectionsCount = 0
yearsCount = 1
}
}
} catch let error as NSError {
NSLog("发现错误 \(error.localizedDescription)")
}
}
override func numberOfSections(in collectionView: UICollectionView) -> Int {
return yearsCount
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 1
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let identifier = "HomeYearCollectionViewCell"
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as! HomeYearCollectionViewCell
// 获取当前月份
let components = Calendar.current.component(Calendar.Component.year, from: Date())
var year = components
if sectionsCount > 0 {
// 如果程序内有保存的日记,就使用保存的日记的年份
let sectionInfo = fetchedResultsController.sections![indexPath.section]
print("分组信息 \(sectionInfo.name)")
year = Int(sectionInfo.name)!
}
cell.textInt = year
cell.labelText = "\(numberToChinese(cell.textInt)) 年"
// Configure the cell
return cell
}
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
//super.collectionView(collectionView, didSelectItemAt: indexPath as IndexPath)
let identifier = "DiaryYearCollectionViewController"
let dvc = self.storyboard?.instantiateViewController(withIdentifier: identifier) as! DiaryYearCollectionViewController // 获取 DiaryYearCollectionViewController
let components = Calendar.current.component(Calendar.Component.year, from: Date())
var year = components
if sectionsCount > 0 {
let sectionInfo = fetchedResultsController.sections![(indexPath as NSIndexPath).row]
print("Section info \(sectionInfo.name)")
year = Int(sectionInfo.name)!
}
dvc.year = year
self.navigationController!.pushViewController(dvc, animated: true)
}
}
extension HomeCollectionViewController: UINavigationControllerDelegate {
func navigationController(_ navigationController:
UINavigationController,
animationControllerFor operation:
UINavigationController.Operation,
from fromVC: UIViewController,
to toVC: UIViewController) ->
UIViewControllerAnimatedTransitioning? {
let animator = DiaryAnimator()
animator.operation = operation
return animator
}
}
================================================
FILE: Example Codes/Diary/Diary_12/Diary/HomeYearCollectionViewCell.swift
================================================
//
// HomeYearCollectionViewCell.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class HomeYearCollectionViewCell: UICollectionViewCell {
var textLabel: DiaryLabel!
var textInt: Int = 0
var labelText: String = "" {
didSet {
textLabel.updateText(labelText: labelText)
}
}
override func awakeFromNib() {
super.awakeFromNib()
// 界面载入内存
self.textLabel = DiaryLabel(
fontname: "TpldKhangXiDictTrial",
labelText: labelText,
fontSize: 16.0,
lineHeight: 5.0,
color: UIColor.black)
self.contentView.addSubview(textLabel)
}
override func layoutSubviews() {
super.layoutSubviews() // 当对子视图进行布局时
self.textLabel.center = CGPoint(x: itemWidth/2.0, y: 150.0/2.0)
}
}
================================================
FILE: Example Codes/Diary/Diary_12/Diary/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
CFBundleVersion
1
LSRequiresIPhoneOS
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
Main
UIRequiredDeviceCapabilities
armv7
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
UIAppFonts
Wyue-GutiFangsong-NC_deliverable.otf
TpldKhangXiDictTrial.otf
NSLocationWhenInUseUsageDescription
在撰写日志的时候自动添加位置
UISupportedInterfaceOrientations~ipad
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
================================================
FILE: Example Codes/Diary/Diary_12/Diary/ViewController.swift
================================================
//
// ViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
================================================
FILE: Example Codes/Diary/Diary_12/Diary/Wyue-GutiFangsong-NC_deliverable.otf
================================================
[File too large to display: 21.5 MB]
================================================
FILE: Example Codes/Diary/Diary_12/Diary.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
0A5EA7371DB2B0F500B4665B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7361DB2B0F500B4665B /* AppDelegate.swift */; };
0A5EA7391DB2B0F500B4665B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7381DB2B0F500B4665B /* ViewController.swift */; };
0A5EA73C1DB2B0F500B4665B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA73A1DB2B0F500B4665B /* Main.storyboard */; };
0A5EA73E1DB2B0F500B4665B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA73D1DB2B0F500B4665B /* Assets.xcassets */; };
0A5EA7411DB2B0F500B4665B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA73F1DB2B0F500B4665B /* LaunchScreen.storyboard */; };
0A5EA7491DB2B2E200B4665B /* DiaryLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7481DB2B2E200B4665B /* DiaryLabel.swift */; };
0A5EA74F1DB2B81900B4665B /* HomeCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA74E1DB2B81900B4665B /* HomeCollectionViewController.swift */; };
0A5EA7511DB2B98D00B4665B /* HomeYearCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7501DB2B98D00B4665B /* HomeYearCollectionViewCell.swift */; };
0A5EA7551DB2BD1700B4665B /* DiaryLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7541DB2BD1700B4665B /* DiaryLayout.swift */; };
0A5EA75A1DB2C29800B4665B /* TpldKhangXiDictTrial.otf in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA74A1DB2B4BA00B4665B /* TpldKhangXiDictTrial.otf */; };
0A5EA75B1DB2C29B00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA74B1DB2B4BA00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf */; };
0A5EA75D1DB2E5E400B4665B /* DiaryYearCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA75C1DB2E5E400B4665B /* DiaryYearCollectionViewController.swift */; };
0A5EA75F1DB2E9BF00B4665B /* DiaryCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA75E1DB2E9BF00B4665B /* DiaryCell.swift */; };
0A5EA7611DB2EDDC00B4665B /* Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7601DB2EDDC00B4665B /* Helper.swift */; };
0A5EA7631DB2EF3E00B4665B /* DiaryMonthCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7621DB2EF3E00B4665B /* DiaryMonthCollectionViewController.swift */; };
0A5EA7651DB2F82E00B4665B /* DiaryAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7641DB2F82E00B4665B /* DiaryAnimator.swift */; };
0A5EA7671DB30D2000B4665B /* DiaryComposeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7661DB30D2000B4665B /* DiaryComposeViewController.swift */; };
0A5EA7691DB3131E00B4665B /* DiaryLocationHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7681DB3131E00B4665B /* DiaryLocationHelper.swift */; };
0A5EA76F1DB31A8500B4665B /* Diary.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA76D1DB31A8500B4665B /* Diary.xcdatamodeld */; };
9F74CDB71DB3A69300DD10E3 /* DiaryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F74CDB61DB3A69300DD10E3 /* DiaryViewController.swift */; };
9F74CDB91DB3A80700DD10E3 /* DiaryTemplate.html in Resources */ = {isa = PBXBuildFile; fileRef = 9F74CDB81DB3A80700DD10E3 /* DiaryTemplate.html */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
0A5EA7331DB2B0F500B4665B /* Diary.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Diary.app; sourceTree = BUILT_PRODUCTS_DIR; };
0A5EA7361DB2B0F500B4665B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
0A5EA7381DB2B0F500B4665B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
0A5EA73B1DB2B0F500B4665B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
0A5EA73D1DB2B0F500B4665B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
0A5EA7401DB2B0F500B4665B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
0A5EA7421DB2B0F500B4665B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
0A5EA7481DB2B2E200B4665B /* DiaryLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryLabel.swift; sourceTree = ""; };
0A5EA74A1DB2B4BA00B4665B /* TpldKhangXiDictTrial.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = TpldKhangXiDictTrial.otf; sourceTree = ""; };
0A5EA74B1DB2B4BA00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Wyue-GutiFangsong-NC_deliverable.otf"; sourceTree = ""; };
0A5EA74E1DB2B81900B4665B /* HomeCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeCollectionViewController.swift; sourceTree = ""; };
0A5EA7501DB2B98D00B4665B /* HomeYearCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeYearCollectionViewCell.swift; sourceTree = ""; };
0A5EA7541DB2BD1700B4665B /* DiaryLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryLayout.swift; sourceTree = ""; };
0A5EA75C1DB2E5E400B4665B /* DiaryYearCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryYearCollectionViewController.swift; sourceTree = ""; };
0A5EA75E1DB2E9BF00B4665B /* DiaryCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryCell.swift; sourceTree = ""; };
0A5EA7601DB2EDDC00B4665B /* Helper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Helper.swift; sourceTree = ""; };
0A5EA7621DB2EF3E00B4665B /* DiaryMonthCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryMonthCollectionViewController.swift; sourceTree = ""; };
0A5EA7641DB2F82E00B4665B /* DiaryAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryAnimator.swift; sourceTree = ""; };
0A5EA7661DB30D2000B4665B /* DiaryComposeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryComposeViewController.swift; sourceTree = ""; };
0A5EA7681DB3131E00B4665B /* DiaryLocationHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryLocationHelper.swift; sourceTree = ""; };
0A5EA76E1DB31A8500B4665B /* Diary.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Diary.xcdatamodel; sourceTree = ""; };
9F74CDB61DB3A69300DD10E3 /* DiaryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryViewController.swift; sourceTree = ""; };
9F74CDB81DB3A80700DD10E3 /* DiaryTemplate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DiaryTemplate.html; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
0A5EA7301DB2B0F500B4665B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
0A5EA72A1DB2B0F500B4665B = {
isa = PBXGroup;
children = (
0A5EA7351DB2B0F500B4665B /* Diary */,
0A5EA7341DB2B0F500B4665B /* Products */,
);
sourceTree = "";
};
0A5EA7341DB2B0F500B4665B /* Products */ = {
isa = PBXGroup;
children = (
0A5EA7331DB2B0F500B4665B /* Diary.app */,
);
name = Products;
sourceTree = "";
};
0A5EA7351DB2B0F500B4665B /* Diary */ = {
isa = PBXGroup;
children = (
9F74CDB81DB3A80700DD10E3 /* DiaryTemplate.html */,
9F74CDB61DB3A69300DD10E3 /* DiaryViewController.swift */,
0A5EA76D1DB31A8500B4665B /* Diary.xcdatamodeld */,
0A5EA7681DB3131E00B4665B /* DiaryLocationHelper.swift */,
0A5EA7661DB30D2000B4665B /* DiaryComposeViewController.swift */,
0A5EA7641DB2F82E00B4665B /* DiaryAnimator.swift */,
0A5EA7601DB2EDDC00B4665B /* Helper.swift */,
0A5EA7541DB2BD1700B4665B /* DiaryLayout.swift */,
0A5EA74E1DB2B81900B4665B /* HomeCollectionViewController.swift */,
0A5EA75C1DB2E5E400B4665B /* DiaryYearCollectionViewController.swift */,
0A5EA7621DB2EF3E00B4665B /* DiaryMonthCollectionViewController.swift */,
0A5EA75E1DB2E9BF00B4665B /* DiaryCell.swift */,
0A5EA7501DB2B98D00B4665B /* HomeYearCollectionViewCell.swift */,
0A5EA7361DB2B0F500B4665B /* AppDelegate.swift */,
0A5EA7481DB2B2E200B4665B /* DiaryLabel.swift */,
0A5EA7381DB2B0F500B4665B /* ViewController.swift */,
0A5EA73A1DB2B0F500B4665B /* Main.storyboard */,
0A5EA74A1DB2B4BA00B4665B /* TpldKhangXiDictTrial.otf */,
0A5EA74B1DB2B4BA00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf */,
0A5EA73D1DB2B0F500B4665B /* Assets.xcassets */,
0A5EA73F1DB2B0F500B4665B /* LaunchScreen.storyboard */,
0A5EA7421DB2B0F500B4665B /* Info.plist */,
);
path = Diary;
sourceTree = "";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
0A5EA7321DB2B0F500B4665B /* Diary */ = {
isa = PBXNativeTarget;
buildConfigurationList = 0A5EA7451DB2B0F500B4665B /* Build configuration list for PBXNativeTarget "Diary" */;
buildPhases = (
0A5EA72F1DB2B0F500B4665B /* Sources */,
0A5EA7301DB2B0F500B4665B /* Frameworks */,
0A5EA7311DB2B0F500B4665B /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = Diary;
productName = Diary;
productReference = 0A5EA7331DB2B0F500B4665B /* Diary.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
0A5EA72B1DB2B0F500B4665B /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0800;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = kevinzhow;
TargetAttributes = {
0A5EA7321DB2B0F500B4665B = {
CreatedOnToolsVersion = 8.0;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 0A5EA72E1DB2B0F500B4665B /* Build configuration list for PBXProject "Diary" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 0A5EA72A1DB2B0F500B4665B;
productRefGroup = 0A5EA7341DB2B0F500B4665B /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
0A5EA7321DB2B0F500B4665B /* Diary */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
0A5EA7311DB2B0F500B4665B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0A5EA7411DB2B0F500B4665B /* LaunchScreen.storyboard in Resources */,
0A5EA75A1DB2C29800B4665B /* TpldKhangXiDictTrial.otf in Resources */,
9F74CDB91DB3A80700DD10E3 /* DiaryTemplate.html in Resources */,
0A5EA73E1DB2B0F500B4665B /* Assets.xcassets in Resources */,
0A5EA73C1DB2B0F500B4665B /* Main.storyboard in Resources */,
0A5EA75B1DB2C29B00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
0A5EA72F1DB2B0F500B4665B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0A5EA7391DB2B0F500B4665B /* ViewController.swift in Sources */,
0A5EA75D1DB2E5E400B4665B /* DiaryYearCollectionViewController.swift in Sources */,
0A5EA74F1DB2B81900B4665B /* HomeCollectionViewController.swift in Sources */,
0A5EA7691DB3131E00B4665B /* DiaryLocationHelper.swift in Sources */,
0A5EA7631DB2EF3E00B4665B /* DiaryMonthCollectionViewController.swift in Sources */,
0A5EA75F1DB2E9BF00B4665B /* DiaryCell.swift in Sources */,
0A5EA7371DB2B0F500B4665B /* AppDelegate.swift in Sources */,
0A5EA7671DB30D2000B4665B /* DiaryComposeViewController.swift in Sources */,
0A5EA7611DB2EDDC00B4665B /* Helper.swift in Sources */,
0A5EA7491DB2B2E200B4665B /* DiaryLabel.swift in Sources */,
0A5EA7511DB2B98D00B4665B /* HomeYearCollectionViewCell.swift in Sources */,
9F74CDB71DB3A69300DD10E3 /* DiaryViewController.swift in Sources */,
0A5EA76F1DB31A8500B4665B /* Diary.xcdatamodeld in Sources */,
0A5EA7651DB2F82E00B4665B /* DiaryAnimator.swift in Sources */,
0A5EA7551DB2BD1700B4665B /* DiaryLayout.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
0A5EA73A1DB2B0F500B4665B /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
0A5EA73B1DB2B0F500B4665B /* Base */,
);
name = Main.storyboard;
sourceTree = "";
};
0A5EA73F1DB2B0F500B4665B /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
0A5EA7401DB2B0F500B4665B /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
0A5EA7431DB2B0F500B4665B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
0A5EA7441DB2B0F500B4665B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
0A5EA7461DB2B0F500B4665B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Diary/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = kevinzhow.Diary;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
};
name = Debug;
};
0A5EA7471DB2B0F500B4665B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Diary/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = kevinzhow.Diary;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
0A5EA72E1DB2B0F500B4665B /* Build configuration list for PBXProject "Diary" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0A5EA7431DB2B0F500B4665B /* Debug */,
0A5EA7441DB2B0F500B4665B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0A5EA7451DB2B0F500B4665B /* Build configuration list for PBXNativeTarget "Diary" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0A5EA7461DB2B0F500B4665B /* Debug */,
0A5EA7471DB2B0F500B4665B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCVersionGroup section */
0A5EA76D1DB31A8500B4665B /* Diary.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
0A5EA76E1DB31A8500B4665B /* Diary.xcdatamodel */,
);
currentVersion = 0A5EA76E1DB31A8500B4665B /* Diary.xcdatamodel */;
path = Diary.xcdatamodeld;
sourceTree = "";
versionGroupType = wrapper.xcdatamodel;
};
/* End XCVersionGroup section */
};
rootObject = 0A5EA72B1DB2B0F500B4665B /* Project object */;
}
================================================
FILE: Example Codes/Diary/Diary_12/Diary.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
================================================
FILE: Example Codes/Diary/Diary_12/Diary.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
================================================
IDEDidComputeMac32BitWarning
================================================
FILE: Example Codes/Diary/Diary_12/Diary.xcodeproj/xcuserdata/kevin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
================================================
================================================
FILE: Example Codes/Diary/Diary_12/Diary.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/Diary.xcscheme
================================================
================================================
FILE: Example Codes/Diary/Diary_12/Diary.xcodeproj/xcuserdata/kevin.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Diary.xcscheme
orderHint
0
SuppressBuildableAutocreation
0A5EA7321DB2B0F500B4665B
primary
================================================
FILE: Example Codes/Diary/Diary_12/Diary.xcodeproj/xcuserdata/kevinzhow.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
================================================
================================================
FILE: Example Codes/Diary/Diary_12/Diary.xcodeproj/xcuserdata/kevinzhow.xcuserdatad/xcschemes/Diary.xcscheme
================================================
================================================
FILE: Example Codes/Diary/Diary_12/Diary.xcodeproj/xcuserdata/kevinzhow.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Diary.xcscheme
orderHint
0
SuppressBuildableAutocreation
0A5EA7321DB2B0F500B4665B
primary
================================================
FILE: Example Codes/Diary/Diary_12/Diary.xcodeproj/xcuserdata/zhoukaiwen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
================================================
================================================
FILE: Example Codes/Diary/Diary_12/Diary.xcodeproj/xcuserdata/zhoukaiwen.xcuserdatad/xcschemes/xcschememanagement.plist
================================================
SchemeUserState
Diary.xcscheme_^#shared#^_
orderHint
0
================================================
FILE: Example Codes/Diary/Diary_13/Diary/AppDelegate.swift
================================================
//
// AppDelegate.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
// Coredata
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let managedContext = appDelegate.managedObjectContext!
let itemHeight: CGFloat = 150.0
// Cell的高度
let itemWidth: CGFloat = 60
// Cell的宽度
let collectionViewWidth = itemWidth * 3
// 同时显示3个Cell时候
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
lazy var managedObjectModel: NSManagedObjectModel = {
// 描述数据模型描述文件存储位置
let modelURL = Bundle.main.url(forResource: "Diary", withExtension: "momd")!
return NSManagedObjectModel(contentsOf: modelURL)!
}()
lazy var applicationDocumentsDirectory: URL = {
// 数据库文件的存放文件夹
let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
return urls[urls.count-1]
}()
lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator? = {
// 通过 managedObjectModel 创建持久化管理
var coordinator: NSPersistentStoreCoordinator? =
NSPersistentStoreCoordinator(managedObjectModel:
self.managedObjectModel)
let url = self.applicationDocumentsDirectory.appendingPathComponent("Diary.sqlite")
// 设定数据库存储位置
var error: NSError? = nil
var failureReason = "载入程序存储的数据出错."
do {
try coordinator!.addPersistentStore(
ofType: NSSQLiteStoreType, configurationName: nil,
at: url, options: nil)
// 创建NSSQLiteStoreType类型持久化存储
} catch var error1 as NSError {
error = error1
coordinator = nil
// 报告错误
var dict = [String: AnyObject]()
dict[NSLocalizedDescriptionKey] = "无法初始化程序存储的数据" as AnyObject?
dict[NSLocalizedFailureReasonErrorKey] = failureReason as AnyObject?
dict[NSUnderlyingErrorKey] = error
error = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
NSLog("发现错误 \(error), \(error!.userInfo)")
abort()
} catch {
fatalError()
}
return coordinator
}()
lazy var managedObjectContext: NSManagedObjectContext? = {
let coordinator = self.persistentStoreCoordinator
if coordinator == nil {
return nil
}
var managedObjectContext = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
managedObjectContext.persistentStoreCoordinator = coordinator
return managedObjectContext
}()
}
================================================
FILE: Example Codes/Diary/Diary_13/Diary/Assets.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Diary/Diary_13/Diary/Assets.xcassets/Contents.json
================================================
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Diary/Diary_13/Diary/Assets.xcassets/Oval.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"filename" : "Oval.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Oval@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Oval@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Diary/Diary_13/Diary/Assets.xcassets/Oval_pressed.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"filename" : "Oval_pressed.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Oval_pressed@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Oval_pressed@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Example Codes/Diary/Diary_13/Diary/Base.lproj/LaunchScreen.storyboard
================================================
================================================
FILE: Example Codes/Diary/Diary_13/Diary/Base.lproj/Main.storyboard
================================================
================================================
FILE: Example Codes/Diary/Diary_13/Diary/Diary.xcdatamodeld/Diary.xcdatamodel/contents
================================================
================================================
FILE: Example Codes/Diary/Diary_13/Diary/DiaryAnimator.swift
================================================
//
// DiaryAnimator.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class DiaryAnimator: NSObject, UIViewControllerAnimatedTransitioning {
var operation: UINavigationController.Operation!
// 转场时长
func transitionDuration(using transitionContext:
UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.4
}
func animateTransition(using transitionContext:
UIViewControllerContextTransitioning)
{
// 获取转场舞台
let containerView = transitionContext.containerView
let fromVC = transitionContext.viewController(
forKey: UITransitionContextViewControllerKey.from)
// 获取从哪个场景开始转
let fromView = fromVC!.view
let toVC = transitionContext.viewController(
forKey: UITransitionContextViewControllerKey.to)
// 获取要转去哪个场景
let toView = toVC!.view
// 设置新场景透明度
toView?.alpha = 0.0
// UINavigationControllerOperation.Pop用来判断是转入还是转出
if operation == UINavigationController.Operation.pop {
// 如果是返回旧场景,那么设置要转入的场景初始缩放为原始大小
toView?.transform = CGAffineTransform(scaleX: 1.0,y: 1.0)
}else{
// 如果是转到新场景,设置新场景初始缩放为0.3
toView?.transform = CGAffineTransform(scaleX: 0.3,y: 0.3);
}
// 在舞台上插入场景
containerView.insertSubview(toView!, aboveSubview: fromView!)
UIView.animate(
withDuration: transitionDuration(using: transitionContext),
delay: 0,
options: UIView.AnimationOptions.curveEaseInOut,
animations:
{
if self.operation == UINavigationController.Operation.pop {
// 放大要转出的场景
fromView?.transform = CGAffineTransform(scaleX: 3.3,y: 3.3)
} else {
// 设置新场景为原始大小
toView?.transform = CGAffineTransform(scaleX: 1.0,y: 1.0)
}
toView?.alpha = 1.0
}, completion: { finished in
// 通知NavigationController已经完成转场
transitionContext.completeTransition(true)
})
}
}
================================================
FILE: Example Codes/Diary/Diary_13/Diary/DiaryCell.swift
================================================
//
// DiaryCell.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class DiaryCell: UICollectionViewCell {
var textLabel: DiaryLabel!
var textInt: Int = 0
var labelText: String = "" {
didSet {
textLabel.updateText(labelText: labelText)
}
}
override func awakeFromNib() {
super.awakeFromNib()
// 界面载入内存
self.textLabel = DiaryLabel(
fontname: "Wyue-GutiFangsong-NC",
labelText: labelText,
fontSize: 16.0,
lineHeight: 5.0,
color: UIColor.black)
self.contentView.addSubview(textLabel)
}
override func layoutSubviews() {
super.layoutSubviews() // 当对子视图进行布局时
self.textLabel.center = CGPoint(x: itemWidth/2.0, y: 150.0/2.0)
}
}
================================================
FILE: Example Codes/Diary/Diary_13/Diary/DiaryComposeViewController.swift
================================================
//
// DiaryComposeViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
let titleTextViewHeight:CGFloat = 30.0
let contentMargin:CGFloat = 20.0
var defaultFont = "Wyue-GutiFangsong-NC"
let DiaryFont = UIFont(name: defaultFont, size: 18)!
let DiaryLocationFont = UIFont(name: defaultFont, size: 16)!
let DiaryTitleFont = UIFont(name: defaultFont, size: 18)!
class DiaryComposeViewController: UIViewController {
var diary: Diary?
var composeView:UITextView!
var locationTextView:UITextView!
var titleTextView:UITextView!
var finishButton:UIButton!
var keyboardSize:CGSize = CGSize(width: 0, height: 0)
var locationHelper: DiaryLocationHelper = DiaryLocationHelper()
override func viewDidLoad() {
super.viewDidLoad()
// 创建正文输入框
composeView = UITextView(frame: CGRect(x: 0, y: contentMargin + titleTextViewHeight, width: screenSize.width, height: screenSize.height))
composeView.font = DiaryFont
composeView.isEditable = true
composeView.isUserInteractionEnabled = true
composeView.textContainerInset = UIEdgeInsets(top: contentMargin, left: contentMargin, bottom: contentMargin, right: contentMargin)
// 创建地址输入框
locationTextView = UITextView(frame: CGRect(x: 0, y: composeView.frame.size.height - 30.0, width: screenSize.width - 60.0, height: 30.0))
locationTextView.font = DiaryLocationFont
locationTextView.isEditable = true
locationTextView.isUserInteractionEnabled = true
locationTextView.bounces = false
// 创建标题输入框
titleTextView = UITextView(frame: CGRect(x: contentMargin, y: contentMargin/2, width: screenSize.width - 60.0, height: titleTextViewHeight))
titleTextView.font = DiaryTitleFont
titleTextView.isEditable = true
titleTextView.isUserInteractionEnabled = true
titleTextView.bounces = false
self.view.addSubview(composeView)
self.view.addSubview(locationTextView)
self.view.addSubview(titleTextView)
if let diary = diary {
composeView.text = diary.content
locationTextView.text = diary.location
if let title = diary.title {
titleTextView.text = title
}
}
// 创建完成按钮
finishButton = diaryButtonWith(text: "完", fontSize: 18.0, width: 50.0, normalImageName: "Oval", highlightedImageName: "Oval_pressed")
finishButton.center = CGPoint(x: screenSize.width - 20, y: screenSize.height - 30)
self.view.addSubview(finishButton)
self.finishButton.center = CGPoint(x: self.view.frame.width - self.finishButton.frame.size.height/2.0 - 10, y: self.view.frame.height - self.finishButton.frame.size.height/2.0 - 10)
self.finishButton.addTarget(self, action: #selector(finishCompose(_:)), for: UIControl.Event.touchUpInside)
self.locationTextView.center = CGPoint(x: self.locationTextView.frame.size.width/2.0 + 20.0, y: self.finishButton.center.y)
// 监听键盘事件
NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidShow(_:)), name: UIWindow.keyboardDidShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(updateAddress(_:)), name: NSNotification.Name(rawValue: "DiaryLocationUpdated"), object: nil)
}
@objc func finishCompose(_ button: UIButton) {
// 取消输入框的编辑状态,收起键盘
self.composeView.endEditing(true)
self.locationTextView.endEditing(true)
// 确保有文字内容才保存
if (composeView.text.lengthOfBytes(using: String.Encoding.utf8) > 1){
// 如果是修改 Diary,则保存到原日记中
if let diary = diary {
diary.content = composeView.text
diary.location = locationTextView.text
diary.title = titleTextView.text
}else{
let entity = NSEntityDescription.entity(forEntityName: "Diary", in: managedContext)
let newdiary = Diary(entity: entity!,
insertInto:managedContext)
newdiary.content = composeView.text
if let address = locationHelper.address {
newdiary.location = address
}
if let title = titleTextView.text {
newdiary.title = title
}
newdiary.updateTimeWithDate(Date())
}
do {
try managedContext.save()
} catch let error as NSError {
print("Could not save \(error.description)")
}
}
self.dismiss(animated: true, completion: nil)
}
@objc func updateAddress(_ notification: Notification) {
if let address = notification.object as? String {
locationTextView.text = "于 \(address)"
locationHelper.locationManager.stopUpdatingLocation()
}
}
@objc func keyboardDidShow(_ notification: Notification) {
// 取出键盘的高度
if let rectValue = (notification as NSNotification).userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue {
keyboardSize = rectValue.cgRectValue.size
//更新完成按钮和地址输入框的位置
updateTextViewSizeForKeyboardHeight(keyboardSize.height)
}
}
func updateTextViewSizeForKeyboardHeight(_ keyboardHeight: CGFloat) {
let newKeyboardHeight = keyboardHeight
UIView.animate(withDuration: 1.0, delay: 0, options: UIView.AnimationOptions(), animations:
{
if (self.locationTextView.text == nil) {
self.composeView.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height - newKeyboardHeight)
}else{
self.composeView.frame = CGRect(x: 0, y: contentMargin + titleTextViewHeight, width: self.composeView.frame.size.width, height: self.view.frame.height - newKeyboardHeight - 40.0 - self.finishButton.frame.size.height/2.0 - (contentMargin + titleTextViewHeight))
}
self.finishButton.center = CGPoint(x: self.view.frame.width - self.finishButton.frame.size.height/2.0 - 10, y: self.view.frame.height - newKeyboardHeight - self.finishButton.frame.size.height/2.0 - 10)
self.locationTextView.center = CGPoint(x: self.locationTextView.frame.size.width/2.0 + 20.0, y: self.finishButton.center.y)
}, completion: nil)
}
}
================================================
FILE: Example Codes/Diary/Diary_13/Diary/DiaryLabel.swift
================================================
//
// DiaryLabel.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import pop
func sizeHeightWithText(labelText: String,
fontSize: CGFloat,
textAttributes: [NSAttributedString.Key: AnyObject]) -> CGRect {
return labelText.boundingRect(
with: CGSize(width:fontSize, height:480),
options: NSStringDrawingOptions.usesLineFragmentOrigin,
attributes: textAttributes, context: nil)
}
class DiaryLabel: UILabel {
var textAttributes: [NSAttributedString.Key: AnyObject]!
convenience init(fontname:String,
labelText:String,
fontSize : CGFloat,
lineHeight: CGFloat,
color: UIColor){
self.init(frame: CGRect(x:0, y:0, width:0, height:0))
let font = UIFont(name: fontname,
size: fontSize)
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = lineHeight
textAttributes = [NSAttributedString.Key.font: font!,
NSAttributedString.Key.foregroundColor: color,
NSAttributedString.Key.paragraphStyle: paragraphStyle]
let labelSize = sizeHeightWithText(labelText: labelText,
fontSize: fontSize ,
textAttributes: textAttributes)
self.frame = CGRect(x: 0, y: 0, width: labelSize.width,
height: labelSize.height)
self.attributedText = NSAttributedString(
string: labelText,
attributes: textAttributes)
self.lineBreakMode = NSLineBreakMode.byCharWrapping
self.numberOfLines = 0
self.isUserInteractionEnabled = true
}
func updateText(labelText: String) {
let labelSize = sizeHeightWithText(labelText: labelText,
fontSize: self.font.pointSize,
textAttributes: textAttributes)
self.frame = CGRect(x:0,y: 0, width:labelSize.width,
height:labelSize.height)
self.attributedText = NSAttributedString(
string: labelText,
attributes: textAttributes)
}
override func touchesBegan(_ touches: Set, with event: UIEvent?) {
// 使用Pop对其进行缩放
let anim = POPSpringAnimation(propertyNamed: kPOPLayerScaleXY)
anim?.springBounciness = 10
anim?.springSpeed = 15
anim?.fromValue = NSValue(cgPoint: CGPoint(x: 1.0, y: 1.0))
anim?.toValue = NSValue(cgPoint: CGPoint(x: 0.9, y: 0.9))
self.layer.pop_add(anim, forKey: "PopScale")
super.touchesBegan(touches, with: event)
}
override func touchesEnded(_ touches: Set, with event: UIEvent?) {
// 使用Pop对其进行缩放
let anim = POPSpringAnimation(propertyNamed: kPOPLayerScaleXY)
anim?.springBounciness = 10
anim?.springSpeed = 15
anim?.fromValue = NSValue(cgPoint: CGPoint(x: 0.9, y: 0.9))
anim?.toValue = NSValue(cgPoint: CGPoint(x: 1.0, y: 1.0))
self.layer.pop_add(anim, forKey: "PopScale")
super.touchesEnded(touches, with: event)
}
}
================================================
FILE: Example Codes/Diary/Diary_13/Diary/DiaryLayout.swift
================================================
//
// DiaryLayout.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
let screenSize = UIWindow().screen.bounds
class DiaryLayout: UICollectionViewFlowLayout {
var edgeInsets = (screenSize.width - itemWidth)/2.0
override func prepare() {
super.prepare() //准备布局
// Cell 大小
let itemSize = CGSize(width: itemWidth,height: itemHeight)
self.itemSize = itemSize
// Cell 左右间距
self.minimumInteritemSpacing = 0.0
// Cell 行间距
self.minimumLineSpacing = 0
// 增加内嵌
self.sectionInset = UIEdgeInsets(top: (screenSize.height/2.0) - (itemHeight/2.0), left: edgeInsets, bottom: (screenSize.height/2.0) - (itemHeight/2.0), right: 0)
// 滚动方向
scrollDirection = UICollectionView.ScrollDirection.horizontal
}
// 每次Cell的位置发生变化的时候都会执行
// layoutAttributesForElementsInRect询问Cell应该放在什么位置
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
let layoutAttributes = super.layoutAttributesForElements(in: rect)
// 获取所有需要显示的Cell的位置信息
let contentOffset = collectionView!.contentOffset
// 获取collectionView的滑动情况
for attributes in layoutAttributes! {
let center = attributes.center
let cellPositinOnScreen = (center.x - itemWidth/2.0) - contentOffset.x
if cellPositinOnScreen >= (edgeInsets - itemWidth/2.0)
&& cellPositinOnScreen < (edgeInsets
+ collectionViewWidth ) {
// 计算Cell是不是在应该显示的区域
attributes.alpha = 1
} else {
attributes.alpha = 0
}
}
return layoutAttributes
}
override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool {
return true
}
}
func calInsets(numberOfCells: Int) -> UIEdgeInsets {
let insetLeft = (screenSize.width - collectionViewWidth)/2.0
var edgeInsets: CGFloat = 0
if (numberOfCells >= 3) {
edgeInsets = insetLeft
} else {
edgeInsets = insetLeft + (collectionViewWidth - (CGFloat(numberOfCells)*itemWidth))/2.0
}
return UIEdgeInsets(top: (screenSize.height/2.0) - (itemHeight/2.0), left: edgeInsets, bottom: (screenSize.height/2.0) - (itemHeight/2.0), right: 0)
}
================================================
FILE: Example Codes/Diary/Diary_13/Diary/DiaryLocationHelper.swift
================================================
//
// DiaryLocationHelper.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import CoreLocation
class DiaryLocationHelper: NSObject, CLLocationManagerDelegate {
var locationManager:CLLocationManager = CLLocationManager()
var currentLocation:CLLocation?
var address:String?
var geocoder = CLGeocoder()
override init() {
super.init()
// 设置委托
locationManager.delegate = self
// 请求位置授权
locationManager.requestWhenInUseAuthorization()
if (CLLocationManager.locationServicesEnabled()){
//开始获取位置
locationManager.startUpdatingLocation()
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
// 根据经纬度查询位置名称
geocoder.reverseGeocodeLocation(locations[0], completionHandler: { (placemarks, error) in
if let error = error {
print("查询失败: \(error.localizedDescription)")
}
// placemarks里包括了位置的国家、省份、地区等信息
if let pm = placemarks {
if pm.count > 0 {
let placemark = pm.first
self.address = placemark?.locality
// 广播位置信息
NotificationCenter.default.post(name: Notification.Name(rawValue: "DiaryLocationUpdated"), object: self.address)
}
}
})
}
}
================================================
FILE: Example Codes/Diary/Diary_13/Diary/DiaryMonthCollectionViewController.swift
================================================
//
// DiaryMonthCollectionViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
let DiaryRed = UIColor(red: 192.0/255.0, green: 23/255.0, blue: 48.0/255.0, alpha: 1)
class DiaryMonthCollectionViewController: UICollectionViewController {
var year: Int!
var month: Int!
var yearLabel: DiaryLabel!
var monthLabel: DiaryLabel!
var fetchedResultsController : NSFetchedResultsController!
var diarys = [Diary]()
override func viewDidLoad() {
super.viewDidLoad()
let layout = DiaryLayout()
layout.scrollDirection = UICollectionView.ScrollDirection.horizontal
self.collectionView?.setCollectionViewLayout(layout, animated: false)
yearLabel = DiaryLabel(
fontname: "TpldKhangXiDictTrial",
labelText: "二零一五年",
fontSize: 16.0,
lineHeight: 5.0,
color: UIColor.black)
yearLabel.frame = CGRect(x: screenSize.width - yearLabel.frame.size.width - 20, y: 20, width: yearLabel.frame.size.width, height: yearLabel.frame.size.height)
self.view.addSubview(yearLabel)
monthLabel = DiaryLabel(
fontname: "Wyue-GutiFangsong-NC",
labelText: "三月",
fontSize: 16.0,
lineHeight: 5.0,
color: DiaryRed)
monthLabel.frame = CGRect(x: screenSize.width - monthLabel.frame.size.width - 20, y: screenSize.height/2.0 - monthLabel.frame.size.height/2.0, width: monthLabel.frame.size.width, height: monthLabel.frame.size.height)
self.view.addSubview(monthLabel)
// 添加按钮
let composeButton = diaryButtonWith(text: "撰",
fontSize: 14.0,
width: 40.0,
normalImageName: "Oval",
highlightedImageName: "Oval_pressed")
composeButton.center = CGPoint(x: yearLabel.center.x,
y: 38 + yearLabel.frame.size.height + 26.0/2.0)
composeButton.addTarget(self, action: #selector(newCompose),
for: UIControl.Event.touchUpInside)
self.view.addSubview(composeButton)
// 查询数据
do {
// 新建查询
let fetchRequest = NSFetchRequest(entityName:"Diary")
// 增加过滤条件
fetchRequest.predicate = NSPredicate(format:"year = \(year!) AND month = \(month!)")
// 排序方式
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "created_at", ascending: true)]
fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest,
managedObjectContext: managedContext, sectionNameKeyPath: nil,
cacheName: nil)
// 建立委托关系
fetchedResultsController.delegate = self
// 尝试查询
try self.fetchedResultsController.performFetch()
if (fetchedResultsController.fetchedObjects!.count == 0){
print("没有存储结果")
}else{
diarys = fetchedResultsController.fetchedObjects!
}
} catch let error as NSError {
NSLog("发现错误 \(error.localizedDescription)")
}
resetCollectionView()
}
func resetCollectionView() {
let edgeInsets = calInsets(numberOfCells: diarys.count)
if let layout = collectionView!.collectionViewLayout as? DiaryLayout {
layout.edgeInsets = edgeInsets.left
}
self.collectionView!.contentOffset = CGPoint(x: -edgeInsets.left, y: 0)
self.collectionView!.reloadData()
view.layoutIfNeeded()
}
@objc func newCompose() {
let identifier = "DiaryComposeViewController"
let composeViewController = self.storyboard?.instantiateViewController(withIdentifier: identifier)
as! DiaryComposeViewController
self.present(composeViewController,
animated: true,
completion: nil)
}
override func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return diarys.count
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let identifier = "DiaryCell"
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as! DiaryCell
let diary = diarys[indexPath.row]
cell.labelText = diary.title!
return cell
}
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let dvc = self.storyboard?.instantiateViewController(withIdentifier: "DiaryViewController") as! DiaryViewController
dvc.diary = diarys[indexPath.row]
self.navigationController!.pushViewController(dvc, animated: true)
}
}
extension DiaryMonthCollectionViewController: NSFetchedResultsControllerDelegate {
// 响应数据变化
func controller(_ controller: NSFetchedResultsController, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
// 重置数据源
diarys = controller.fetchedObjects! as! [Diary]
// 重载数据
self.collectionView?.reloadData()
// 更新布局
self.collectionView?.setCollectionViewLayout(DiaryLayout(), animated: false)
}
}
================================================
FILE: Example Codes/Diary/Diary_13/Diary/DiaryTemplate.html
================================================
================================================
FILE: Example Codes/Diary/Diary_13/Diary/DiaryViewController.swift
================================================
//
// DiaryViewController.swift
// Diary
//
// Created by kevinzhow on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class DiaryViewController: UIViewController {
var diary:Diary!
var webview: UIWebView!
var saveButton:UIButton!
var deleteButton:UIButton!
var editButton:UIButton!
var buttonsView:UIView!
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
showButtons()
}
func setupUI() {
webview = UIWebView(frame: CGRect(x: 0,y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height))
webview.scrollView.bounces = true
webview.backgroundColor = UIColor.white
self.view.addSubview(self.webview)
// 读取模板的内容
let mainHTML = Bundle.main.url(forResource: "DiaryTemplate", withExtension:"html")
var contents: NSString = ""
do {
contents = try NSString(contentsOfFile: mainHTML!.path, encoding: String.Encoding.utf8.rawValue)
} catch let error as NSError {
print(error)
}
// 生成年的整数类型
let year = (Calendar.current as NSCalendar).component(NSCalendar.Unit.year, from: diary.created_at!)
// 生成月的整数类型
let month = (Calendar.current as NSCalendar).component(NSCalendar.Unit.month, from: diary.created_at!)
// 生成日的整数类型
let day = (Calendar.current as NSCalendar).component(NSCalendar.Unit.day, from: diary.created_at!)
let timeString = "\(numberToChinese(year))年 \(numberToChineseWithUnit(month))月 \(numberToChineseWithUnit(day))日"
// 替换字符串
contents = contents.replacingOccurrences(of: "#timeString#", with: timeString) as NSString
let newDiaryString = diary.content?.replacingOccurrences(of: "\n", with: "
", options: NSString.CompareOptions.literal, range: nil)
contents = contents.replacingOccurrences(of: "#newDiaryString#", with: newDiaryString!) as NSString
var title = ""
var contentWidthOffset = 140
var contentMargin:CGFloat = 10
if let titleStr = diary?.title {
let parsedTime = "\(numberToChineseWithUnit((Calendar.current as NSCalendar).component(NSCalendar.Unit.day, from: diary.created_at!))) 日"
if titleStr != parsedTime {
title = titleStr
contentWidthOffset = 205
contentMargin = 10
title = "\(title)
"
}
}
contents = contents.replacingOccurrences(of: "#contentMargin#", with: "\(contentMargin)") as NSString
contents = contents.replacingOccurrences(of: "#title#", with: title) as NSString
let minWidth = self.view.frame.size.width - CGFloat(contentWidthOffset)
contents = contents.replacingOccurrences(of: "#minWidth#", with: "\(minWidth)") as NSString
let fontStr = defaultFont
contents = contents.replacingOccurrences(of: "#fontStr#", with: fontStr) as NSString
let titleMarginRight:CGFloat = 15
contents = contents.replacingOccurrences(of: "#titleMarginRight#", with: "\(titleMarginRight)") as NSString
if let location = diary.location {
contents = contents.replacingOccurrences(of: "#location#", with: location) as NSString
} else {
contents = contents.replacingOccurrences(of: "#location#", with: "") as NSString
}
webview.loadHTMLString(contents as String, baseURL: nil)
// 添加存改删按钮
buttonsView = UIView(frame: CGRect(x: 0, y: screenSize.height, width: screenSize.width, height: 80.0))
buttonsView.backgroundColor = UIColor.clear
buttonsView.alpha = 0.0
let buttonFontSize:CGFloat = 18.0
saveButton = diaryButtonWith(text: "存", fontSize: buttonFontSize, width: 50.0, normalImageName: "Oval", highlightedImageName: "Oval_pressed")
saveButton.center = CGPoint(x: buttonsView.frame.width/2.0, y: buttonsView.frame.height/2.0)
saveButton.addTarget(self, action: #selector(saveToRoll), for: UIControl.Event.touchUpInside)
buttonsView.addSubview(saveButton)
editButton = diaryButtonWith(text: "改", fontSize: buttonFontSize, width: 50.0, normalImageName: "Oval", highlightedImageName: "Oval_pressed")
editButton.center = CGPoint(x: saveButton.center.x - 56.0, y: saveButton.center.y)
editButton.addTarget(self, action: #selector(editDiary), for: UIControl.Event.touchUpInside)
buttonsView.addSubview(editButton)
deleteButton = diaryButtonWith(text: "刪", fontSize: buttonFontSize, width: 50.0, normalImageName: "Oval", highlightedImageName: "Oval_pressed")
deleteButton.center = CGPoint(x: saveButton.center.x + 56.0, y: saveButton.center.y)
deleteButton.addTarget(self, action: #selector(deleteThisDiary), for: UIControl.Event.touchUpInside)
buttonsView.addSubview(deleteButton)
self.view.addSubview(buttonsView)
// 切换按钮的显示状态
let mTapUpRecognizer = UITapGestureRecognizer(target: self, action: #selector(showButtons))
mTapUpRecognizer.numberOfTapsRequired = 1
mTapUpRecognizer.delegate = self
self.webview.addGestureRecognizer(mTapUpRecognizer)
}
@objc func showButtons() {
if(buttonsView.alpha == 0.0) {
UIView.animate(withDuration: 0.2, delay: 0, options: UIView.AnimationOptions(), animations:
{
self.buttonsView.center = CGPoint(x: self.buttonsView.center.x, y: screenSize.height - self.buttonsView.frame.size.height/2.0)
self.buttonsView.alpha = 1.0
}, completion: nil)
}else{
UIView.animate(withDuration: 0.1, delay: 0, options: UIView.AnimationOptions(), animations:
{
self.buttonsView.center = CGPoint(x: self.buttonsView.center.x, y: screenSize.height + self.buttonsView.frame.size.height/2.0)
self.buttonsView.alpha = 0.0
}, completion: nil)
}
}
@objc func editDiary() {
let composeViewController = self.storyboard?.instantiateViewController(withIdentifier: "DiaryComposeViewController") as! DiaryComposeViewController
if let diary = diary {
composeViewController.diary = diary
}
self.present(composeViewController, animated: true, completion: nil)
}
@objc func saveToRoll() {
let offset = self.webview.scrollView.contentOffset.x
// 针对 WebView 截图
let image = webview.captureView()
self.webview.scrollView.contentOffset.x = offset
// 创建分享对象
var sharingItems = [AnyObject]()
// 给分享对象插入图片
sharingItems.append(image)
// 初始化分享组件
let activityViewController = UIActivityViewController(activityItems: sharingItems, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.saveButton
// 现实分享组件
self.present(activityViewController, animated: true, completion: nil)
}
@objc func deleteThisDiary() {
managedContext.delete(diary)
do {
try managedContext.save()
} catch _ {
}
hideDiary()
}
func hideDiary() {
self.navigationController?.popViewController(animated: true)
}
}
extension DiaryViewController: UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailBy otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
}
================================================
FILE: Example Codes/Diary/Diary_13/Diary/DiaryYearCollectionViewController.swift
================================================
//
// DiaryYearCollectionViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
class DiaryYearCollectionViewController: UICollectionViewController {
var year: Int!
var diarys = [Diary]()
var fetchedResultsController : NSFetchedResultsController!
var monthCount: Int = 1
var sectionsCount: Int = 0
override func viewDidLoad() {
super.viewDidLoad()
let layout = DiaryLayout()
layout.scrollDirection = UICollectionView.ScrollDirection.horizontal
self.collectionView?.setCollectionViewLayout(layout, animated: false)
do {
// 新建查询
let fetchRequest = NSFetchRequest(entityName:"Diary")
// 增加过滤条件
fetchRequest.predicate = NSPredicate(format:"year = \(year!)")
// 排序方式
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "created_at", ascending: true)]
fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest,
managedObjectContext: managedContext, sectionNameKeyPath: "month",
cacheName: nil)
// 尝试查询
try self.fetchedResultsController.performFetch()
if (fetchedResultsController.fetchedObjects!.count == 0){
print("没有存储结果")
}else{
if let sectionsCount = fetchedResultsController.sections?.count {
monthCount = sectionsCount
diarys = fetchedResultsController.fetchedObjects!
}else {
sectionsCount = 0
monthCount = 1
}
}
} catch let error as NSError {
NSLog("发现错误 \(error.localizedDescription)")
}
}
override func numberOfSections(in collectionView: UICollectionView) -> Int {
return monthCount
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 1
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let identifier = "DiaryCell"
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as! DiaryCell
// 获取当前月份
let components = Calendar.current.component(Calendar.Component.month, from: Date())
var month = components
if sectionsCount > 0 {
// 如果程序内有保存的日记,就使用保存的日记的月份
let sectionInfo = fetchedResultsController.sections![indexPath.section]
print("分组信息 \(sectionInfo.name)")
month = Int(sectionInfo.name)!
}
cell.textInt = month
cell.labelText = "\(numberToChinese(cell.textInt)) 月"
// Configure the cell
return cell
}
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
//super.collectionView(collectionView, didSelectItemAt: indexPath as IndexPath)
let identifier = "DiaryMonthCollectionViewController"
let dvc = self.storyboard?.instantiateViewController(withIdentifier: identifier) as! DiaryMonthCollectionViewController // 获取 DiaryMonthCollectionViewController
// 获取当前月份
let components = Calendar.current.component(Calendar.Component.month, from: Date())
var month = components
if sectionsCount > 0 {
// 如果程序内有保存的日记,就使用保存的日记的月份
let sectionInfo = fetchedResultsController.sections![indexPath.section]
print("分组信息 \(sectionInfo.name)")
month = Int(sectionInfo.name)!
}
// 指定是 2015 年的 1 月份
dvc.month = month
dvc.year = year
// 页面跳转
self.navigationController!.pushViewController(dvc, animated: true)
}
}
================================================
FILE: Example Codes/Diary/Diary_13/Diary/Helper.swift
================================================
//
// Helper.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
extension Diary {
func updateTimeWithDate(_ date: Date){
self.created_at = date
self.year = Int32(Calendar.current.component(Calendar.Component.year, from: date))
self.month = Int32(Calendar.current.component(Calendar.Component.month, from: date))
}
}
extension UIWebView {
func captureView() -> UIImage{
// 存储初始大小
let tmpFrame = self.frame
// 新的 Frame
var aFrame = self.frame
aFrame.size.width = self.sizeThatFits(UIScreen.main.bounds.size).width
// 展开 Frame
self.frame = aFrame
// 初始化 ImageContext
UIGraphicsBeginImageContextWithOptions(
self.sizeThatFits(UIScreen.main.bounds.size),
false,
UIScreen.main.scale)
// 创建新的 Context
let resizedContext = UIGraphicsGetCurrentContext()
self.layer.render(in: resizedContext!)
// 重新渲染到新的 resizedContext
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
// 还原 Frame
self.frame = tmpFrame
return image!
}
}
func diaryButtonWith(text: String,
fontSize: CGFloat,
width: CGFloat,
normalImageName: String,
highlightedImageName: String) -> UIButton {
// 创建自定义按钮
let button = UIButton(type: UIButton.ButtonType.custom)
// 设定按钮的大小
button.frame = CGRect(x: 0, y: 0, width: width, height: width)
let font = UIFont(name: "Wyue-GutiFangsong-NC", size: fontSize)
let textAttributes: [NSAttributedString.Key: AnyObject] = [
NSAttributedString.Key.font: font!,
NSAttributedString.Key.foregroundColor: UIColor.white]
// 设置按钮的字体
let attributedText = NSAttributedString(string: text, attributes: textAttributes)
button.setAttributedTitle(attributedText, for: UIControl.State.normal)
// 设置默认按钮的样式
button.setBackgroundImage(UIImage(
named: normalImageName),
for: UIControl.State.normal)
// 设置按钮被按下时的样式
button.setBackgroundImage(UIImage(
named: highlightedImageName),
for: UIControl.State.highlighted)
return button
}
func singleNumberToChinese(_ number:Character) -> String {
switch number {
case "0":
return "零"
case "1":
return "一"
case "2":
return "二"
case "3":
return "三"
case "4":
return "四"
case "5":
return "五"
case "6":
return "六"
case "7":
return "七"
case "8":
return "八"
case "9":
return "九"
default:
return ""
}
}
func numberToChinese(_ number:Int) -> String {
let numbers = String(number)
var finalString = ""
for singleNumber in numbers {
let string = singleNumberToChinese(singleNumber)
finalString = "\(finalString)\(string)"
}
return finalString
}
func numberToChineseWithUnit(_ number:Int) -> String {
let numbers = String(number)
var units = unitParser(numbers.count)
var finalString = ""
for (index, singleNumber) in numbers.enumerated() {
let string = singleNumberToChinese(singleNumber)
if (!(string == "零" && (index+1) == numbers.count)){
finalString = "\(finalString)\(string)\(units[index])"
}
}
return finalString
}
func unitParser(_ unit:Int) -> [String] {
var units = Array(["万","千","百","十",""].reversed())
let parsedUnits = units[0..<(unit)].reversed()
let slicedUnits: ArraySlice = ArraySlice(parsedUnits)
let final: [String] = Array(slicedUnits)
return final
}
================================================
FILE: Example Codes/Diary/Diary_13/Diary/HomeCollectionViewController.swift
================================================
//
// HomeCollectionViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
import CoreData
class HomeCollectionViewController: UICollectionViewController {
var diarys = [Diary]()
var fetchedResultsController : NSFetchedResultsController!
var yearsCount: Int = 1
var sectionsCount: Int = 0
override func viewDidLoad() {
super.viewDidLoad()
let yearLayout = DiaryLayout()
yearLayout.scrollDirection = UICollectionView.ScrollDirection.horizontal
self.collectionView?.setCollectionViewLayout(yearLayout, animated: false)
self.navigationController!.delegate = self
do {
// 新建查询
let fetchRequest = NSFetchRequest(entityName:"Diary")
// 排序方式
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "created_at", ascending: true)]
fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest,
managedObjectContext: managedContext, sectionNameKeyPath: "year",
cacheName: nil)
// 尝试查询
try self.fetchedResultsController.performFetch()
if (fetchedResultsController.fetchedObjects!.count == 0){
print("没有存储结果")
}else{
if let sectionsCount = fetchedResultsController.sections?.count {
yearsCount = sectionsCount
diarys = fetchedResultsController.fetchedObjects!
}else {
sectionsCount = 0
yearsCount = 1
}
}
} catch let error as NSError {
NSLog("发现错误 \(error.localizedDescription)")
}
}
override func numberOfSections(in collectionView: UICollectionView) -> Int {
return yearsCount
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 1
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let identifier = "HomeYearCollectionViewCell"
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath) as! HomeYearCollectionViewCell
// 获取当前月份
let components = Calendar.current.component(Calendar.Component.year, from: Date())
var year = components
if sectionsCount > 0 {
// 如果程序内有保存的日记,就使用保存的日记的年份
let sectionInfo = fetchedResultsController.sections![indexPath.section]
print("分组信息 \(sectionInfo.name)")
year = Int(sectionInfo.name)!
}
cell.textInt = year
cell.labelText = "\(numberToChinese(cell.textInt)) 年"
// Configure the cell
return cell
}
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
//super.collectionView(collectionView, didSelectItemAt: indexPath as IndexPath)
let identifier = "DiaryYearCollectionViewController"
let dvc = self.storyboard?.instantiateViewController(withIdentifier: identifier) as! DiaryYearCollectionViewController // 获取 DiaryYearCollectionViewController
let components = Calendar.current.component(Calendar.Component.year, from: Date())
var year = components
if sectionsCount > 0 {
let sectionInfo = fetchedResultsController.sections![(indexPath as NSIndexPath).row]
print("Section info \(sectionInfo.name)")
year = Int(sectionInfo.name)!
}
dvc.year = year
self.navigationController!.pushViewController(dvc, animated: true)
}
}
extension HomeCollectionViewController: UINavigationControllerDelegate {
func navigationController(_ navigationController:
UINavigationController,
animationControllerFor operation:
UINavigationController.Operation,
from fromVC: UIViewController,
to toVC: UIViewController) ->
UIViewControllerAnimatedTransitioning? {
let animator = DiaryAnimator()
animator.operation = operation
return animator
}
}
================================================
FILE: Example Codes/Diary/Diary_13/Diary/HomeYearCollectionViewCell.swift
================================================
//
// HomeYearCollectionViewCell.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class HomeYearCollectionViewCell: UICollectionViewCell {
var textLabel: DiaryLabel!
var textInt: Int = 0
var labelText: String = "" {
didSet {
textLabel.updateText(labelText: labelText)
}
}
override func awakeFromNib() {
super.awakeFromNib()
// 界面载入内存
self.textLabel = DiaryLabel(
fontname: "TpldKhangXiDictTrial",
labelText: labelText,
fontSize: 16.0,
lineHeight: 5.0,
color: UIColor.black)
self.contentView.addSubview(textLabel)
}
override func layoutSubviews() {
super.layoutSubviews() // 当对子视图进行布局时
self.textLabel.center = CGPoint(x: itemWidth/2.0, y: 150.0/2.0)
}
}
================================================
FILE: Example Codes/Diary/Diary_13/Diary/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
CFBundleVersion
1
LSRequiresIPhoneOS
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
Main
UIRequiredDeviceCapabilities
armv7
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
UIAppFonts
Wyue-GutiFangsong-NC_deliverable.otf
TpldKhangXiDictTrial.otf
NSLocationWhenInUseUsageDescription
在撰写日志的时候自动添加位置
UISupportedInterfaceOrientations~ipad
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
================================================
FILE: Example Codes/Diary/Diary_13/Diary/ViewController.swift
================================================
//
// ViewController.swift
// Diary
//
// Created by 周楷雯 on 2016/10/16.
// Copyright © 2016年 kevinzhow. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
================================================
FILE: Example Codes/Diary/Diary_13/Diary/Wyue-GutiFangsong-NC_deliverable.otf
================================================
[File too large to display: 21.5 MB]
================================================
FILE: Example Codes/Diary/Diary_13/Diary.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
0A5EA7371DB2B0F500B4665B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7361DB2B0F500B4665B /* AppDelegate.swift */; };
0A5EA7391DB2B0F500B4665B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7381DB2B0F500B4665B /* ViewController.swift */; };
0A5EA73C1DB2B0F500B4665B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA73A1DB2B0F500B4665B /* Main.storyboard */; };
0A5EA73E1DB2B0F500B4665B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA73D1DB2B0F500B4665B /* Assets.xcassets */; };
0A5EA7411DB2B0F500B4665B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA73F1DB2B0F500B4665B /* LaunchScreen.storyboard */; };
0A5EA7491DB2B2E200B4665B /* DiaryLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7481DB2B2E200B4665B /* DiaryLabel.swift */; };
0A5EA74F1DB2B81900B4665B /* HomeCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA74E1DB2B81900B4665B /* HomeCollectionViewController.swift */; };
0A5EA7511DB2B98D00B4665B /* HomeYearCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7501DB2B98D00B4665B /* HomeYearCollectionViewCell.swift */; };
0A5EA7551DB2BD1700B4665B /* DiaryLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7541DB2BD1700B4665B /* DiaryLayout.swift */; };
0A5EA75A1DB2C29800B4665B /* TpldKhangXiDictTrial.otf in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA74A1DB2B4BA00B4665B /* TpldKhangXiDictTrial.otf */; };
0A5EA75B1DB2C29B00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf in Resources */ = {isa = PBXBuildFile; fileRef = 0A5EA74B1DB2B4BA00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf */; };
0A5EA75D1DB2E5E400B4665B /* DiaryYearCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA75C1DB2E5E400B4665B /* DiaryYearCollectionViewController.swift */; };
0A5EA75F1DB2E9BF00B4665B /* DiaryCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA75E1DB2E9BF00B4665B /* DiaryCell.swift */; };
0A5EA7611DB2EDDC00B4665B /* Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7601DB2EDDC00B4665B /* Helper.swift */; };
0A5EA7631DB2EF3E00B4665B /* DiaryMonthCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7621DB2EF3E00B4665B /* DiaryMonthCollectionViewController.swift */; };
0A5EA7651DB2F82E00B4665B /* DiaryAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7641DB2F82E00B4665B /* DiaryAnimator.swift */; };
0A5EA7671DB30D2000B4665B /* DiaryComposeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7661DB30D2000B4665B /* DiaryComposeViewController.swift */; };
0A5EA7691DB3131E00B4665B /* DiaryLocationHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA7681DB3131E00B4665B /* DiaryLocationHelper.swift */; };
0A5EA76F1DB31A8500B4665B /* Diary.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 0A5EA76D1DB31A8500B4665B /* Diary.xcdatamodeld */; };
152AD5CEB9F39CA5BCD1741E /* Pods_Diary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D089038386BD762E4D5B302A /* Pods_Diary.framework */; };
9F74CDB71DB3A69300DD10E3 /* DiaryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F74CDB61DB3A69300DD10E3 /* DiaryViewController.swift */; };
9F74CDB91DB3A80700DD10E3 /* DiaryTemplate.html in Resources */ = {isa = PBXBuildFile; fileRef = 9F74CDB81DB3A80700DD10E3 /* DiaryTemplate.html */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
0A5EA7331DB2B0F500B4665B /* Diary.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Diary.app; sourceTree = BUILT_PRODUCTS_DIR; };
0A5EA7361DB2B0F500B4665B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
0A5EA7381DB2B0F500B4665B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
0A5EA73B1DB2B0F500B4665B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
0A5EA73D1DB2B0F500B4665B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
0A5EA7401DB2B0F500B4665B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
0A5EA7421DB2B0F500B4665B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
0A5EA7481DB2B2E200B4665B /* DiaryLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryLabel.swift; sourceTree = ""; };
0A5EA74A1DB2B4BA00B4665B /* TpldKhangXiDictTrial.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = TpldKhangXiDictTrial.otf; sourceTree = ""; };
0A5EA74B1DB2B4BA00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Wyue-GutiFangsong-NC_deliverable.otf"; sourceTree = ""; };
0A5EA74E1DB2B81900B4665B /* HomeCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeCollectionViewController.swift; sourceTree = ""; };
0A5EA7501DB2B98D00B4665B /* HomeYearCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeYearCollectionViewCell.swift; sourceTree = ""; };
0A5EA7541DB2BD1700B4665B /* DiaryLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryLayout.swift; sourceTree = ""; };
0A5EA75C1DB2E5E400B4665B /* DiaryYearCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryYearCollectionViewController.swift; sourceTree = ""; };
0A5EA75E1DB2E9BF00B4665B /* DiaryCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryCell.swift; sourceTree = ""; };
0A5EA7601DB2EDDC00B4665B /* Helper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Helper.swift; sourceTree = ""; };
0A5EA7621DB2EF3E00B4665B /* DiaryMonthCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryMonthCollectionViewController.swift; sourceTree = ""; };
0A5EA7641DB2F82E00B4665B /* DiaryAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryAnimator.swift; sourceTree = ""; };
0A5EA7661DB30D2000B4665B /* DiaryComposeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryComposeViewController.swift; sourceTree = ""; };
0A5EA7681DB3131E00B4665B /* DiaryLocationHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryLocationHelper.swift; sourceTree = ""; };
0A5EA76E1DB31A8500B4665B /* Diary.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Diary.xcdatamodel; sourceTree = ""; };
34DBE8E96D1A285A248E3CD7 /* Pods-Diary.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Diary.debug.xcconfig"; path = "Target Support Files/Pods-Diary/Pods-Diary.debug.xcconfig"; sourceTree = ""; };
9F74CDB61DB3A69300DD10E3 /* DiaryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryViewController.swift; sourceTree = ""; };
9F74CDB81DB3A80700DD10E3 /* DiaryTemplate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DiaryTemplate.html; sourceTree = ""; };
D089038386BD762E4D5B302A /* Pods_Diary.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Diary.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F5DE54E1347D7E1B1C9D99DF /* Pods-Diary.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Diary.release.xcconfig"; path = "Target Support Files/Pods-Diary/Pods-Diary.release.xcconfig"; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
0A5EA7301DB2B0F500B4665B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
152AD5CEB9F39CA5BCD1741E /* Pods_Diary.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
0A5EA72A1DB2B0F500B4665B = {
isa = PBXGroup;
children = (
0A5EA7351DB2B0F500B4665B /* Diary */,
0A5EA7341DB2B0F500B4665B /* Products */,
7CD61015506E8489957E690F /* Pods */,
E825C8D9466500F7A7F83C86 /* Frameworks */,
);
sourceTree = "";
};
0A5EA7341DB2B0F500B4665B /* Products */ = {
isa = PBXGroup;
children = (
0A5EA7331DB2B0F500B4665B /* Diary.app */,
);
name = Products;
sourceTree = "";
};
0A5EA7351DB2B0F500B4665B /* Diary */ = {
isa = PBXGroup;
children = (
9F74CDB81DB3A80700DD10E3 /* DiaryTemplate.html */,
9F74CDB61DB3A69300DD10E3 /* DiaryViewController.swift */,
0A5EA76D1DB31A8500B4665B /* Diary.xcdatamodeld */,
0A5EA7681DB3131E00B4665B /* DiaryLocationHelper.swift */,
0A5EA7661DB30D2000B4665B /* DiaryComposeViewController.swift */,
0A5EA7641DB2F82E00B4665B /* DiaryAnimator.swift */,
0A5EA7601DB2EDDC00B4665B /* Helper.swift */,
0A5EA7541DB2BD1700B4665B /* DiaryLayout.swift */,
0A5EA74E1DB2B81900B4665B /* HomeCollectionViewController.swift */,
0A5EA75C1DB2E5E400B4665B /* DiaryYearCollectionViewController.swift */,
0A5EA7621DB2EF3E00B4665B /* DiaryMonthCollectionViewController.swift */,
0A5EA75E1DB2E9BF00B4665B /* DiaryCell.swift */,
0A5EA7501DB2B98D00B4665B /* HomeYearCollectionViewCell.swift */,
0A5EA7361DB2B0F500B4665B /* AppDelegate.swift */,
0A5EA7481DB2B2E200B4665B /* DiaryLabel.swift */,
0A5EA7381DB2B0F500B4665B /* ViewController.swift */,
0A5EA73A1DB2B0F500B4665B /* Main.storyboard */,
0A5EA74A1DB2B4BA00B4665B /* TpldKhangXiDictTrial.otf */,
0A5EA74B1DB2B4BA00B4665B /* Wyue-GutiFangsong-NC_deliverable.otf */,
0A5EA73D1DB2B0F500B4665B /* Assets.xcassets */,
0A5EA73F1DB2B0F500B4665B /* LaunchScreen.storyboard */,
0A5EA7421DB2B0F500B4665B /* Info.plist */,
);
path = Diary;
sourceTree = "