├── CorePagesView.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ ├── xcshareddata
│ │ ├── CorePagesView.xccheckout
│ │ └── CorePagesView.xcscmblueprint
│ └── xcuserdata
│ │ ├── Charlin.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
│ │ ├── huaxi100.xcuserdatad
│ │ ├── UserInterfaceState.xcuserstate
│ │ └── WorkspaceSettings.xcsettings
│ │ └── muxi.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcuserdata
│ ├── Charlin.xcuserdatad
│ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ │ ├── CorePagesView.xcscheme
│ │ └── xcschememanagement.plist
│ ├── huaxi100.xcuserdatad
│ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ │ ├── CorePagesView.xcscheme
│ │ └── xcschememanagement.plist
│ └── muxi.xcuserdatad
│ ├── xcdebugger
│ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ ├── CorePagesView.xcscheme
│ └── xcschememanagement.plist
├── CorePagesView
├── AppDelegate.h
├── AppDelegate.m
├── Base.lproj
│ ├── LaunchScreen.xib
│ └── Main.storyboard
├── CorePagesView
│ ├── CateGory
│ │ ├── CAAnimation+PagesViewBarShake.h
│ │ └── CAAnimation+PagesViewBarShake.m
│ ├── Config
│ │ ├── CorePagesViewConfig.h
│ │ └── CorePagesViewConfig.m
│ ├── MainView
│ │ ├── CorePagesView.h
│ │ ├── CorePagesView.m
│ │ └── CorePagesView.xib
│ ├── Model
│ │ ├── CorePageModel.h
│ │ └── CorePageModel.m
│ └── View
│ │ ├── CorePagesBarBtn.h
│ │ ├── CorePagesBarBtn.m
│ │ ├── CorePagesBarView.h
│ │ └── CorePagesBarView.m
├── Frameworks
│ ├── CoreArchive
│ │ ├── Category
│ │ │ ├── NSString+ArcFile.h
│ │ │ └── NSString+ArcFile.m
│ │ ├── CoreArchive.h
│ │ └── CoreArchive.m
│ ├── CoreHttp
│ │ ├── CoreHttp.h
│ │ ├── CoreHttp.m
│ │ ├── NSString+CoreHttp
│ │ │ ├── NSString+CoreHttp.h
│ │ │ └── NSString+CoreHttp.m
│ │ └── Upload
│ │ │ ├── NSData+MimeType.h
│ │ │ ├── NSData+MimeType.m
│ │ │ ├── NSData+Param.h
│ │ │ ├── NSData+Param.m
│ │ │ ├── NSString+File.h
│ │ │ ├── NSString+File.m
│ │ │ ├── NSURL+File.h
│ │ │ ├── NSURL+File.m
│ │ │ ├── UploadFile.h
│ │ │ └── UploadFile.m
│ ├── CoreList
│ │ ├── Common
│ │ │ ├── Controller
│ │ │ │ ├── CoreListVC.h
│ │ │ │ └── CoreListVC.m
│ │ │ ├── Model
│ │ │ │ ├── CoreListCommonModel.h
│ │ │ │ ├── CoreListCommonModel.m
│ │ │ │ ├── LTConfigModel.h
│ │ │ │ └── LTConfigModel.m
│ │ │ └── Resource
│ │ │ │ └── CoreList.bundle
│ │ │ │ └── back_top@2x.png
│ │ ├── CoreLTVC_Useage_ReadME.h
│ │ ├── CoreListCVC
│ │ │ ├── VC
│ │ │ │ ├── CoreLCVC.h
│ │ │ │ └── CoreLCVC.m
│ │ │ └── View
│ │ │ │ ├── LCCell.h
│ │ │ │ └── LCCell.m
│ │ └── CoreListTVC
│ │ │ ├── VC
│ │ │ ├── CoreLTVC.h
│ │ │ └── CoreLTVC.m
│ │ │ └── View
│ │ │ ├── LTCell.h
│ │ │ └── LTCell.m
│ ├── CoreRefresh
│ │ ├── CAAnimation+CoreRefresh.h
│ │ ├── CAAnimation+CoreRefresh.m
│ │ ├── CoreFooterView.h
│ │ ├── CoreFooterView.m
│ │ ├── CoreFooterView.xib
│ │ ├── CoreHeaderShowView.h
│ │ ├── CoreHeaderShowView.m
│ │ ├── CoreHeaderShowView.xib
│ │ ├── CoreHeaderView.h
│ │ ├── CoreHeaderView.m
│ │ ├── CoreHeaderView.xib
│ │ ├── CoreRefreshConst.h
│ │ ├── CoreRefreshConst.m
│ │ ├── CoreRefreshEntry.h
│ │ ├── CoreRefreshResource.bundle
│ │ │ └── coreRefreshIcon@2x.png
│ │ ├── CoreRefreshView.h
│ │ ├── CoreRefreshView.m
│ │ ├── UIScrollView+MJExtension.h
│ │ ├── UIScrollView+MJExtension.m
│ │ ├── UIScrollView+Refresh.h
│ │ ├── UIScrollView+Refresh.m
│ │ ├── UIView+MJExtension.h
│ │ └── UIView+MJExtension.m
│ ├── CoreStatus
│ │ ├── CoreStatus.h
│ │ ├── CoreStatus.m
│ │ └── Reachability
│ │ │ ├── Reachability.h
│ │ │ └── Reachability.m
│ ├── CoreViewNetWorkStausManager
│ │ ├── CoreViewNetWorkStausManager.h
│ │ ├── CoreViewNetWorkStausManager.m
│ │ └── Lib
│ │ │ ├── CM.bundle
│ │ │ └── CMIcon@2x.png
│ │ │ ├── CMView.h
│ │ │ ├── CMView.m
│ │ │ └── CMView.xib
│ └── MJExtension
│ │ ├── MJConst.h
│ │ ├── MJConst.m
│ │ ├── MJExtension.h
│ │ ├── MJFoundation.h
│ │ ├── MJFoundation.m
│ │ ├── MJProperty.h
│ │ ├── MJProperty.m
│ │ ├── MJType.h
│ │ ├── MJType.m
│ │ ├── NSObject+MJCoding.h
│ │ ├── NSObject+MJCoding.m
│ │ ├── NSObject+MJKeyValue.h
│ │ ├── NSObject+MJKeyValue.m
│ │ ├── NSObject+MJProperty.h
│ │ ├── NSObject+MJProperty.m
│ │ ├── NSString+MJExtension.h
│ │ └── NSString+MJExtension.m
├── Images.xcassets
│ ├── AppIcon.appiconset
│ │ └── Contents.json
│ └── LaunchImage.launchimage
│ │ └── Contents.json
├── Info.plist
├── NewsListCell.h
├── NewsListCell.m
├── NewsListCell.xib
├── NewsListModel.h
├── NewsListModel.m
├── NewsListTVC.h
├── NewsListTVC.m
├── ViewController.h
├── ViewController.m
├── main.m
├── pic
│ ├── 1.png
│ ├── 2.png
│ ├── 3.png
│ └── 4.png
└── show2.gif
├── CorePagesViewTests
├── CorePagesViewTests.m
└── Info.plist
└── README.md
/CorePagesView.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CorePagesView.xcodeproj/project.xcworkspace/xcshareddata/CorePagesView.xccheckout:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDESourceControlProjectFavoriteDictionaryKey
6 |
7 | IDESourceControlProjectIdentifier
8 | E0AD4BB4-E7D4-49E2-8BB1-0BE2394118F7
9 | IDESourceControlProjectName
10 | CorePagesView
11 | IDESourceControlProjectOriginsDictionary
12 |
13 | 6B2015D4436429F47C792D67800C8954018A2739
14 | https://github.com/nsdictionary/CoreList.git
15 | C094A7C9ECBE0E0D46C864B8A8853A58DDDD94EC
16 | https://github.com/nsdictionary/CorePagesView.git
17 |
18 | IDESourceControlProjectPath
19 | CorePagesView.xcodeproj
20 | IDESourceControlProjectRelativeInstallPathDictionary
21 |
22 | 6B2015D4436429F47C792D67800C8954018A2739
23 | ../../CorePagesView/Frameworks/CoreList
24 | C094A7C9ECBE0E0D46C864B8A8853A58DDDD94EC
25 | ../..
26 |
27 | IDESourceControlProjectURL
28 | https://github.com/nsdictionary/CorePagesView.git
29 | IDESourceControlProjectVersion
30 | 111
31 | IDESourceControlProjectWCCIdentifier
32 | C094A7C9ECBE0E0D46C864B8A8853A58DDDD94EC
33 | IDESourceControlProjectWCConfigurations
34 |
35 |
36 | IDESourceControlRepositoryExtensionIdentifierKey
37 | public.vcs.git
38 | IDESourceControlWCCIdentifierKey
39 | 6B2015D4436429F47C792D67800C8954018A2739
40 | IDESourceControlWCCName
41 | CoreList
42 |
43 |
44 | IDESourceControlRepositoryExtensionIdentifierKey
45 | public.vcs.git
46 | IDESourceControlWCCIdentifierKey
47 | C094A7C9ECBE0E0D46C864B8A8853A58DDDD94EC
48 | IDESourceControlWCCName
49 | CorePagesView
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/CorePagesView.xcodeproj/project.xcworkspace/xcshareddata/CorePagesView.xcscmblueprint:
--------------------------------------------------------------------------------
1 | {
2 | "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "C094A7C9ECBE0E0D46C864B8A8853A58DDDD94EC",
3 | "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
4 |
5 | },
6 | "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
7 | "6B2015D4436429F47C792D67800C8954018A2739" : 0,
8 | "C094A7C9ECBE0E0D46C864B8A8853A58DDDD94EC" : 0
9 | },
10 | "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "E0AD4BB4-E7D4-49E2-8BB1-0BE2394118F7",
11 | "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
12 | "6B2015D4436429F47C792D67800C8954018A2739" : "CorePagesView\/CorePagesView\/Frameworks\/CoreList",
13 | "C094A7C9ECBE0E0D46C864B8A8853A58DDDD94EC" : "CorePagesView"
14 | },
15 | "DVTSourceControlWorkspaceBlueprintNameKey" : "CorePagesView",
16 | "DVTSourceControlWorkspaceBlueprintVersion" : 204,
17 | "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "CorePagesView.xcodeproj",
18 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
19 | {
20 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/nsdictionary\/CoreList.git",
21 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
22 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "6B2015D4436429F47C792D67800C8954018A2739"
23 | },
24 | {
25 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/nsdictionary\/CorePagesView.git",
26 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
27 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "C094A7C9ECBE0E0D46C864B8A8853A58DDDD94EC"
28 | }
29 | ]
30 | }
--------------------------------------------------------------------------------
/CorePagesView.xcodeproj/project.xcworkspace/xcuserdata/Charlin.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CorePagesView/905caceaf4b2d8ede868bb8c231f38daf802066b/CorePagesView.xcodeproj/project.xcworkspace/xcuserdata/Charlin.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/CorePagesView.xcodeproj/project.xcworkspace/xcuserdata/huaxi100.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CorePagesView/905caceaf4b2d8ede868bb8c231f38daf802066b/CorePagesView.xcodeproj/project.xcworkspace/xcuserdata/huaxi100.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/CorePagesView.xcodeproj/project.xcworkspace/xcuserdata/huaxi100.xcuserdatad/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges
6 |
7 | SnapshotAutomaticallyBeforeSignificantChanges
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/CorePagesView.xcodeproj/project.xcworkspace/xcuserdata/muxi.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CorePagesView/905caceaf4b2d8ede868bb8c231f38daf802066b/CorePagesView.xcodeproj/project.xcworkspace/xcuserdata/muxi.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/CorePagesView.xcodeproj/xcuserdata/Charlin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/CorePagesView.xcodeproj/xcuserdata/Charlin.xcuserdatad/xcschemes/CorePagesView.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
44 |
45 |
47 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
65 |
66 |
75 |
77 |
83 |
84 |
85 |
86 |
87 |
88 |
94 |
96 |
102 |
103 |
104 |
105 |
107 |
108 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/CorePagesView.xcodeproj/xcuserdata/Charlin.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | CorePagesView.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | EE4A92961ABBB94400F01A48
16 |
17 | primary
18 |
19 |
20 | EE4A92AF1ABBB94400F01A48
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/CorePagesView.xcodeproj/xcuserdata/huaxi100.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/CorePagesView.xcodeproj/xcuserdata/huaxi100.xcuserdatad/xcschemes/CorePagesView.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
44 |
45 |
47 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
65 |
66 |
75 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
93 |
94 |
100 |
101 |
102 |
103 |
105 |
106 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/CorePagesView.xcodeproj/xcuserdata/huaxi100.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | CorePagesView.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | EE4A92961ABBB94400F01A48
16 |
17 | primary
18 |
19 |
20 | EE4A92AF1ABBB94400F01A48
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/CorePagesView.xcodeproj/xcuserdata/muxi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/CorePagesView.xcodeproj/xcuserdata/muxi.xcuserdatad/xcschemes/CorePagesView.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
44 |
45 |
47 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
65 |
66 |
75 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
93 |
94 |
100 |
101 |
102 |
103 |
105 |
106 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/CorePagesView.xcodeproj/xcuserdata/muxi.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | CorePagesView.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | EE4A92961ABBB94400F01A48
16 |
17 | primary
18 |
19 |
20 | EE4A92AF1ABBB94400F01A48
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/CorePagesView/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // CorePagesView
4 | //
5 | // Created by muxi on 15/3/20.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/CorePagesView/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // CorePagesView
4 | //
5 | // Created by muxi on 15/3/20.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application {
24 | // 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.
25 | // 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.
26 | }
27 |
28 | - (void)applicationDidEnterBackground:(UIApplication *)application {
29 | // 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.
30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31 | }
32 |
33 | - (void)applicationWillEnterForeground:(UIApplication *)application {
34 | // 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.
35 | }
36 |
37 | - (void)applicationDidBecomeActive:(UIApplication *)application {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application {
42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/CorePagesView/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/CorePagesView/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/CorePagesView/CorePagesView/CateGory/CAAnimation+PagesViewBarShake.h:
--------------------------------------------------------------------------------
1 | //
2 | // CAAnimation+PagesViewBarShake.h
3 | // CorePagesView
4 | //
5 | // Created by muxi on 15/3/20.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CAAnimation (PagesViewBarShake)
12 |
13 |
14 | /**
15 | * 抖动
16 | */
17 | +(CAKeyframeAnimation *)shake;
18 |
19 |
20 |
21 |
22 |
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/CorePagesView/CorePagesView/CateGory/CAAnimation+PagesViewBarShake.m:
--------------------------------------------------------------------------------
1 | //
2 | // CAAnimation+PagesViewBarShake.m
3 | // CorePagesView
4 | //
5 | // Created by muxi on 15/3/20.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "CAAnimation+PagesViewBarShake.h"
10 |
11 | @implementation CAAnimation (PagesViewBarShake)
12 |
13 |
14 |
15 | /**
16 | * 抖动
17 | */
18 | +(CAKeyframeAnimation *)shake{
19 | CAKeyframeAnimation *kfa=[CAKeyframeAnimation animationWithKeyPath:@"transform.translation.x"];
20 |
21 | //值
22 | kfa.values=@[@(10),@(-8),@(6),@(-4),@(2),@(-1),@(0)];
23 |
24 | //设置时间
25 | kfa.duration=0.6f;
26 |
27 | //是否重复
28 | kfa.repeatCount=0;
29 |
30 | //是否反转
31 | kfa.autoreverses=NO;
32 |
33 | //完成移除
34 | kfa.removedOnCompletion=YES;
35 |
36 | return kfa;
37 | }
38 |
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/CorePagesView/CorePagesView/Config/CorePagesViewConfig.h:
--------------------------------------------------------------------------------
1 | //
2 | // CorePagesViewConfig.h
3 | // CorePagesView
4 | //
5 | // Created by 成林 on 15/6/27.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface CorePagesViewConfig : NSObject
13 |
14 |
15 | /** 顶部按钮的基本宽度 */
16 | @property (nonatomic,assign) CGFloat barBtnWidth;
17 |
18 | /** 顶部按钮的扩展宽度 */
19 | @property (nonatomic,assign) CGFloat barBtnExtraWidth;
20 |
21 | /** 是否使用自定义的宽度,如果不使用,则框架自行计算宽度 */
22 | @property (nonatomic,assign) BOOL isBarBtnUseCustomWidth;
23 |
24 | /** bar条的高度 */
25 | @property (nonatomic,assign) CGFloat barViewH;
26 |
27 | /** 字体大小 */
28 | @property (nonatomic,assign) CGFloat barBtnFontPoint;
29 |
30 | /** 顶部菜单最左和最右的间距 */
31 | @property (nonatomic,assign) CGFloat barScrollMargin;
32 |
33 | /** 菜单按钮之间的间距 */
34 | @property (nonatomic,assign) CGFloat barBtnMargin;
35 |
36 | /** 线条多余长度(单边) */
37 | @property (nonatomic,assign) CGFloat mainViewMargin;
38 |
39 | /** 主体内容区间距值 */
40 | @property (nonatomic,assign) CGFloat barLineViewPadding;
41 |
42 | /** 动画时长 */
43 | @property (nonatomic,assign) CGFloat animDuration;
44 |
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/CorePagesView/CorePagesView/Config/CorePagesViewConfig.m:
--------------------------------------------------------------------------------
1 | //
2 | // CorePagesViewConfig.m
3 | // CorePagesView
4 | //
5 | // Created by 成林 on 15/6/27.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "CorePagesViewConfig.h"
10 |
11 | @implementation CorePagesViewConfig
12 |
13 | - (instancetype)init
14 | {
15 | self = [super init];
16 | if (self) {
17 |
18 | //默认值设置
19 | [self defaultValueSet];
20 | }
21 | return self;
22 | }
23 |
24 |
25 | /** 默认值设置 */
26 | -(void)defaultValueSet{
27 |
28 | //顶部按钮的基本宽度
29 | _barBtnWidth = 60;
30 |
31 | //顶部按钮的扩展宽度
32 | _barBtnExtraWidth = 0;
33 |
34 | //是否使用自定义的宽度,如果不使用,则框架自行计算宽度
35 | _isBarBtnUseCustomWidth = YES;
36 |
37 | //bar条的高度
38 | _barViewH = 44;
39 |
40 | //字体大小
41 | _barBtnFontPoint = 15.0f;
42 |
43 | //顶部菜单最左和最右的间距
44 | _barScrollMargin = 0;
45 |
46 | //菜单按钮之间的间距
47 | _barBtnMargin = 0;
48 |
49 | //线条多余长度(单边)
50 | _barLineViewPadding = 0;
51 |
52 | //主体内容区间距值
53 | _mainViewMargin = 0;
54 |
55 | //动画时长
56 | _animDuration = 0.25f;
57 | }
58 |
59 |
60 | @end
61 |
--------------------------------------------------------------------------------
/CorePagesView/CorePagesView/MainView/CorePagesView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreTabsView.h
3 | // CoreTabsVC
4 | //
5 | // Created by 冯成林 on 15/3/19.
6 | // Copyright (c) 2015年 冯成林. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "CorePageModel.h"
11 | #import "CorePagesViewConfig.h"
12 |
13 |
14 | @interface CorePagesView : UIView
15 |
16 | @property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
17 |
18 |
19 | /** 中转到指定页码 */
20 | -(void)jumpToPage:(NSUInteger)jumpPage;
21 |
22 |
23 |
24 | /**
25 | * 快速实例化对象
26 | *
27 | * @param ownerVC 本视图所属的控制器
28 | * @param pageModels 模型数组
29 | * @param config 配置
30 | *
31 | * @return 实例
32 | */
33 | +(instancetype)viewWithOwnerVC:(UIViewController *)ownerVC pageModels:(NSArray *)pageModels config:(CorePagesViewConfig *)config;
34 |
35 |
36 |
37 |
38 |
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/CorePagesView/CorePagesView/MainView/CorePagesView.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/CorePagesView/CorePagesView/Model/CorePageModel.h:
--------------------------------------------------------------------------------
1 | //
2 | // CorePageModel.h
3 | // CorePageModel
4 | //
5 | // Created by 冯成林 on 15/3/19.
6 | // Copyright (c) 2015年 冯成林. All rights reserved.
7 | // 描述顶部item的模型
8 |
9 | #import
10 | #import
11 |
12 | @interface CorePageModel : NSObject
13 |
14 |
15 | /**
16 | * 控制器
17 | */
18 | @property (nonatomic,strong) UIViewController *pageVC;
19 |
20 |
21 | /**
22 | * 控制器对应的名称
23 | */
24 | @property (nonatomic,copy) NSString *pageBarName;
25 |
26 |
27 |
28 | /**
29 | * 每一个item的bar实际占用的宽度
30 | */
31 | @property (nonatomic,assign) CGFloat padding;
32 |
33 |
34 |
35 |
36 |
37 | /**
38 | * 快速创建一个page模型
39 | *
40 | * @param pageVC 控制器
41 | * @param pageBarName 控制器对应的名称
42 | *
43 | * @return 实例
44 | */
45 | +(instancetype)model:(UIViewController *)pageVC pageBarName:(NSString *)pageBarName;
46 |
47 |
48 |
49 |
50 | /**
51 | * 模型检查
52 | */
53 | +(BOOL)modelCheck:(NSArray *)pageModels;
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | @end
63 |
--------------------------------------------------------------------------------
/CorePagesView/CorePagesView/Model/CorePageModel.m:
--------------------------------------------------------------------------------
1 | //
2 | // TabsBarModel.m
3 | // CoreTabsVC
4 | //
5 | // Created by 冯成林 on 15/3/19.
6 | // Copyright (c) 2015年 冯成林. All rights reserved.
7 | //
8 |
9 | #import "CorePageModel.h"
10 |
11 |
12 | @interface CorePageModel ()
13 |
14 |
15 |
16 | @end
17 |
18 |
19 |
20 |
21 | @implementation CorePageModel
22 |
23 |
24 |
25 | /**
26 | * 快速创建一个page模型
27 | *
28 | * @param pageVC 控制器
29 | * @param pageBarName 控制器对应的名称
30 | *
31 | * @return 实例
32 | */
33 | +(instancetype)model:(UIViewController *)pageVC pageBarName:(NSString *)pageBarName{
34 |
35 | CorePageModel *pageModel=[[CorePageModel alloc] init];
36 |
37 | pageModel.pageVC=pageVC;
38 | pageModel.pageBarName=pageBarName;
39 |
40 | return pageModel;
41 | }
42 |
43 |
44 |
45 |
46 | /**
47 | * 模型检查
48 | */
49 | +(BOOL)modelCheck:(NSArray *)pageModels{
50 |
51 | if(pageModels==nil || pageModels.count==0) return NO;
52 |
53 | for (id obj in pageModels) {
54 | if([obj isKindOfClass:[self class]]) continue;
55 | return NO;
56 | }
57 |
58 | return YES;
59 | }
60 |
61 |
62 |
63 | @end
64 |
--------------------------------------------------------------------------------
/CorePagesView/CorePagesView/View/CorePagesBarBtn.h:
--------------------------------------------------------------------------------
1 | //
2 | // CorePagesBarBtn.h
3 | // CorePagesView
4 | //
5 | // Created by muxi on 15/3/20.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CorePagesBarBtn : UIButton
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CorePagesView/CorePagesView/View/CorePagesBarBtn.m:
--------------------------------------------------------------------------------
1 | //
2 | // CorePagesBarBtn.m
3 | // CorePagesView
4 | //
5 | // Created by muxi on 15/3/20.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "CorePagesBarBtn.h"
10 |
11 | #define rgba(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
12 |
13 |
14 | @implementation CorePagesBarBtn
15 |
16 |
17 | -(instancetype)initWithFrame:(CGRect)frame{
18 |
19 | self = [super initWithFrame:frame];
20 |
21 | if(self){
22 |
23 | //个性化
24 | [self corePagesBarBtnPrePare];
25 | }
26 |
27 | return self;
28 | }
29 |
30 |
31 |
32 | -(id)initWithCoder:(NSCoder *)aDecoder{
33 |
34 | self=[super initWithCoder:aDecoder];
35 |
36 | if(self){
37 |
38 | //个性化
39 | [self corePagesBarBtnPrePare];
40 | }
41 |
42 | return self;
43 | }
44 |
45 | /**
46 | * 个性化
47 | */
48 | -(void)corePagesBarBtnPrePare{
49 |
50 | [self setTitleColor:rgba(0, 0, 0, 1) forState:UIControlStateNormal];
51 | [self setTitleColor:rgba(90, 90, 90, 1) forState:UIControlStateHighlighted];
52 | [self setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
53 | }
54 |
55 |
56 | @end
57 |
--------------------------------------------------------------------------------
/CorePagesView/CorePagesView/View/CorePagesBarView.h:
--------------------------------------------------------------------------------
1 | //
2 | // TabsBarView.h
3 | // CoreTabsVC
4 | //
5 | // Created by 冯成林 on 15/3/19.
6 | // Copyright (c) 2015年 冯成林. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "CorePagesBarBtn.h"
11 | #import "CorePagesViewConfig.h"
12 |
13 | @interface CorePagesBarView : UIScrollView
14 |
15 |
16 |
17 | /**
18 | * 分页模型数组
19 | */
20 | @property (nonatomic,strong) NSArray *pageModels;
21 |
22 |
23 |
24 | /**
25 | * 页码
26 | */
27 | @property (nonatomic,assign) NSUInteger page;
28 |
29 |
30 |
31 |
32 | /**
33 | * btn操作block
34 | */
35 | @property (nonatomic,copy) void (^btnActionBlock)(CorePagesBarBtn *btn,NSUInteger selectedIndex);
36 |
37 |
38 | @property (nonatomic,strong) CorePagesViewConfig *config;
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreArchive/Category/NSString+ArcFile.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+File.h
3 | // CoreCategory
4 | //
5 | // Created by 成林 on 15/4/6.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 |
12 |
13 | @interface NSString (ArcFile)
14 |
15 |
16 | /*
17 | * document根文件夹
18 | */
19 | +(NSString *)documentFolder;
20 |
21 |
22 | /*
23 | * caches根文件夹
24 | */
25 | +(NSString *)cachesFolder;
26 |
27 |
28 |
29 |
30 | /**
31 | * 生成子文件夹
32 | *
33 | * 如果子文件夹不存在,则直接创建;如果已经存在,则直接返回
34 | *
35 | * @param subFolder 子文件夹名
36 | *
37 | * @return 文件夹路径
38 | */
39 | -(NSString *)createSubFolder:(NSString *)subFolder;
40 |
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreArchive/Category/NSString+ArcFile.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+File.m
3 | // CoreCategory
4 | //
5 | // Created by 成林 on 15/4/6.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import "NSString+ArcFile.h"
10 |
11 | @implementation NSString (ArcFile)
12 |
13 | /*
14 | * document根文件夹
15 | */
16 | +(NSString *)documentFolder{
17 |
18 | return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
19 | }
20 |
21 |
22 |
23 | /*
24 | * caches根文件夹
25 | */
26 | +(NSString *)cachesFolder{
27 |
28 | return [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
29 | }
30 |
31 |
32 |
33 |
34 |
35 | /**
36 | * 生成子文件夹
37 | *
38 | * 如果子文件夹不存在,则直接创建;如果已经存在,则直接返回
39 | *
40 | * @param subFolder 子文件夹名
41 | *
42 | * @return 文件夹路径
43 | */
44 | -(NSString *)createSubFolder:(NSString *)subFolder{
45 |
46 | NSString *subFolderPath=[NSString stringWithFormat:@"%@/%@",self,subFolder];
47 |
48 | BOOL isDir = NO;
49 |
50 | NSFileManager *fileManager = [NSFileManager defaultManager];
51 |
52 | BOOL existed = [fileManager fileExistsAtPath:subFolderPath isDirectory:&isDir];
53 |
54 | if ( !(isDir == YES && existed == YES) )
55 | {
56 | [fileManager createDirectoryAtPath:subFolderPath withIntermediateDirectories:YES attributes:nil error:nil];
57 | }
58 |
59 | return subFolderPath;
60 | }
61 |
62 | @end
63 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreArchive/CoreArchive.h:
--------------------------------------------------------------------------------
1 | //
2 | // ToolArc.h
3 | // 私人通讯录
4 | //
5 | // Created by muxi on 14-9-3.
6 | // Copyright (c) 2014年 muxi. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import "NSString+ArcFile.h"
12 |
13 |
14 | @interface CoreArchive : NSObject
15 |
16 | #pragma mark - 偏好类信息存储
17 |
18 | /**
19 | * 保存普通字符串
20 | */
21 | +(void)setStr:(NSString *)str key:(NSString *)key;
22 |
23 | /**
24 | * 读取
25 | */
26 | +(NSString *)strForKey:(NSString *)key;
27 |
28 | /**
29 | * 删除
30 | */
31 | +(void)removeStrForKey:(NSString *)key;
32 |
33 |
34 | /**
35 | * 保存int
36 | */
37 | +(void)setInt:(NSInteger)i key:(NSString *)key;
38 |
39 | /**
40 | * 读取int
41 | */
42 | +(NSInteger)intForKey:(NSString *)key;
43 |
44 |
45 |
46 | /**
47 | * 保存float
48 | */
49 | +(void)setFloat:(CGFloat)floatValue key:(NSString *)key;
50 |
51 | /**
52 | * 读取float
53 | */
54 | +(CGFloat)floatForKey:(NSString *)key;
55 |
56 |
57 |
58 | /**
59 | * 保存bool
60 | */
61 | +(void)setBool:(BOOL)boolValue key:(NSString *)key;
62 |
63 | /**
64 | * 读取bool
65 | */
66 | +(BOOL)boolForKey:(NSString *)key;
67 |
68 |
69 | #pragma mark - 文件归档
70 |
71 | /**
72 | * 归档
73 | */
74 | +(BOOL)archiveRootObject:(id)obj toFile:(NSString *)path;
75 | /**
76 | * 删除
77 | */
78 | +(BOOL)removeRootObjectWithFile:(NSString *)path;
79 |
80 | /**
81 | * 解档
82 | */
83 | +(id)unarchiveObjectWithFile:(NSString *)path;
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 | @end
94 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreArchive/CoreArchive.m:
--------------------------------------------------------------------------------
1 | //
2 | // ToolArc.m
3 | // 私人通讯录
4 | //
5 | // Created by muxi on 14-9-3.
6 | // Copyright (c) 2014年 muxi. All rights reserved.
7 | //
8 |
9 | #import "CoreArchive.h"
10 |
11 | @implementation CoreArchive
12 |
13 | #pragma mark - 偏好类信息存储
14 | //保存普通对象
15 | +(void)setStr:(NSString *)str key:(NSString *)key{
16 |
17 | //获取preference
18 | NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
19 |
20 | //保存
21 | [defaults setObject:str forKey:key];
22 |
23 | //立即同步
24 | [defaults synchronize];
25 |
26 | }
27 |
28 | //读取
29 | +(NSString *)strForKey:(NSString *)key{
30 |
31 | //获取preference
32 | NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
33 |
34 | //读取
35 | NSString *str=(NSString *)[defaults objectForKey:key];
36 |
37 | return str;
38 |
39 | }
40 |
41 | //删除
42 | +(void)removeStrForKey:(NSString *)key{
43 |
44 | [self setStr:nil key:key];
45 |
46 | }
47 |
48 | //保存int
49 | +(void)setInt:(NSInteger)i key:(NSString *)key{
50 | //获取preference
51 | NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
52 |
53 | //保存
54 | [defaults setInteger:i forKey:key];
55 |
56 | //立即同步
57 | [defaults synchronize];
58 |
59 | }
60 |
61 | //读取
62 | +(NSInteger)intForKey:(NSString *)key{
63 | //获取preference
64 | NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
65 |
66 | //读取
67 | NSInteger i=[defaults integerForKey:key];
68 |
69 | return i;
70 | }
71 |
72 | //保存float
73 | +(void)setFloat:(CGFloat)floatValue key:(NSString *)key{
74 |
75 | //获取preference
76 | NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
77 |
78 | //保存
79 | [defaults setFloat:floatValue forKey:key];
80 |
81 | //立即同步
82 | [defaults synchronize];
83 |
84 | }
85 | //读取
86 | +(CGFloat)floatForKey:(NSString *)key{
87 | //获取preference
88 | NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
89 |
90 | //读取
91 | CGFloat floatValue=[defaults floatForKey:key];
92 |
93 | return floatValue;
94 | }
95 |
96 |
97 | //保存bool
98 | +(void)setBool:(BOOL)boolValue key:(NSString *)key{
99 | //获取preference
100 | NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
101 |
102 | //保存
103 | [defaults setBool:boolValue forKey:key];
104 |
105 | //立即同步
106 | [defaults synchronize];
107 |
108 | }
109 | //读取
110 | +(BOOL)boolForKey:(NSString *)key{
111 | //获取preference
112 | NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
113 |
114 | //读取
115 | BOOL boolValue=[defaults boolForKey:key];
116 |
117 | return boolValue;
118 | }
119 |
120 |
121 |
122 |
123 | #pragma mark - 文件归档
124 | //归档
125 | +(BOOL)archiveRootObject:(id)obj toFile:(NSString *)path{
126 | return [NSKeyedArchiver archiveRootObject:obj toFile:path];
127 | }
128 | //删除
129 | +(BOOL)removeRootObjectWithFile:(NSString *)path{
130 | return [self archiveRootObject:nil toFile:path];
131 | }
132 | //解档
133 | +(id)unarchiveObjectWithFile:(NSString *)path{
134 | return [NSKeyedUnarchiver unarchiveObjectWithFile:path];
135 | }
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 | @end
145 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreHttp/CoreHttp.h:
--------------------------------------------------------------------------------
1 | //
2 | // ToolConnection.h
3 | //
4 | // Created by muxi on 14/10/22.
5 | // Copyright (c) 2014年 muxi. All rights reserved.
6 | // 全新的网络请求工具类:2.0版本(更新于2015.01.28)
7 |
8 | #import
9 | #import "UploadFile.h"
10 |
11 | typedef enum{
12 |
13 | //请求正常,无错误
14 | CoreHttpErrorTypeNull=0,
15 |
16 | //请求时出错,可能是URL不正确
17 | CoreHttpErrorTypeURLConnectionError,
18 |
19 | //请求时出错,服务器未返回正常的状态码:200
20 | CoreHttpErrorTypeStatusCodeError,
21 |
22 | //请求回的Data在解析前就是nil,导致请求无效,无法后续JSON反序列化。
23 | CoreHttpErrorTypeDataNilError,
24 |
25 | //data在JSON反序列化时出错
26 | CoreHttpErrorTypeDataSerializationError,
27 |
28 | //无网络连接
29 | CoreHttpErrorTypeNoNetWork,
30 |
31 | //服务器请求成功,但抛出错误
32 | CoreHttpErrorTypeServiceRetrunErrorStatus,
33 |
34 | /**
35 | * 以下是文件上传中的错误类型
36 | */
37 | CoreHttpErrorTypeUploadDataNil, //什么都没有上传
38 |
39 |
40 | }CoreHttpErrorType; //错误类型定义
41 |
42 |
43 |
44 |
45 |
46 | typedef void(^SuccessBlock)(id obj);
47 |
48 | typedef void(^ErrorBlock)(CoreHttpErrorType errorType);
49 |
50 |
51 |
52 | @interface CoreHttp : NSObject
53 |
54 |
55 | /**
56 | * GET:
57 | * params中可指明参数类型
58 | */
59 | +(void)getUrl:(NSString *)urlString params:(NSDictionary *)params success:(SuccessBlock)successBlock errorBlock:(ErrorBlock)errorBlock;
60 |
61 |
62 | /**
63 | * POST:
64 | */
65 | +(void)postUrl:(NSString *)urlString params:(NSDictionary *)params success:(SuccessBlock)successBlock errorBlock:(ErrorBlock)errorBlock;
66 |
67 |
68 |
69 | /**
70 | * 文件上传
71 | * @params: 普通参数
72 | * @files : 文件数据,里面装的都是UploadFile对象
73 | */
74 | +(void)uploadUrl:(NSString *)uploadUrl params:(NSDictionary *)params files:(NSArray *)files success:(SuccessBlock)successBlock errorBlock:(ErrorBlock)errorBlock;
75 |
76 |
77 |
78 | @end
79 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreHttp/NSString+CoreHttp/NSString+CoreHttp.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+CoreHttp.h
3 | // CoreHttp
4 | //
5 | // Created by muxi on 15/3/2.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSString (CoreHttp)
12 |
13 | /**
14 | * 处理json格式的字符串中的换行符、回车符
15 | */
16 | -(NSString *)deleteSpecialCode;
17 |
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreHttp/NSString+CoreHttp/NSString+CoreHttp.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+CoreHttp.m
3 | // CoreHttp
4 | //
5 | // Created by muxi on 15/3/2.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "NSString+CoreHttp.h"
10 |
11 | @implementation NSString (CoreHttp)
12 |
13 |
14 |
15 | /**
16 | * 处理json格式的字符串中的换行符、回车符
17 | */
18 | -(NSString *)deleteSpecialCode {
19 |
20 | NSString *string = [self stringByReplacingOccurrencesOfString:@"\r" withString:@""];
21 |
22 | string = [string stringByReplacingOccurrencesOfString:@"\n" withString:@""];
23 |
24 | string = [string stringByReplacingOccurrencesOfString:@"\n" withString:@""];
25 |
26 | string = [string stringByReplacingOccurrencesOfString:@"\t" withString:@""];
27 |
28 | return string;
29 | }
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreHttp/Upload/NSData+MimeType.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSData+MimeType.h
3 | // CoreHttp
4 | //
5 | // Created by muxi on 15/3/2.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSData (MimeType)
12 |
13 | @property (nonatomic,copy,readonly) NSString *mimeType;
14 |
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreHttp/Upload/NSData+MimeType.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSData+MimeType.m
3 | // CoreHttp
4 | //
5 | // Created by muxi on 15/3/2.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "NSData+MimeType.h"
10 |
11 | @implementation NSData (MimeType)
12 |
13 |
14 | -(NSString *)mimeType{
15 |
16 | uint8_t c;
17 |
18 | [self getBytes:&c length:1];
19 |
20 | NSString *mimeType=nil;
21 |
22 | switch (c) {
23 | case 0xFF:
24 | mimeType = @"image/jpeg";
25 | break;
26 | case 0x89:
27 | mimeType = @"image/png";
28 | break;
29 | case 0x47:
30 | mimeType = @"image/gif";
31 | break;
32 | case 0x49:
33 | case 0x4D:
34 | mimeType = @"image/tiff";
35 | break;
36 | }
37 |
38 | if(mimeType==nil){
39 | mimeType=@"image/jpeg";
40 | NSLog(@"Warnning:请注意,根据NSData获取图片的MimeType的时候出现错误:没有获取到值,框架默认‘image/jpeg’替换!");
41 | }
42 |
43 | return mimeType;
44 | }
45 |
46 |
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreHttp/Upload/NSData+Param.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSData+Param.h
3 | // Upload
4 | //
5 | // Created by muxi on 15/2/12.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSData (Param)
12 |
13 |
14 |
15 |
16 | /**
17 | * 文件参数
18 | *
19 | * @param files 文件参数对象数组
20 | *
21 | * @return data
22 | */
23 | +(NSData *)uploadParameterForFiles:(NSArray *)files;
24 |
25 |
26 |
27 |
28 | /**
29 | * 普通参数对象:一个键值对就是一个UploadParameter对象
30 | *
31 | * @param normalParams 普通参数字典
32 | *
33 | * @return data
34 | */
35 | +(NSData *)uploadParameterForNormalParams:(NSDictionary *)normalParams;
36 |
37 |
38 |
39 |
40 | /**
41 | * 结束参数对象
42 | */
43 | +(NSData *)uploadParameterForEnd;
44 |
45 |
46 |
47 |
48 | /**
49 | * 返回boundary
50 | */
51 | +(NSString *)boundary;
52 |
53 |
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreHttp/Upload/NSData+Param.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSData+Param.m
3 | // Upload
4 | //
5 | // Created by muxi on 15/2/12.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "NSData+Param.h"
10 | #import "UploadFile.h"
11 | #import "NSString+File.h"
12 |
13 | NSString *const symbol=@"--"; //symbol
14 |
15 | NSString *const boundary=@"boundary"; //boundary
16 |
17 | NSString *const lineBreak=@"\r\n"; //lineBreak
18 |
19 | @implementation NSData (Param)
20 |
21 |
22 | /**
23 | * 开始参数
24 | */
25 | +(NSData *)uploadParameterForBegin{
26 |
27 | NSData *symbolData=symbol.strData;
28 |
29 | NSData *boundaryData=boundary.strData;
30 |
31 | NSData *lineBreakData=lineBreak.strData;
32 |
33 | NSMutableData *beginDataM=[NSMutableData data];
34 |
35 | //symbol
36 | [beginDataM appendData:symbolData];
37 |
38 | //boundary
39 | [beginDataM appendData:boundaryData];
40 |
41 | //lineBreak
42 | [beginDataM appendData:lineBreakData];
43 |
44 | return beginDataM;
45 | }
46 |
47 |
48 |
49 |
50 |
51 | /**
52 | * 文件参数
53 | *
54 | * @param files 文件参数对象数组
55 | *
56 | * @return data
57 | */
58 | +(NSData *)uploadParameterForFiles:(NSArray *)files{
59 |
60 | if(files==nil || files.count==0){
61 |
62 | NSLog(@"上传文件的文件列表为空,请检查!");
63 | return nil;
64 | }
65 |
66 | NSData *lineBreakData=lineBreak.strData;
67 |
68 | //创建对象
69 | NSMutableData *uploadFileDataM=[NSMutableData data];
70 |
71 | //拼接文件参数数据
72 | for (NSInteger i=0; i
10 |
11 | @interface NSString (File)
12 |
13 |
14 | /**
15 | * 字符串转data
16 | */
17 | -(NSData *)strData;
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreHttp/Upload/NSString+File.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+File.m
3 | // Upload
4 | //
5 | // Created by muxi on 15/2/12.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "NSString+File.h"
10 |
11 | @implementation NSString (File)
12 |
13 | -(NSData *)strData{
14 |
15 | NSRange range = [self rangeOfString:@"file://"];
16 |
17 | if(range.length!=0){
18 |
19 | NSLog(@"请注意:您可能是想要获取本地文件(%@)数据,而不是将此URL地址直接转为对应的NSData。",self);
20 | }
21 |
22 | return [self dataUsingEncoding:NSUTF8StringEncoding];
23 | }
24 |
25 |
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreHttp/Upload/NSURL+File.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSURL+File.h
3 | // Upload
4 | //
5 | // Created by muxi on 15/2/12.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | // 本地文件资源转Data操作
8 |
9 | #import
10 |
11 | @interface NSURL (File)
12 |
13 |
14 | /**
15 | * 获取指定path的文件的mimeType
16 | */
17 | -(NSString *)mimeType;
18 |
19 |
20 | /**
21 | * 获取指定path的文件的data
22 | */
23 | -(NSData *)dataForFileResource;
24 |
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreHttp/Upload/NSURL+File.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSURL+File.m
3 | // Upload
4 | //
5 | // Created by muxi on 15/2/12.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "NSURL+File.h"
10 |
11 | @implementation NSURL (File)
12 |
13 | /**
14 | * 获取指定文件的mimeType
15 | */
16 | -(NSString *)mimeType{
17 |
18 | NSURLRequest *request=[NSURLRequest requestWithURL:self];
19 |
20 | NSURLResponse *response=nil;
21 |
22 | NSError *error=nil;
23 |
24 | //使用同步请求,访问本地文件
25 | [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
26 |
27 | if(error!=nil){
28 | NSLog(@"获取指定文件的mimeType时出错,出错信息:%@出错文件:%@",error.localizedDescription,self);
29 | return nil;
30 | }
31 |
32 | NSString *mimeType=response.MIMEType;
33 |
34 | if(mimeType==nil || mimeType.length==0){
35 | NSLog(@"获取指定文件的mimeType时为空:%@出错文件:%@",mimeType,self);
36 | return nil;
37 | }
38 |
39 | return mimeType;
40 | }
41 |
42 |
43 |
44 |
45 | /**
46 | * 获取指定path的文件的data
47 | */
48 | -(NSData *)dataForFileResource{
49 |
50 | NSURLRequest *request=[NSURLRequest requestWithURL:self];
51 |
52 | NSURLResponse *response=nil;
53 |
54 | NSError *error=nil;
55 |
56 | //使用同步请求,访问本地文件
57 | NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
58 |
59 | if(error!=nil){
60 | NSLog(@"获取指定文件的data数据时出错,出错信息:%@出错文件:%@",error.localizedDescription,self);
61 | return nil;
62 | }
63 |
64 | if(data==nil || data.length==0){
65 | NSLog(@"获取指定文件的data数据为空,出错文件:%@",self);
66 | return nil;
67 | }
68 |
69 | return data;
70 | }
71 |
72 |
73 |
74 | @end
75 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreHttp/Upload/UploadFile.h:
--------------------------------------------------------------------------------
1 | //
2 | // UploadFile.h
3 | // Upload
4 | //
5 | // Created by muxi on 15/2/11.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | // 上传的文件
8 |
9 | #import
10 |
11 | @interface UploadFile : NSObject
12 |
13 | @property (nonatomic,strong) NSString *key; //文件上传对应的key,如果不传默认放入file[]
14 |
15 | @property (nonatomic,copy) NSURL *url; //文件本地路径
16 |
17 | @property (nonatomic,copy) NSString *name; //文件名
18 |
19 | @property (nonatomic,copy) NSString *mimeType; //文件类型
20 |
21 | @property (nonatomic,assign) NSInteger size; //文件大小(服务器自动获取)
22 |
23 | @property (nonatomic,strong) NSData *data; //文件的二进制数据
24 |
25 | @property (nonatomic,copy) NSString *tmp_name; //临时文件名(服务器自动获取)
26 |
27 | @property (nonatomic,copy) NSString *error; //文件错误信息(服务器自动获取)
28 |
29 |
30 | /**
31 | * 文件:基于本地URL创建
32 | */
33 | +(instancetype)fileWithKey:(NSString *)key url:(NSURL *)url;
34 |
35 |
36 |
37 | /**
38 | * 自动获取mimeType
39 | *
40 | * @param key key:服务器对应的key
41 | * @param data 图片二进制数据
42 | * @param name 图片名称
43 | *
44 | * @return 实例
45 | */
46 | +(instancetype)fileWithKey:(NSString *)key data:(NSData *)data name:(NSString *)name;
47 |
48 |
49 |
50 |
51 | /**
52 | * 如果自动处理mimeType出错,建议使用此方法,一般不使用此方法
53 | */
54 | +(instancetype)fileWithKey:(NSString *)key data:(NSData *)data mimeType:(NSString *)mimeType name:(NSString *)name NS_DEPRECATED_IOS(2_0, 6_0, "Charlin提示您:请使用fileWithKey:data:name:");
55 |
56 |
57 |
58 | @end
59 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreHttp/Upload/UploadFile.m:
--------------------------------------------------------------------------------
1 | //
2 | // UploadFile.m
3 | // Upload
4 | //
5 | // Created by muxi on 15/2/11.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "UploadFile.h"
10 | #import "NSURL+File.h"
11 | #import "NSString+File.h"
12 | #import "NSData+MimeType.h"
13 |
14 | @implementation UploadFile
15 |
16 |
17 | /**
18 | * 文件:通过url创建
19 | */
20 | +(instancetype)fileWithKey:(NSString *)key url:(NSURL *)url{
21 |
22 | UploadFile *file=[[UploadFile alloc] init];
23 |
24 | if(url==nil){
25 | NSLog(@"初始化文件时传入了一个空的本地URL资源地址,请检查!");
26 | return file;
27 | }
28 |
29 | //key
30 | file.key=key;
31 |
32 | //保存路径
33 | file.url=url;
34 |
35 | //获取文件名
36 | file.name=[url.absoluteString lastPathComponent];
37 |
38 | //获取mimeType
39 | file.mimeType=[url mimeType];
40 |
41 | //获取data
42 | file.data=[url dataForFileResource];
43 |
44 | return file;
45 | }
46 |
47 |
48 |
49 | /**
50 | * 自动获取mimeType
51 | *
52 | * @param key key:服务器对应的key
53 | * @param data 图片二进制数据
54 | * @param name 图片名称
55 | *
56 | * @return 实例
57 | */
58 | +(instancetype)fileWithKey:(NSString *)key data:(NSData *)data name:(NSString *)name{
59 |
60 | UploadFile *file=[[UploadFile alloc] init];
61 |
62 | //key
63 | file.key=key;
64 |
65 | //data
66 | file.data=data;
67 |
68 | //name
69 | file.name=name;
70 |
71 | //mimeType
72 | file.mimeType=data.mimeType;
73 |
74 | return file;
75 | }
76 |
77 |
78 | /**
79 | * 如果自动处理mimeType出错,可尝试使用此方法,一般不使用此方法
80 | */
81 | +(instancetype)fileWithKey:(NSString *)key data:(NSData *)data mimeType:(NSString *)mimeType name:(NSString *)name{
82 |
83 | UploadFile *file=[self fileWithKey:key data:data name:name];
84 |
85 | //mimeType
86 | file.mimeType=mimeType;
87 |
88 | return file;
89 | }
90 |
91 | -(NSString *)description{
92 | return [NSString stringWithFormat:@"key=%@,name=%@,mimeType=%@",self.key,self.name,self.mimeType];
93 | }
94 |
95 | -(NSString *)key{
96 |
97 | if(_key==nil){
98 |
99 | _key=@"file[]";
100 | }
101 |
102 | return _key;
103 | }
104 |
105 | @end
106 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreList/Common/Controller/CoreListVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreListController.h
3 | // CoreListMVC
4 | //
5 | // Created by 沐汐 on 15-3-11.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | // TableView列表控制器和CollectionView列表控制器的父类
8 | //
9 | // 目的:统一上拉下拉业务,高度封装。
10 | //
11 | // 1.无缓存功能
12 | // 2.含上拉下拉功能。
13 | // 3.上拉下拉可定制,即可选择是否添加上拉功能、下拉功能。
14 | // 4.支持自动数据转模型操作。
15 | // 5.支持GET/POST请求。
16 |
17 |
18 |
19 | #import
20 | #import "LTConfigModel.h"
21 | #import "CoreHttp.h"
22 |
23 | @interface CoreListVC : UIViewController
24 |
25 | /**
26 | * 配置模型
27 | */
28 | @property (nonatomic,strong) LTConfigModel *configModel;
29 |
30 |
31 | /**
32 | * 数据
33 | */
34 | @property (nonatomic,strong) NSArray *dataList;
35 |
36 |
37 |
38 | /**
39 | * scrollView
40 | */
41 | @property (nonatomic,strong) UIScrollView *scrollView;
42 |
43 |
44 | @property (nonatomic,copy) void (^errorBlock)(CoreHttpErrorType errorType);
45 |
46 |
47 |
48 | /**
49 | * 模型配置正确。框架开始运作。
50 | */
51 | -(void)workBegin;
52 |
53 |
54 | /**
55 | * 重新加载数据(内部子类调用,此方法不会导致请求网络数据)
56 | */
57 | -(void)reloadData;
58 |
59 |
60 |
61 | /**
62 | * 刷新获取最新数据:此方法会触发顶部刷新控件,并且scrollView会回到顶部
63 | */
64 | -(void)reloadDataWithheaderViewStateRefresh;
65 |
66 |
67 | /**
68 | * 刷新获取最新数据:此方法不会触发顶部刷新控件,scrollView不会回到顶部
69 | */
70 | -(void)reloadDataDerectly;
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreList/Common/Model/CoreListCommonModel.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreListCommonModel.h
3 | // CoreListMVC
4 | //
5 | // Created by muxi on 15/3/12.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "NSObject+MJKeyValue.h"
11 |
12 |
13 |
14 |
15 |
16 | @interface CoreListCommonModel : NSObject
17 |
18 |
19 | /**
20 | * 服务器id
21 | */
22 | @property (nonatomic,assign) NSInteger hostID;
23 |
24 |
25 |
26 |
27 | /**
28 | * 数据处理
29 | *
30 | * @param obj 原始数据
31 | *
32 | * @return 数组
33 | */
34 | +(NSArray *)modelPrepare:(id)obj;
35 |
36 |
37 |
38 |
39 |
40 | /**
41 | * 模型数组校验
42 | */
43 | +(BOOL)check:(NSArray *)models;
44 |
45 |
46 |
47 |
48 |
49 |
50 | /**
51 | * 模型数组对比
52 | */
53 | +(BOOL)ListModel:(NSArray *)modelArray1 isEqual:(NSArray *)modelArray2;
54 |
55 |
56 |
57 |
58 | @end
59 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreList/Common/Model/CoreListCommonModel.m:
--------------------------------------------------------------------------------
1 | //
2 | // CoreListCommonModel.m
3 | // CoreListMVC
4 | //
5 | // Created by muxi on 15/3/12.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import "CoreListCommonModel.h"
10 |
11 | @implementation CoreListCommonModel
12 |
13 |
14 |
15 | +(NSDictionary *)replacedKeyFromPropertyName{
16 | return @{@"hostID":@"id"};
17 | }
18 |
19 |
20 |
21 |
22 |
23 |
24 | /**
25 | * 数据处理
26 | *
27 | * @param obj 原始数据
28 | *
29 | * @return 数组
30 | */
31 | +(NSArray *)modelPrepare:(id)obj{
32 | return obj;
33 | }
34 |
35 |
36 |
37 | /**
38 | * 模型数组校验
39 | */
40 | +(BOOL)check:(NSArray *)models{
41 |
42 | if(models==nil || models.count==0){
43 | NSLog(@"当前数据为空:当前模型为:%@",NSStringFromClass(self));
44 | return NO;
45 | }
46 |
47 | for (CoreListCommonModel *model in models) {
48 |
49 | if([model isKindOfClass:self]) continue;
50 |
51 | NSLog(@"\n当前数组里面装的不是%@模型,\n数组内容为:%@",NSStringFromClass(self),models);
52 |
53 | return NO;
54 | }
55 |
56 | return YES;
57 | }
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | /**
68 | * 模型数组对比
69 | */
70 | +(BOOL)ListModel:(NSArray *)modelArray1 isEqual:(NSArray *)modelArray2{
71 |
72 | //排序
73 | NSArray *sortedArray1 = [self modelArrayAsc:modelArray1];
74 | NSArray *sortedArray2 = [self modelArrayAsc:modelArray2];
75 |
76 | //1.对比hostID数组,如果hostID数组都不一致,则数组一定不相同
77 | NSArray *idArray1 = [sortedArray1 valueForKeyPath:@"hostID"];
78 | NSArray *idArray2 = [sortedArray2 valueForKeyPath:@"hostID"];
79 |
80 | if(![idArray1 isEqualToArray:idArray2]) return NO;
81 |
82 | //id数组一样,则需要详细对比整体内容
83 | //模型数组转字典数组
84 | NSArray *dictArray1=[NSObject keyValuesArrayWithObjectArray:sortedArray1];
85 | NSArray *dictArray2=[NSObject keyValuesArrayWithObjectArray:sortedArray2];
86 |
87 | if(![dictArray1 isEqualToArray:dictArray2]) {
88 | NSLog(@"不相同");
89 | return NO;
90 | }else{
91 | NSLog(@"相同");
92 | }
93 |
94 | return YES;
95 | }
96 |
97 |
98 |
99 | /**
100 | * 模型数组升序排列
101 | *
102 | * @param modelArray 原数组
103 | *
104 | * @return 升序数组
105 | */
106 | +(NSArray *)modelArrayAsc:(NSArray *)modelArray{
107 |
108 | NSArray *sortedModelArray = [modelArray sortedArrayUsingComparator:^NSComparisonResult(CoreListCommonModel *m1, CoreListCommonModel *m2) {
109 |
110 | if(m1.hostIDm2.hostID) return NSOrderedDescending;
112 |
113 | return NSOrderedSame;
114 | }];
115 |
116 | return sortedModelArray;
117 | }
118 |
119 |
120 |
121 | @end
122 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreList/Common/Model/LTConfigModel.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreLTVCConfigModel.h
3 | // CoreLTVC
4 | //
5 | // Created by 沐汐 on 15-3-9.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | // 配置模型
8 |
9 | #import
10 | #import
11 |
12 | typedef enum {
13 |
14 | //GET
15 | LTConfigModelHTTPMethodGET=0,
16 |
17 | //POST
18 | LTConfigModelHTTPMethodPOST,
19 |
20 | }LTConfigModelHTTPMethod;
21 |
22 |
23 |
24 | typedef enum{
25 |
26 | //顶部刷新、底部刷新控件均安装
27 | LTConfigModelRefreshControlTypeBoth=0,
28 |
29 | //仅仅安装顶部刷新新控
30 | LTConfigModelRefreshControlTypeTopRefreshOnly,
31 |
32 | //仅仅安装底部刷新新控
33 | LTConfigModelRefreshControlTypeBottomRefreshOnly,
34 |
35 | //顶部刷新、底部刷新控件均不安装,仅仅是利用数据解析的便利
36 | LTConfigModelRefreshControlTypeNeither,
37 |
38 |
39 | }LTConfigModelRefreshControlType;
40 |
41 |
42 |
43 | @interface LTConfigModel : NSObject
44 |
45 |
46 | /**
47 | * ----------------必传参数----------------url、params、ModelClass、ViewForCellClass
48 | */
49 |
50 |
51 |
52 | /**
53 | * url地址
54 | */
55 | @property (nonatomic,copy) NSString *url;
56 |
57 |
58 | /**
59 | * 参数:注意参数中无需考虑page及pageSize
60 | */
61 | @property (nonatomic,strong) NSDictionary *params;
62 |
63 |
64 |
65 | /**
66 | * 数据模型类
67 | */
68 | @property (nonatomic,assign) Class ModelClass;
69 |
70 |
71 | /**
72 | * cell所用类:注,cell默认从xib创建
73 | */
74 | @property (nonatomic,assign) Class ViewForCellClass;
75 |
76 |
77 |
78 |
79 |
80 |
81 | /**
82 | * ----------------选填参数----------------pageStartValue、pageName、pageSizeName、pageSize、cycle、refreshControlType、httpMethod、rowHeight、lid
83 | */
84 |
85 | /**
86 | * 页面的起始值:默认为1
87 | */
88 | @property (nonatomic,assign) NSInteger pageStartValue;
89 |
90 |
91 | /**
92 | * pageName:默认为page
93 | */
94 | @property (nonatomic,copy) NSString *pageName;
95 |
96 | /**
97 | * pageSizeName:默认为pagesize
98 | */
99 | @property (nonatomic,copy) NSString *pageSizeName;
100 |
101 |
102 |
103 | /**
104 | * pageSize:强制要求最低是10个
105 | */
106 | @property (nonatomic,assign) NSInteger pageSize;
107 |
108 |
109 | /**
110 | * 更新数据周期:默认为5分钟,单位是秒
111 | */
112 | @property (nonatomic,assign) NSTimeInterval cycle;
113 |
114 |
115 | /**
116 | * 刷新控件安装方式:默认为均安装
117 | */
118 | @property (nonatomic,assign) LTConfigModelRefreshControlType refreshControlType;
119 |
120 |
121 | /**
122 | * 请求方式:默认为GET方式
123 | */
124 | @property (nonatomic,assign) LTConfigModelHTTPMethod httpMethod;
125 |
126 | /**
127 | * cell的行高:默认是44
128 | */
129 | @property (nonatomic,assign) CGFloat rowHeight;
130 |
131 |
132 | /**
133 | * 控制器唯一标识:用于定期更新数据
134 | */
135 | @property (nonatomic,copy) NSString *lid;
136 |
137 |
138 | /**
139 | * 是否移除返回顶部功能按钮,默认不移除
140 | */
141 | @property (nonatomic,assign) BOOL removeBackToTopBtn;
142 |
143 |
144 | @end
145 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreList/Common/Model/LTConfigModel.m:
--------------------------------------------------------------------------------
1 | //
2 | // CoreLTVCConfigModel.m
3 | // CoreLTVC
4 | //
5 | // Created by 沐汐 on 15-3-9.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import "LTConfigModel.h"
10 |
11 | @implementation LTConfigModel
12 |
13 | - (instancetype)init
14 | {
15 | self = [super init];
16 | if (self) {
17 |
18 | //模型初始化
19 | [self modelPrepare];
20 | }
21 | return self;
22 | }
23 |
24 |
25 |
26 |
27 | /**
28 | * 模型初始化
29 | */
30 | -(void)modelPrepare{
31 |
32 | //请求方式:GET
33 | self.httpMethod=LTConfigModelHTTPMethodGET;
34 |
35 | //安装方式
36 | self.refreshControlType=LTConfigModelRefreshControlTypeBoth;
37 |
38 | //更新周期
39 | self.cycle=5 * 60.0f;
40 |
41 | //pagesize
42 | self.pageSize=10;
43 |
44 | //pageSizeName
45 | self.pageSizeName=@"pagesize";
46 |
47 | //pageName
48 | self.pageName=@"page";
49 |
50 | //pageStartValue
51 | self.pageStartValue=1;
52 |
53 | //cellHeight
54 | self.rowHeight=44.0f;
55 | }
56 |
57 |
58 |
59 |
60 |
61 | -(NSInteger)pageSize{
62 |
63 | if(_pageSize<10){
64 | _pageSize =10;
65 | }
66 |
67 | return _pageSize;
68 | }
69 |
70 |
71 | -(void)setParams:(NSDictionary *)params{
72 |
73 | _params=params;
74 |
75 | //参数检查
76 | NSArray *keys=[params allKeys];
77 |
78 | if([keys containsObject:@"p"]||[keys containsObject:@"page"]||[keys containsObject:@"pagesize"]||[keys containsObject:@"pageSize"]) NSLog(@"参数中请不要带入page信息");
79 | }
80 |
81 |
82 |
83 |
84 | @end
85 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreList/Common/Resource/CoreList.bundle/back_top@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CorePagesView/905caceaf4b2d8ede868bb8c231f38daf802066b/CorePagesView/Frameworks/CoreList/Common/Resource/CoreList.bundle/back_top@2x.png
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreList/CoreLTVC_Useage_ReadME.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreLTVC_ReadME.h
3 | // CoreLTVC
4 | //
5 | // Created by 沐汐 on 15-3-9.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #ifndef CoreLTVC_CoreLTVC_ReadME_h
10 | #define CoreLTVC_CoreLTVC_ReadME_h
11 |
12 | /*
13 |
14 | 使用说明:
15 |
16 |
17 | 一.框架说明:
18 |
19 | (1)本框架集成了没有缓存功能的TableView列表、CollectionView列表。
20 |
21 | (2)本框架依赖以下框架:CoreArchive、MJExtension、CoreHttp、CoreRefresh、CoreViewNetWorkStausManager
22 |
23 | (3)使用前,一定要清醒的认识到,父类控制器一个ViewController,他里面分别装有TableView和CollectionView,并非纯正的TableViewVC和CollectionViewVC,因为这样很难统一封装网络请求及上拉下拉加载业务。
24 |
25 |
26 |
27 | 二、使用步骤:
28 |
29 | 1.UITableViewMVC的集成:
30 | (1)控制器: 建立控制器,继承自CoreLTVC,建立LTConfigModel模型并传递。
31 | (2)视图: 建立视图cell,继承自LTCell,重写+(instancetype)cellPrepare方法,创建cell(父类默认从同名Nib创建,也可自行使用代码创建,注意cell从nib创建,nib中需要指定和类名相同的rid。)。
32 | (3)模型: 继承通用模型,继承自CoreListCommonModel:重写+(NSArray *)modelPrepare:方法,解析并返回列表的字典数组。
33 |
34 | 2.UICollectionViewMVC的集成:
35 | (1)控制器: 建立控制器,继承自CoreLCVC,控制器内部建立UICollectionViewFlowLayout及LTConfigModel模型并传递。
36 | (2)视图cell:建立cell,继承自LCCell,内部实现-(void)dataFill即可。(注意cell从nib创建,nib中需要指定和类名相同的rid。)
37 | (3)模型: 建立模型,继承自CoreListCommonModel,重写+(NSArray *)modelPrepare:方法,解析并返回列表的字典数组。
38 |
39 | */
40 |
41 |
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreList/CoreListCVC/VC/CoreLCVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreCVC.h
3 | // CoreListMVC
4 | //
5 | // Created by 沐汐 on 15-3-11.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "CoreListVC.h"
11 |
12 | @interface CoreLCVC : CoreListVC
13 |
14 | /**
15 | * collectionView
16 | */
17 | @property (nonatomic,weak) UICollectionView *collectionView;
18 |
19 |
20 | /**
21 | * 初始化方法
22 | */
23 | - (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout;
24 |
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreList/CoreListCVC/VC/CoreLCVC.m:
--------------------------------------------------------------------------------
1 | //
2 | // CoreCVC.m
3 | // CoreListMVC
4 | //
5 | // Created by 沐汐 on 15-3-11.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import "CoreLCVC.h"
10 | #import "LCCell.h"
11 |
12 |
13 |
14 | @interface CoreLCVC ()
15 |
16 | /**
17 | * 布局配置对象
18 | */
19 | @property (nonatomic,strong) UICollectionViewLayout *layout;
20 |
21 |
22 | @end
23 |
24 |
25 |
26 |
27 |
28 | @implementation CoreLCVC
29 |
30 |
31 | /**
32 | * 初始化方法
33 | */
34 | - (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout{
35 |
36 | self=[super init];
37 |
38 | if(self){
39 |
40 | self.layout=layout;
41 | }
42 |
43 | return self;
44 | }
45 |
46 |
47 |
48 |
49 |
50 |
51 | /**
52 | * 重新加载数据
53 | */
54 | -(void)reloadData{
55 | dispatch_async(dispatch_get_main_queue(), ^{
56 | [self.collectionView reloadData];
57 | });
58 | }
59 |
60 |
61 |
62 | /**
63 | * 有多少组
64 | */
65 | -(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
66 | return 1;
67 | }
68 |
69 |
70 |
71 | /**
72 | * 共有多少行
73 | */
74 | -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
75 | return self.dataList.count;
76 | }
77 |
78 |
79 |
80 |
81 | /**
82 | * cell
83 | */
84 | -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
85 |
86 | NSString *rid=NSStringFromClass(self.configModel.ViewForCellClass);
87 |
88 | LCCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:rid forIndexPath:indexPath];
89 |
90 | cell.model=self.dataList[indexPath.item];
91 |
92 | return cell;
93 | }
94 |
95 |
96 |
97 |
98 |
99 | /**
100 | * collectionView
101 | */
102 | -(UICollectionView *)collectionView{
103 |
104 | if(_collectionView==nil){
105 | UICollectionView *collectionView=[[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:_layout];
106 | _collectionView=collectionView;
107 | collectionView.delegate=self;
108 | collectionView.dataSource=self;
109 | [self.view addSubview:collectionView];
110 |
111 | collectionView.translatesAutoresizingMaskIntoConstraints=NO;
112 | NSDictionary *views=NSDictionaryOfVariableBindings(collectionView);
113 | [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[collectionView]-0-|" options:0 metrics:nil views:views]];
114 | [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[collectionView]-0-|" options:0 metrics:nil views:views]];
115 | }
116 |
117 | return _collectionView;
118 | }
119 |
120 |
121 |
122 | /**
123 | * scrollView
124 | */
125 | -(UIScrollView *)scrollView{
126 | return self.collectionView;
127 | }
128 |
129 |
130 |
131 | @end
132 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreList/CoreListCVC/View/LCCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // CLCell.h
3 | // CoreListMVC
4 | //
5 | // Created by 沐汐 on 15-3-11.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "CoreListCommonModel.h"
11 |
12 | @interface LCCell : UICollectionViewCell
13 |
14 |
15 |
16 |
17 | /**
18 | * 模型数据
19 | */
20 | @property (nonatomic,strong) CoreListCommonModel *model;
21 |
22 |
23 |
24 | /**
25 | * indexPath
26 | */
27 | @property (nonatomic,strong) NSIndexPath *indexPath;
28 |
29 |
30 |
31 | /**
32 | * 填充数据
33 | */
34 | -(void)dataFill;
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreList/CoreListCVC/View/LCCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // CLCell.m
3 | // CoreListMVC
4 | //
5 | // Created by 沐汐 on 15-3-11.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import "LCCell.h"
10 |
11 | @implementation LCCell
12 |
13 |
14 |
15 | -(void)setModel:(CoreListCommonModel *)model{
16 |
17 | //记录
18 | _model=model;
19 |
20 | //调用数据填充方法
21 | [self dataFill];
22 | }
23 |
24 |
25 |
26 | /**
27 | * 填充数据:等待子类实现
28 | */
29 | -(void)dataFill{}
30 |
31 |
32 |
33 |
34 |
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreList/CoreListTVC/VC/CoreLTVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreLTVC.h
3 | // CoreLTVC
4 | //
5 | // Created by 沐汐 on 15-3-9.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | // 封装列表
8 |
9 |
10 |
11 |
12 | #import
13 | #import "CoreListVC.h"
14 |
15 |
16 | @interface CoreLTVC : CoreListVC
17 |
18 |
19 | /**
20 | * tableView
21 | */
22 | @property (nonatomic,weak) UITableView *tableView;
23 |
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreList/CoreListTVC/VC/CoreLTVC.m:
--------------------------------------------------------------------------------
1 | //
2 | // CoreLTVC.m
3 | // CoreLTVC
4 | //
5 | // Created by 沐汐 on 15-3-9.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import "CoreLTVC.h"
10 | #import "LTCell.h"
11 |
12 |
13 | @interface CoreLTVC ()
14 |
15 |
16 | @end
17 |
18 |
19 |
20 |
21 |
22 | @implementation CoreLTVC
23 |
24 |
25 |
26 | -(void)viewDidLoad{
27 |
28 | [super viewDidLoad];
29 |
30 | self.tableView.tableFooterView=[[UIView alloc] init];
31 | }
32 |
33 |
34 | /**
35 | * 模型配置正确。框架开始运作。
36 | */
37 | -(void)workBegin{
38 |
39 | [super workBegin];
40 |
41 | self.tableView.rowHeight=self.configModel.rowHeight;
42 | }
43 |
44 |
45 |
46 | /**
47 | * 重新加载数据
48 | */
49 | -(void)reloadData{
50 |
51 | dispatch_async(dispatch_get_main_queue(), ^{
52 | [self.tableView reloadData];
53 | });
54 | }
55 |
56 |
57 |
58 | /**
59 | * 有多少组
60 | */
61 | -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
62 | return 1;
63 | }
64 |
65 |
66 |
67 | /**
68 | * 共有多少行
69 | */
70 | -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
71 | return self.dataList.count;
72 | }
73 |
74 |
75 |
76 |
77 | /**
78 | * cell
79 | */
80 | -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
81 |
82 | //子类真实实例化,父类多态接收
83 | LTCell *cell=[self.configModel.ViewForCellClass cellWithTableView:tableView];
84 |
85 | //数据传递
86 | cell.indexPath=indexPath;
87 |
88 | //模型传递
89 | cell.model=self.dataList[indexPath.row];
90 |
91 | return cell;
92 | }
93 |
94 |
95 |
96 |
97 | /**
98 | * tableView
99 | */
100 | -(UITableView *)tableView{
101 |
102 | if(_tableView==nil){
103 | UITableView *tableView=[[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
104 |
105 |
106 | _tableView=tableView;
107 | tableView.delegate=self;
108 | tableView.dataSource=self;
109 | [self.view addSubview:tableView];
110 |
111 | tableView.translatesAutoresizingMaskIntoConstraints=NO;
112 | NSDictionary *views=NSDictionaryOfVariableBindings(tableView);
113 | [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[tableView]-0-|" options:0 metrics:nil views:views]];
114 | [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[tableView]-0-|" options:0 metrics:nil views:views]];
115 | }
116 |
117 | return _tableView;
118 | }
119 |
120 |
121 |
122 | /**
123 | * scrollView
124 | */
125 | -(UIScrollView *)scrollView{
126 | return self.tableView;
127 | }
128 |
129 |
130 | /**
131 | * 代理方法
132 | */
133 |
134 | /**
135 | * 选中行
136 | */
137 | -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
138 | [tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
139 | }
140 |
141 | /**
142 | * 反选中行
143 | */
144 | -(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{
145 | [tableView deselectRowAtIndexPath:indexPath animated:YES];
146 | }
147 |
148 |
149 | @end
150 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreList/CoreListTVC/View/LTCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // LTCell.h
3 | // CoreLTVC
4 | //
5 | // Created by 沐汐 on 15-3-9.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "CoreListCommonModel.h"
11 |
12 |
13 |
14 | @interface LTCell : UITableViewCell
15 |
16 |
17 | /**
18 | * 模型数据
19 | */
20 | @property (nonatomic,strong) CoreListCommonModel *model;
21 |
22 | /**
23 | * indexPath
24 | */
25 | @property (nonatomic,strong) NSIndexPath *indexPath;
26 |
27 |
28 | /**
29 | * 从缓存池中取cell封装
30 | */
31 | +(instancetype)cellWithTableView:(UITableView *)tableView;
32 |
33 |
34 | /**
35 | * cell的创建
36 | */
37 | +(instancetype)cellPrepare;
38 |
39 |
40 | /**
41 | * 填充数据
42 | */
43 | -(void)dataFill;
44 |
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreList/CoreListTVC/View/LTCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // LTCell.m
3 | // CoreLTVC
4 | //
5 | // Created by 沐汐 on 15-3-9.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import "LTCell.h"
10 |
11 | @implementation LTCell
12 |
13 |
14 | /**
15 | * 从缓存池中取cell封装
16 | */
17 | +(instancetype)cellWithTableView:(UITableView *)tableView{
18 |
19 | NSString *rid=NSStringFromClass(self);
20 |
21 | LTCell *cell=[tableView dequeueReusableCellWithIdentifier:rid];
22 |
23 | if(cell==nil) cell=[self cellPrepare];
24 |
25 | return cell;
26 | }
27 |
28 |
29 | /**
30 | * cell的创建
31 | */
32 | +(instancetype)cellPrepare{
33 |
34 | LTCell *cell = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil] firstObject];
35 | return cell;
36 | }
37 |
38 |
39 |
40 | -(void)setModel:(CoreListCommonModel *)model{
41 |
42 | //记录
43 | _model=model;
44 |
45 | dispatch_async(dispatch_get_main_queue(), ^{
46 | //调用数据填充方法
47 | [self dataFill];
48 | });
49 | }
50 |
51 |
52 |
53 | /**
54 | * 填充数据:等待子类实现
55 | */
56 | -(void)dataFill{}
57 |
58 |
59 |
60 |
61 | @end
62 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/CAAnimation+CoreRefresh.h:
--------------------------------------------------------------------------------
1 | //
2 | // CAAnimation+CoreRefresh.h
3 | // CoreListMVC
4 | //
5 | // Created by muxi on 15/3/12.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | // 动画生成分类
8 |
9 | #import
10 |
11 | @interface CAAnimation (CoreRefresh)
12 |
13 |
14 |
15 | /**
16 | * 生成一个翻转动画
17 | */
18 | +(CABasicAnimation *)rotationAnim;
19 |
20 |
21 |
22 | /**
23 | * 旋转动画
24 | */
25 | +(CABasicAnimation *)rotaAnim;
26 |
27 |
28 |
29 | /**
30 | * 抖动
31 | */
32 | +(CAKeyframeAnimation *)shakeAnim;
33 |
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/CAAnimation+CoreRefresh.m:
--------------------------------------------------------------------------------
1 | //
2 | // CAAnimation+CoreRefresh.m
3 | // CoreListMVC
4 | //
5 | // Created by muxi on 15/3/12.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import "CAAnimation+CoreRefresh.h"
10 |
11 | @implementation CAAnimation (CoreRefresh)
12 |
13 | #define kDegreeToRadian(x) (M_PI/180.0 * (x))
14 |
15 | /**
16 | * 生成一个翻转动画
17 | */
18 | +(CABasicAnimation *)rotationAnim{
19 |
20 | CABasicAnimation *anim=[CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
21 |
22 | //起点
23 | anim.fromValue = @(0);
24 |
25 | //终点
26 | anim.toValue=@(kDegreeToRadian(-360));
27 |
28 | //动画时长
29 | anim.duration=1.f;
30 |
31 | //是否反转
32 | anim.autoreverses=NO;
33 |
34 | //是否重复
35 | anim.repeatCount=.0f;
36 |
37 | //动画完成移除
38 | anim.removedOnCompletion=YES;
39 |
40 | return anim;
41 | }
42 |
43 |
44 |
45 | /**
46 | * 旋转动画
47 | */
48 | +(CABasicAnimation *)rotaAnim{
49 |
50 |
51 | CABasicAnimation *anim=[CABasicAnimation animationWithKeyPath:@"transform.rotation"];
52 |
53 | //设置起点
54 | anim.fromValue=0;
55 |
56 | //设置终点
57 | anim.toValue=@(kDegreeToRadian(360.0f));
58 |
59 | //设置动画执行一次的时长
60 | anim.duration=.8f;
61 |
62 | //设置速度函数
63 | anim.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
64 |
65 | //完成动画不删除:
66 | anim.removedOnCompletion=NO;
67 |
68 | //向前填充
69 | anim.fillMode=kCAFillModeForwards;
70 |
71 | //设置重复次数
72 | anim.repeatCount=MAXFLOAT;
73 |
74 |
75 | return anim;
76 | }
77 |
78 |
79 | /**
80 | * 抖动
81 | */
82 | +(CAKeyframeAnimation *)shakeAnim{
83 |
84 | CAKeyframeAnimation *kfa=[CAKeyframeAnimation animationWithKeyPath:@"transform.rotation"];
85 |
86 | //值
87 | kfa.values=@[@0.1f,@(0),@(-0.1f),@(0),@0.1f,@(0),@(-0.1f)];
88 |
89 | //设置时间
90 | kfa.duration=0.15f;
91 |
92 | //是否重复
93 | kfa.repeatCount=6.0f;
94 |
95 | //是否反转
96 | kfa.autoreverses=YES;
97 |
98 | //完成移除
99 | kfa.removedOnCompletion=YES;
100 |
101 | return kfa;
102 | }
103 |
104 | @end
105 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/CoreFooterView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreFooterView.h
3 | // CoreRefresh
4 | //
5 | // Created by 沐汐 on 15-1-18.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "CoreRefreshView.h"
11 |
12 | typedef enum{
13 |
14 | CoreFooterViewRefreshStateNormalForContinueDragUp=0, //这就是最普通的状态,并且普通状态是请继续拉动
15 |
16 | CoreFooterViewRefreshStateRefreshing, //刷新中
17 |
18 | CoreFooterViewRefreshStateFailed, //刷新失败
19 |
20 | CoreFooterViewRefreshStateSuccessedResultNoMoreData, //刷新成功->无更多数据
21 |
22 | CoreFooterViewRefreshStateSuccessedResultDataShowing, //刷新成功->本次的新数据正在展示中(此状态会延时变更为0)
23 |
24 | }CoreFooterViewRefreshState;
25 |
26 |
27 | @interface CoreFooterView : CoreRefreshView
28 |
29 |
30 | @property (nonatomic,assign) CoreFooterViewRefreshState state; //底部控件的状态
31 |
32 | + (instancetype)footer;
33 |
34 | -(void)removeFooter;
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/CoreFooterView.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/CoreHeaderShowView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreHeaderShowView.h
3 | // CoreRefresh
4 | //
5 | // Created by muxi on 15/1/19.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CoreHeaderShowView : UIView
12 |
13 | @property (nonatomic,assign) CGFloat progress; //进度
14 |
15 | @property (nonatomic,assign,getter=isRefreshing) BOOL refreshing; //是否刷新中
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/CoreHeaderShowView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CoreHeaderShowView.m
3 | // CoreRefresh
4 | //
5 | // Created by muxi on 15/1/19.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "CoreHeaderShowView.h"
10 | #import "UIView+MJExtension.h"
11 | #import "CAAnimation+CoreRefresh.h"
12 |
13 | #define kDegreeToRadian(x) (M_PI/180.0 * (x))
14 | #define rgba(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
15 |
16 |
17 |
18 |
19 | @interface CoreHeaderShowView ()
20 |
21 | @property (nonatomic,strong) CABasicAnimation *rotaAnim;
22 |
23 | @property (nonatomic,assign) CGFloat centerX,centerY,radius,startAngle;
24 |
25 | @end
26 |
27 | @implementation CoreHeaderShowView
28 |
29 |
30 | -(instancetype)initWithFrame:(CGRect)frame{
31 |
32 | self = [super initWithFrame:frame];
33 |
34 | if(self){
35 |
36 | //添加边框
37 | [self addBorder];
38 | }
39 |
40 | return self;
41 | }
42 |
43 |
44 | -(id)initWithCoder:(NSCoder *)aDecoder{
45 |
46 | self=[super initWithCoder:aDecoder];
47 |
48 | if(self){
49 |
50 | //添加边框
51 | [self addBorder];
52 | }
53 |
54 | return self;
55 | }
56 |
57 |
58 | /**
59 | * 添加边框
60 | */
61 | -(void)addBorder{
62 | self.layer.borderColor=rgba(120, 120, 120, .1f).CGColor;
63 | self.layer.borderWidth=1.0f;
64 | }
65 |
66 |
67 |
68 |
69 | -(void)drawRect:(CGRect)rect{
70 | //获取上下文
71 | CGContextRef context=UIGraphicsGetCurrentContext();
72 |
73 | //绘制一个进度
74 | [self drawProgressArc:context rect:rect];
75 |
76 | if(!self.refreshing) return;
77 |
78 | [self drawWhiteCircle:context rect:rect];
79 | }
80 |
81 |
82 | #pragma mark 绘制一个进度
83 | -(void)drawProgressArc:(CGContextRef)context rect:(CGRect)rect{
84 |
85 | //新建路径
86 | CGMutablePathRef progressArcPath=CGPathCreateMutable();
87 |
88 | CGFloat endAngle=kDegreeToRadian(_progress * 359.99f)+ kDegreeToRadian(-90);
89 |
90 | //添加一个环形路径
91 | CGPathAddArc(progressArcPath, NULL, self.centerX, self.centerY, self.radius, self.startAngle, endAngle, NO);
92 |
93 | //设置路径属性
94 | //1.设置颜色
95 | [[UIColor colorWithRed:.5f green:.5f blue:.5f alpha:.5f] setStroke];
96 | //2.设置线宽
97 | CGContextSetLineWidth(context, 2.0f);
98 |
99 | //将路径添加到上下文中
100 | CGContextAddPath(context, progressArcPath);
101 |
102 | //渲染路径
103 | CGContextStrokePath(context);
104 |
105 | //释放路径
106 | CGPathRelease(progressArcPath);
107 | }
108 |
109 |
110 |
111 | #pragma mark 绘制一个白色的圆环
112 | -(void)drawWhiteCircle:(CGContextRef)context rect:(CGRect)rect{
113 |
114 | //新建路径
115 | CGMutablePathRef grayCirclePath=CGPathCreateMutable();
116 |
117 | CGFloat startAngle=kDegreeToRadian(-40);
118 | CGFloat endAngle=kDegreeToRadian(200);
119 |
120 | CGPathAddArc(grayCirclePath, NULL,self.centerX, self.centerY, self.radius, startAngle,endAngle,YES);
121 |
122 | //将路径添加到上下文
123 | CGContextAddPath(context, grayCirclePath);
124 |
125 | //路径设置
126 | //1.颜色
127 | [[UIColor whiteColor] setStroke];
128 | //2.线宽
129 | CGContextSetLineWidth(context, 2.0f);
130 |
131 |
132 | //渲染路径
133 | CGContextStrokePath(context);
134 |
135 | //释放路径
136 | CGPathRelease(grayCirclePath);
137 | }
138 |
139 |
140 |
141 |
142 |
143 | -(void)setProgress:(CGFloat)progress{
144 |
145 | if(_progress==progress) return;
146 |
147 | //异常处理
148 | if(progress<=0) progress=0;
149 | if(progress>=1.0f) progress=1.0f;
150 |
151 | //记录
152 | _progress=progress;
153 |
154 | //重绘
155 | [self setNeedsDisplay];
156 | }
157 |
158 |
159 | -(void)setRefreshing:(BOOL)refreshing{
160 |
161 | //记录
162 | _refreshing=refreshing;
163 |
164 |
165 |
166 | //响应是否刷新中这个状态
167 | if(refreshing){
168 | [self refreshWithYes];
169 | }else{
170 | [self refreshWithNO];
171 | }
172 |
173 | //重绘
174 | [self setNeedsDisplay];
175 | }
176 |
177 |
178 |
179 |
180 |
181 |
182 | #pragma mark 正在刷新中
183 | -(void)refreshWithYes{
184 |
185 | //强制进度
186 | self.progress=1.0f;
187 |
188 | //在iconImageV添加动画
189 | [self.layer addAnimation:[CAAnimation rotaAnim] forKey:@"rotaAnim"];
190 |
191 | }
192 |
193 |
194 |
195 | #pragma mark 没有在刷新
196 | -(void)refreshWithNO{
197 |
198 | //强制进度
199 | self.progress=.001f;
200 |
201 | [self.layer removeAllAnimations];
202 | }
203 |
204 |
205 |
206 |
207 |
208 | #pragma mark get方法区
209 | -(CGFloat)centerX{
210 |
211 | if(!_centerX){
212 | _centerX=self.mj_width *.5f;
213 | }
214 |
215 | return _centerX;
216 | }
217 |
218 | -(CGFloat)centerY{
219 |
220 | if(!_centerY){
221 |
222 | _centerY=self.mj_height *.5f;
223 | }
224 |
225 | return _centerY;
226 | }
227 |
228 | -(CGFloat)radius{
229 |
230 | if(!_radius){
231 | _radius=MIN(self.centerX, self.centerY);
232 | }
233 |
234 | return _radius;
235 | }
236 |
237 | -(CGFloat)startAngle{
238 |
239 | if(!_startAngle){
240 | _startAngle=kDegreeToRadian(270.0f);
241 | }
242 |
243 | return _startAngle;
244 | }
245 |
246 |
247 | @end
248 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/CoreHeaderShowView.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/CoreHeaderView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreHeaderView.h
3 | // CoreRefresh
4 | //
5 | // Created by muxi on 15/1/19.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "CoreRefreshView.h"
10 |
11 | typedef enum{
12 |
13 | CoreHeaderViewRefreshStateNorMal=0, //普通状态
14 |
15 | CoreHeaderViewRefreshStateReleaseForRefreshing, //松手立即刷新
16 |
17 | CoreHeaderViewRefreshStateRefreshing, //刷新中
18 |
19 | CoreHeaderViewRefreshStateRefreshingFailed, //刷新失败
20 |
21 | CoreHeaderViewRefreshStateSuccessedResultNoMoreData, //刷新成功,无更多数据
22 |
23 | CoreHeaderViewRefreshStateSuccessedResultDataShowing, //刷新成功,数据展示中
24 |
25 | }CoreHeaderViewRefreshState;
26 |
27 |
28 |
29 |
30 |
31 | @interface CoreHeaderView : CoreRefreshView
32 |
33 | @property (nonatomic,assign) CoreHeaderViewRefreshState state; //状态
34 |
35 |
36 | + (instancetype)header;
37 |
38 | - (void)removeHeader;
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/CoreHeaderView.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/CoreRefreshConst.h:
--------------------------------------------------------------------------------
1 | //
2 | // RefreshConst.h
3 | // CoreRefresh
4 | //
5 | // Created by 沐汐 on 15-1-18.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface CoreRefreshConst : NSObject
13 |
14 |
15 | // objc_msgSend
16 | #define msgSend(...) ((void (*)(void *, SEL, UIView *))objc_msgSend)(__VA_ARGS__)
17 | #define msgTarget(target) (__bridge void *)(target)
18 |
19 |
20 | UIKIT_EXTERN NSString *const CoreRefreshContentOffset; //contentOffset
21 |
22 | UIKIT_EXTERN NSString *const CoreRefreshContentSize; //contentSize
23 |
24 | UIKIT_EXTERN CGFloat const CoreRefreshHeaderViewH; //头部刷新控件的高度
25 |
26 | UIKIT_EXTERN CGFloat const CoreRefreshFooterViewH; //底部刷新控件的高度
27 |
28 |
29 |
30 |
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/CoreRefreshConst.m:
--------------------------------------------------------------------------------
1 | //
2 | // RefreshConst.m
3 | // CoreRefresh
4 | //
5 | // Created by 沐汐 on 15-1-18.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import "CoreRefreshConst.h"
10 |
11 | @implementation CoreRefreshConst
12 |
13 | NSString *const CoreRefreshContentOffset = @"contentOffset";
14 |
15 | NSString *const CoreRefreshContentSize = @"contentSize";
16 |
17 | CGFloat const CoreRefreshHeaderViewH=80.0f;
18 |
19 | CGFloat const CoreRefreshFooterViewH=60.0f;
20 |
21 |
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/CoreRefreshEntry.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreRefreshEntry.h
3 | // CoreRefresh
4 | //
5 | // Created by 沐汐 on 15-1-18.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | // 核心刷新库全局头文件
8 | //
9 | // 本框架基本MJRefresh
10 | // 本框架请使用setState来表达各种状态
11 | // 建议在viewDidAppear中添加刷新控件
12 | // 在viewDidDisappear中移除
13 |
14 | #import "UIScrollView+Refresh.h"
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/CoreRefreshResource.bundle/coreRefreshIcon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CorePagesView/905caceaf4b2d8ede868bb8c231f38daf802066b/CorePagesView/Frameworks/CoreRefresh/CoreRefreshResource.bundle/coreRefreshIcon@2x.png
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/CoreRefreshView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreRefreshView.h
3 | // CoreRefresh
4 | //
5 | // Created by 沐汐 on 15-1-18.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | // 刷新控件父类
8 |
9 | #import
10 |
11 | @interface CoreRefreshView : UIView
12 |
13 |
14 |
15 |
16 | #pragma mark - 父控件
17 | @property (nonatomic, weak, readonly) UIScrollView *scrollView;
18 | @property (nonatomic, assign, readonly) UIEdgeInsets scrollViewOriginalInset;
19 |
20 |
21 |
22 |
23 |
24 | #pragma mark - 回调
25 | /**
26 | * 开始进入刷新状态的监听器
27 | */
28 | @property (weak, nonatomic) id beginRefreshingTaget;
29 | /**
30 | * 开始进入刷新状态的监听方法
31 | */
32 | @property (assign, nonatomic) SEL beginRefreshingAction;
33 |
34 |
35 |
36 |
37 | /**
38 | * 开始刷新
39 | */
40 | - (void)beginRefreshing;
41 | /**
42 | * 结束刷新
43 | */
44 | - (void)endRefreshing;
45 |
46 |
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/CoreRefreshView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CoreRefreshView.m
3 | // CoreRefresh
4 | //
5 | // Created by 沐汐 on 15-1-18.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import "CoreRefreshView.h"
10 | #import "CoreRefreshConst.h"
11 | #import "UIView+MJExtension.h"
12 | #import "UIScrollView+MJExtension.h"
13 |
14 | @interface CoreRefreshView ()
15 |
16 | @property (nonatomic,assign) BOOL isCalInset;
17 |
18 | @end
19 |
20 | @implementation CoreRefreshView
21 |
22 |
23 | - (void)willMoveToSuperview:(UIView *)newSuperview
24 | {
25 | [super willMoveToSuperview:newSuperview];
26 |
27 | // 旧的父控件
28 | [self.superview removeObserver:self forKeyPath:CoreRefreshContentOffset context:nil];
29 | [self.superview removeObserver:self forKeyPath:CoreRefreshContentSize context:nil];
30 |
31 | if (newSuperview) { // 新的父控件
32 |
33 | // 监听
34 | [newSuperview addObserver:self forKeyPath:CoreRefreshContentOffset options:NSKeyValueObservingOptionNew context:nil];
35 | [newSuperview addObserver:self forKeyPath:CoreRefreshContentSize options:NSKeyValueObservingOptionNew context:nil];
36 |
37 | // 记录UIScrollView
38 | _scrollView = (UIScrollView *)newSuperview;
39 | // 设置永远支持垂直弹簧效果
40 | _scrollView.alwaysBounceVertical = YES;
41 | // 记录UIScrollView最开始的contentInset
42 | _scrollViewOriginalInset = _scrollView.contentInset;
43 | }
44 |
45 | }
46 |
47 |
48 | -(void)didMoveToSuperview{
49 |
50 | // 记录UIScrollView
51 | UIScrollView *scrollView = (UIScrollView *)self.superview;
52 | // 记录UIScrollView最开始的contentInset
53 | _scrollViewOriginalInset = scrollView.contentInset;
54 | }
55 |
56 |
57 | -(void)layoutSubviews{
58 |
59 | [super layoutSubviews];
60 |
61 | if(UIEdgeInsetsEqualToEdgeInsets(_scrollViewOriginalInset, UIEdgeInsetsZero) && !_isCalInset){
62 | _scrollViewOriginalInset = self.scrollView.contentInset;
63 | _isCalInset = YES;
64 | }
65 |
66 | }
67 |
68 |
69 |
70 | /**
71 | * 开始刷新
72 | */
73 | - (void)beginRefreshing{
74 |
75 | }
76 |
77 |
78 | /**
79 | * 结束刷新
80 | */
81 | - (void)endRefreshing{
82 |
83 |
84 | }
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 | @end
100 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/UIScrollView+MJExtension.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIScrollView+Extension.h
3 | // MJRefreshExample
4 | //
5 | // Created by MJ Lee on 14-5-28.
6 | // Copyright (c) 2014年 itcast. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIScrollView (MJExtension)
12 | @property (assign, nonatomic) CGFloat mj_contentInsetTop;
13 | @property (assign, nonatomic) CGFloat mj_contentInsetBottom;
14 | @property (assign, nonatomic) CGFloat mj_contentInsetLeft;
15 | @property (assign, nonatomic) CGFloat mj_contentInsetRight;
16 |
17 | @property (assign, nonatomic) CGFloat mj_contentOffsetX;
18 | @property (assign, nonatomic) CGFloat mj_contentOffsetY;
19 |
20 | @property (assign, nonatomic) CGFloat mj_contentSizeWidth;
21 | @property (assign, nonatomic) CGFloat mj_contentSizeHeight;
22 | @end
23 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/UIScrollView+MJExtension.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIScrollView+Extension.m
3 | // MJRefreshExample
4 | //
5 | // Created by MJ Lee on 14-5-28.
6 | // Copyright (c) 2014年 itcast. All rights reserved.
7 | //
8 |
9 | #import "UIScrollView+MJExtension.h"
10 |
11 | @implementation UIScrollView (MJExtension)
12 | - (void)setMj_contentInsetTop:(CGFloat)mj_contentInsetTop
13 | {
14 | UIEdgeInsets inset = self.contentInset;
15 | inset.top = mj_contentInsetTop;
16 | self.contentInset = inset;
17 | }
18 |
19 | - (CGFloat)mj_contentInsetTop
20 | {
21 | return self.contentInset.top;
22 | }
23 |
24 | - (void)setMj_contentInsetBottom:(CGFloat)mj_contentInsetBottom
25 | {
26 | UIEdgeInsets inset = self.contentInset;
27 | inset.bottom = mj_contentInsetBottom;
28 | self.contentInset = inset;
29 | }
30 |
31 | - (CGFloat)mj_contentInsetBottom
32 | {
33 | return self.contentInset.bottom;
34 | }
35 |
36 | - (void)setMj_contentInsetLeft:(CGFloat)mj_contentInsetLeft
37 | {
38 | UIEdgeInsets inset = self.contentInset;
39 | inset.left = mj_contentInsetLeft;
40 | self.contentInset = inset;
41 | }
42 |
43 | - (CGFloat)mj_contentInsetLeft
44 | {
45 | return self.contentInset.left;
46 | }
47 |
48 | - (void)setMj_contentInsetRight:(CGFloat)mj_contentInsetRight
49 | {
50 | UIEdgeInsets inset = self.contentInset;
51 | inset.right = mj_contentInsetRight;
52 | self.contentInset = inset;
53 | }
54 |
55 | - (CGFloat)mj_contentInsetRight
56 | {
57 | return self.contentInset.right;
58 | }
59 |
60 | - (void)setMj_contentOffsetX:(CGFloat)mj_contentOffsetX
61 | {
62 | CGPoint offset = self.contentOffset;
63 | offset.x = mj_contentOffsetX;
64 | self.contentOffset = offset;
65 | }
66 |
67 | - (CGFloat)mj_contentOffsetX
68 | {
69 | return self.contentOffset.x;
70 | }
71 |
72 | - (void)setMj_contentOffsetY:(CGFloat)mj_contentOffsetY
73 | {
74 | CGPoint offset = self.contentOffset;
75 | offset.y = mj_contentOffsetY;
76 | self.contentOffset = offset;
77 | }
78 |
79 | - (CGFloat)mj_contentOffsetY
80 | {
81 | return self.contentOffset.y;
82 | }
83 |
84 | - (void)setMj_contentSizeWidth:(CGFloat)mj_contentSizeWidth
85 | {
86 | CGSize size = self.contentSize;
87 | size.width = mj_contentSizeWidth;
88 | self.contentSize = size;
89 | }
90 |
91 | - (CGFloat)mj_contentSizeWidth
92 | {
93 | return self.contentSize.width;
94 | }
95 |
96 | - (void)setMj_contentSizeHeight:(CGFloat)mj_contentSizeHeight
97 | {
98 | CGSize size = self.contentSize;
99 | size.height = mj_contentSizeHeight;
100 | self.contentSize = size;
101 | }
102 |
103 | - (CGFloat)mj_contentSizeHeight
104 | {
105 | return self.contentSize.height;
106 | }
107 | @end
108 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/UIScrollView+Refresh.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIScrollView+Refresh.h
3 | // CoreRefresh
4 | //
5 | // Created by 沐汐 on 15-1-18.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 |
10 | #import
11 | #import "CoreFooterView.h"
12 | #import "CoreHeaderView.h"
13 |
14 | @interface UIScrollView (Refresh)
15 |
16 |
17 |
18 |
19 | /**
20 | * 添加一个下拉刷新头部控件
21 | *
22 | * @param target 目标
23 | * @param action 回调方法
24 | */
25 | - (void)addHeaderWithTarget:(id)target action:(SEL)action;
26 |
27 |
28 | /**
29 | * header的状态更新
30 | */
31 | -(void)headerSetState:(CoreHeaderViewRefreshState)state;
32 |
33 |
34 | /**
35 | * 移除下拉刷新头部控件
36 | */
37 | - (void)removeHeader;
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | /**
46 | * 添加一个上拉刷新尾部控件
47 | *
48 | * @param target 目标
49 | * @param action 回调方法
50 | */
51 | - (void)addFooterWithTarget:(id)target action:(SEL)action;
52 |
53 |
54 | /**
55 | * footer的状态更新
56 | */
57 | -(void)footerSetState:(CoreFooterViewRefreshState)state;
58 |
59 |
60 |
61 | /**
62 | * 移除上拉刷新尾部控件
63 | */
64 | - (void)removeFooter;
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/UIScrollView+Refresh.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIScrollView+Refresh.m
3 | // CoreRefresh
4 | //
5 | // Created by 沐汐 on 15-1-18.
6 | // Copyright (c) 2015年 沐汐. All rights reserved.
7 | //
8 |
9 | #import "UIScrollView+Refresh.h"
10 |
11 | #import
12 |
13 | @interface UIScrollView ()
14 |
15 | @property (weak, nonatomic) CoreHeaderView *header;
16 |
17 | @property (weak, nonatomic) CoreFooterView *footer;
18 |
19 | @end
20 |
21 | #pragma mark - 运行时相关
22 | static char CoreHeaderViewKey;
23 | static char CoreFooterViewKey;
24 |
25 | @implementation UIScrollView (Refresh)
26 |
27 |
28 |
29 |
30 | /**
31 | * 添加一个下拉刷新头部控件
32 | *
33 | * @param target 目标
34 | * @param action 回调方法
35 | */
36 | - (void)addHeaderWithTarget:(id)target action:(SEL)action{
37 | dispatch_async(dispatch_get_main_queue(), ^{
38 | // 1.创建新的header
39 | if (!self.header) {
40 | CoreHeaderView *header = [CoreHeaderView header];
41 | [self addSubview:header];
42 | self.header = header;
43 | }
44 |
45 | // 2.设置目标和回调方法
46 | self.header.beginRefreshingTaget = target;
47 | self.header.beginRefreshingAction = action;
48 | });
49 | }
50 |
51 | /**
52 | * header的状态更新
53 | */
54 | -(void)headerSetState:(CoreHeaderViewRefreshState)state{
55 | dispatch_async(dispatch_get_main_queue(), ^{
56 | self.header.state=state;
57 | });
58 |
59 | }
60 |
61 |
62 | /**
63 | * 移除下拉刷新头部控件
64 | */
65 | - (void)removeHeader{
66 | dispatch_async(dispatch_get_main_queue(), ^{
67 | [self.header removeHeader];
68 | });
69 |
70 | self.header = nil;
71 | }
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | /**
82 | * 添加一个上拉刷新尾部控件
83 | *
84 | * @param target 目标
85 | * @param action 回调方法
86 | */
87 | - (void)addFooterWithTarget:(id)target action:(SEL)action
88 | {
89 | dispatch_async(dispatch_get_main_queue(), ^{
90 | // 1.创建新的footer
91 | if (!self.footer) {
92 | CoreFooterView *footer = [CoreFooterView footer];
93 | [self addSubview:footer];
94 | self.footer = footer;
95 | }
96 |
97 | // 2.设置目标和回调方法
98 | self.footer.beginRefreshingTaget = target;
99 | self.footer.beginRefreshingAction = action;
100 | });
101 | }
102 |
103 |
104 | /**
105 | * footer的状态更新
106 | */
107 | -(void)footerSetState:(CoreFooterViewRefreshState)state{
108 | dispatch_async(dispatch_get_main_queue(), ^{
109 | self.footer.state=state;
110 | });
111 |
112 | }
113 |
114 |
115 |
116 | /**
117 | * 移除上拉刷新尾部控件
118 | */
119 | - (void)removeFooter
120 | {
121 | dispatch_async(dispatch_get_main_queue(), ^{
122 | [self.footer removeFooter];
123 | self.footer = nil;
124 | });
125 | }
126 |
127 |
128 |
129 |
130 |
131 |
132 | #pragma mark 使用运行时模拟成员变量:header
133 | - (void)setHeader:(CoreHeaderView *)header {
134 | [self willChangeValueForKey:@"CoreHeaderViewKey"];
135 | objc_setAssociatedObject(self, &CoreHeaderViewKey,
136 | header,
137 | OBJC_ASSOCIATION_ASSIGN);
138 | [self didChangeValueForKey:@"CoreHeaderViewKey"];
139 | }
140 |
141 | - (CoreHeaderView *)header {
142 | return objc_getAssociatedObject(self, &CoreHeaderViewKey);
143 | }
144 |
145 |
146 |
147 | #pragma mark 使用运行时模拟成员变量:footer
148 | - (void)setFooter:(CoreFooterView *)footer {
149 | [self willChangeValueForKey:@"CoreFooterViewKey"];
150 | objc_setAssociatedObject(self, &CoreFooterViewKey,
151 | footer,
152 | OBJC_ASSOCIATION_ASSIGN);
153 | [self didChangeValueForKey:@"CoreFooterViewKey"];
154 | }
155 |
156 | - (CoreFooterView *)footer {
157 | return objc_getAssociatedObject(self, &CoreFooterViewKey);
158 | }
159 |
160 |
161 | @end
162 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/UIView+MJExtension.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+Extension.h
3 | // MJRefreshExample
4 | //
5 | // Created by MJ Lee on 14-5-28.
6 | // Copyright (c) 2014年 itcast. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIView (MJExtension)
12 | @property (assign, nonatomic) CGFloat mj_x;
13 | @property (assign, nonatomic) CGFloat mj_y;
14 | @property (assign, nonatomic) CGFloat mj_width;
15 | @property (assign, nonatomic) CGFloat mj_height;
16 | @property (assign, nonatomic) CGSize mj_size;
17 | @property (assign, nonatomic) CGPoint mj_origin;
18 | @end
19 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreRefresh/UIView+MJExtension.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+Extension.m
3 | // MJRefreshExample
4 | //
5 | // Created by MJ Lee on 14-5-28.
6 | // Copyright (c) 2014年 itcast. All rights reserved.
7 | //
8 |
9 | #import "UIView+MJExtension.h"
10 |
11 | @implementation UIView (MJExtension)
12 | - (void)setMj_x:(CGFloat)mj_x
13 | {
14 | CGRect frame = self.frame;
15 | frame.origin.x = mj_x;
16 | self.frame = frame;
17 | }
18 |
19 | - (CGFloat)mj_x
20 | {
21 | return self.frame.origin.x;
22 | }
23 |
24 | - (void)setMj_y:(CGFloat)mj_y
25 | {
26 | CGRect frame = self.frame;
27 | frame.origin.y = mj_y;
28 | self.frame = frame;
29 | }
30 |
31 | - (CGFloat)mj_y
32 | {
33 | return self.frame.origin.y;
34 | }
35 |
36 | - (void)setMj_width:(CGFloat)mj_width
37 | {
38 | CGRect frame = self.frame;
39 | frame.size.width = mj_width;
40 | self.frame = frame;
41 | }
42 |
43 | - (CGFloat)mj_width
44 | {
45 | return self.frame.size.width;
46 | }
47 |
48 | - (void)setMj_height:(CGFloat)mj_height
49 | {
50 | CGRect frame = self.frame;
51 | frame.size.height = mj_height;
52 | self.frame = frame;
53 | }
54 |
55 | - (CGFloat)mj_height
56 | {
57 | return self.frame.size.height;
58 | }
59 |
60 | - (void)setMj_size:(CGSize)mj_size
61 | {
62 | CGRect frame = self.frame;
63 | frame.size = mj_size;
64 | self.frame = frame;
65 | }
66 |
67 | - (CGSize)mj_size
68 | {
69 | return self.frame.size;
70 | }
71 |
72 | - (void)setMj_origin:(CGPoint)mj_origin
73 | {
74 | CGRect frame = self.frame;
75 | frame.origin = mj_origin;
76 | self.frame = frame;
77 | }
78 |
79 | - (CGPoint)mj_origin
80 | {
81 | return self.frame.origin;
82 | }
83 | @end
84 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreStatus/CoreStatus.h:
--------------------------------------------------------------------------------
1 | //
2 | // ToolStatus.h
3 | // 网络
4 | //
5 | // Created by muxi on 14-10-11.
6 | // Copyright (c) 2014年 沐汐. All rights reserved.
7 | //
8 | //
9 |
10 |
11 | #import
12 | #import "Reachability.h"
13 |
14 | @interface CoreStatus : NSObject
15 |
16 | /**
17 | * 获取当前网络状态
18 | */
19 | +(NetworkStatus)status;
20 |
21 |
22 |
23 | /**
24 | * 是否处于WIFI环境中:
25 | */
26 | +(BOOL)isWIFIEnable;
27 |
28 | /**
29 | * 是否有网络数据连接:含2G/3G/WIFI
30 | */
31 | +(BOOL)isNETWORKEnable;
32 |
33 |
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreStatus/CoreStatus.m:
--------------------------------------------------------------------------------
1 | //
2 | // ToolStatus.m
3 | // 网络
4 | //
5 | // Created by muxi on 14-10-11.
6 | // Copyright (c) 2014年 沐汐. All rights reserved.
7 | //
8 |
9 | #import "CoreStatus.h"
10 |
11 | @implementation CoreStatus
12 |
13 |
14 |
15 |
16 | /**
17 | * 获取当前网络状态
18 | */
19 | +(NetworkStatus)status{
20 | return [[Reachability reachabilityForInternetConnection] currentReachabilityStatus];
21 | }
22 |
23 |
24 |
25 | /**
26 | * 是否处于WIFI环境中:
27 | */
28 | +(BOOL)isWIFIEnable{
29 | return [self status]==ReachableViaWiFi;
30 | }
31 |
32 |
33 |
34 | /**
35 | * 是否有网络数据连接:含2G/3G/WIFI
36 | */
37 | +(BOOL)isNETWORKEnable{
38 | return [self status] != NotReachable;
39 | }
40 |
41 |
42 |
43 |
44 |
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreStatus/Reachability/Reachability.h:
--------------------------------------------------------------------------------
1 | /*
2 | File: Reachability.h
3 | Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
4 | Version: 3.5
5 |
6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
7 | Inc. ("Apple") in consideration of your agreement to the following
8 | terms, and your use, installation, modification or redistribution of
9 | this Apple software constitutes acceptance of these terms. If you do
10 | not agree with these terms, please do not use, install, modify or
11 | redistribute this Apple software.
12 |
13 | In consideration of your agreement to abide by the following terms, and
14 | subject to these terms, Apple grants you a personal, non-exclusive
15 | license, under Apple's copyrights in this original Apple software (the
16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple
17 | Software, with or without modifications, in source and/or binary forms;
18 | provided that if you redistribute the Apple Software in its entirety and
19 | without modifications, you must retain this notice and the following
20 | text and disclaimers in all such redistributions of the Apple Software.
21 | Neither the name, trademarks, service marks or logos of Apple Inc. may
22 | be used to endorse or promote products derived from the Apple Software
23 | without specific prior written permission from Apple. Except as
24 | expressly stated in this notice, no other rights or licenses, express or
25 | implied, are granted by Apple herein, including but not limited to any
26 | patent rights that may be infringed by your derivative works or by other
27 | works in which the Apple Software may be incorporated.
28 |
29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE
30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
34 |
35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
42 | POSSIBILITY OF SUCH DAMAGE.
43 |
44 | Copyright (C) 2014 Apple Inc. All Rights Reserved.
45 |
46 | */
47 |
48 | #import
49 | #import
50 | #import
51 |
52 |
53 | typedef enum : NSInteger {
54 | NotReachable = 0,
55 | ReachableViaWiFi,
56 | ReachableViaWWAN
57 | } NetworkStatus;
58 |
59 |
60 | extern NSString *kReachabilityChangedNotification;
61 |
62 |
63 | @interface Reachability : NSObject
64 |
65 | /*!
66 | * Use to check the reachability of a given host name.
67 | */
68 | + (instancetype)reachabilityWithHostName:(NSString *)hostName;
69 |
70 | /*!
71 | * Use to check the reachability of a given IP address.
72 | */
73 | + (instancetype)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress;
74 |
75 | /*!
76 | * Checks whether the default route is available. Should be used by applications that do not connect to a particular host.
77 | */
78 | + (instancetype)reachabilityForInternetConnection;
79 |
80 | /*!
81 | * Checks whether a local WiFi connection is available.
82 | */
83 | + (instancetype)reachabilityForLocalWiFi;
84 |
85 | /*!
86 | * Start listening for reachability notifications on the current run loop.
87 | */
88 | - (BOOL)startNotifier;
89 | - (void)stopNotifier;
90 |
91 | - (NetworkStatus)currentReachabilityStatus;
92 |
93 | /*!
94 | * WWAN may be available, but not active until a connection has been established. WiFi may require a connection for VPN on Demand.
95 | */
96 | - (BOOL)connectionRequired;
97 |
98 | @end
99 |
100 |
101 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreViewNetWorkStausManager/CoreViewNetWorkStausManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // CoreViewNetWorkStausManager.h
3 | // CoreViewNetWorkStausManager
4 | //
5 | // Created by muxi on 15/3/12.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | typedef enum{
13 |
14 | //加载中有图片
15 | CMTypeLoadingWithImage=0,
16 |
17 | //加载中无图片
18 | CMTypeLoadingWithoutImage,
19 |
20 | //文字模式,强制显示图片,没有indicator控件
21 | CMTypeNormalMsgWithImage,
22 |
23 | //错误模式:此模型下block才会生效,其他模式下block均被忽略
24 | CMTypeError,
25 |
26 | }CMType;
27 |
28 |
29 |
30 | @interface CoreViewNetWorkStausManager : NSObject
31 |
32 |
33 |
34 |
35 | +(void)show:(UIView *)view type:(CMType)type msg:(NSString *)msg subMsg:(NSString *)subMsg offsetY:(CGFloat)offsetY failClickBlock:(void(^)())failClickBlock;
36 |
37 |
38 | +(void)dismiss:(UIView *)view;
39 |
40 |
41 | @end
42 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreViewNetWorkStausManager/CoreViewNetWorkStausManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // CoreViewNetWorkStausManager.m
3 | // CoreViewNetWorkStausManager
4 | //
5 | // Created by muxi on 15/3/12.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "CoreViewNetWorkStausManager.h"
10 | #import "CMView.h"
11 |
12 | @implementation CoreViewNetWorkStausManager
13 |
14 |
15 | +(void)show:(UIView *)view type:(CMType)type msg:(NSString *)msg subMsg:(NSString *)subMsg offsetY:(CGFloat)offsetY failClickBlock:(void(^)())failClickBlock{
16 |
17 | //先移除一次
18 | [self dismiss:view];
19 |
20 | dispatch_async(dispatch_get_main_queue(), ^{
21 |
22 | //创建CMView
23 | CMView *myCmView=[CMView cmViewWithType:type msg:msg subMsg:subMsg offsetY:offsetY failClickBlock:failClickBlock];
24 |
25 | [view addSubview:myCmView];
26 |
27 | myCmView.alpha=0;
28 | [UIView animateWithDuration:.25f animations:^{
29 | myCmView.alpha=1.0f;
30 | }];
31 | });
32 |
33 | }
34 |
35 |
36 |
37 | +(void)dismiss:(UIView *)view{
38 |
39 | NSArray *subViews=view.subviews;
40 |
41 | if(subViews==nil || subViews.count==0) return;
42 |
43 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
44 | //遍历
45 | for (UIView *subView in subViews) {
46 |
47 | if(![subView isKindOfClass:[CMView class]]) continue;
48 |
49 | dispatch_async(dispatch_get_main_queue(), ^{
50 |
51 | [subView removeFromSuperview];
52 | });
53 | }
54 | });
55 | }
56 |
57 |
58 | @end
59 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreViewNetWorkStausManager/Lib/CM.bundle/CMIcon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CorePagesView/905caceaf4b2d8ede868bb8c231f38daf802066b/CorePagesView/Frameworks/CoreViewNetWorkStausManager/Lib/CM.bundle/CMIcon@2x.png
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreViewNetWorkStausManager/Lib/CMView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CMView.h
3 | // CoreViewNetWorkStausManager
4 | //
5 | // Created by muxi on 15/3/12.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "CoreViewNetWorkStausManager.h"
11 |
12 | @interface CMView : UIView
13 |
14 |
15 |
16 | +(instancetype)cmViewWithType:(CMType)type msg:(NSString *)msg subMsg:(NSString *)subMsg offsetY:(CGFloat)offsetY failClickBlock:(void(^)())failClickBlock;
17 |
18 |
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreViewNetWorkStausManager/Lib/CMView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CMView.m
3 | // CoreViewNetWorkStausManager
4 | //
5 | // Created by muxi on 15/3/12.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "CMView.h"
10 |
11 |
12 | @interface CMView ()
13 |
14 | /**
15 | * 控件
16 | */
17 | @property (strong, nonatomic) IBOutlet UIImageView *imageView;
18 |
19 | @property (strong, nonatomic) IBOutlet UIActivityIndicatorView *idv;
20 |
21 | @property (strong, nonatomic) IBOutlet UILabel *msgLabel;
22 |
23 | @property (strong, nonatomic) IBOutlet UILabel *subMsgLabel;
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | /**
33 | * 值
34 | */
35 | @property (nonatomic,assign) CMType type;
36 |
37 | @property (nonatomic,copy) NSString *msg;
38 |
39 | @property (nonatomic,copy) NSString *subMsg;
40 |
41 | @property (nonatomic,assign) CGFloat offsetY;
42 |
43 |
44 |
45 | /**
46 | * 约束
47 | */
48 | @property (strong, nonatomic) IBOutlet NSLayoutConstraint *msgLabelMarginConstraint;
49 |
50 | @property (strong, nonatomic) IBOutlet NSLayoutConstraint *idvMarginConstraint;
51 |
52 | @property (strong, nonatomic) IBOutlet NSLayoutConstraint *subMsgMarginConstraint;
53 |
54 | @property (nonatomic,copy) void (^failClickBlock)();
55 |
56 | @end
57 |
58 |
59 |
60 |
61 | @implementation CMView
62 |
63 | +(instancetype)cmViewWithType:(CMType)type msg:(NSString *)msg subMsg:(NSString *)subMsg offsetY:(CGFloat)offsetY failClickBlock:(void(^)())failClickBlock{
64 |
65 | CMView * cmView = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] firstObject];
66 |
67 | cmView.type=type;
68 |
69 | cmView.msg=msg;
70 |
71 | cmView.subMsg=subMsg;
72 |
73 | cmView.offsetY=offsetY;
74 |
75 | if(CMTypeError == type) cmView.failClickBlock=failClickBlock;
76 |
77 | return cmView;
78 | }
79 |
80 |
81 |
82 | /**
83 | * set方法修理布局
84 | */
85 | -(void)setType:(CMType)type{
86 |
87 | if(_type == type) return;
88 |
89 | _type=type;
90 |
91 | if(CMTypeLoadingWithoutImage == type){//不显示图片
92 |
93 | //移除视图控件
94 | [_imageView removeFromSuperview];
95 |
96 | _idvMarginConstraint.constant=20;
97 |
98 | }
99 |
100 | _idv.hidden=(CMTypeNormalMsgWithImage == type || CMTypeError == type);
101 | }
102 |
103 |
104 | -(void)setMsg:(NSString *)msg{
105 |
106 | if(msg==nil){
107 | [_msgLabel removeFromSuperview];
108 | _subMsgMarginConstraint.constant=-20;
109 | return;
110 | }
111 |
112 | _msg=msg;
113 |
114 | _msgLabel.text=msg;
115 | }
116 |
117 |
118 | -(void)setSubMsg:(NSString *)subMsg{
119 |
120 | if(subMsg==nil){
121 | [_subMsgLabel removeFromSuperview];
122 |
123 | if(CMTypeLoadingWithImage == _type){
124 | _idvMarginConstraint.constant=-56;
125 | }
126 |
127 | return;
128 | }
129 |
130 | _subMsg=subMsg;
131 |
132 | _subMsgLabel.text=subMsg;
133 | }
134 |
135 |
136 |
137 | /**
138 | * 处理布局
139 | */
140 | -(void)didMoveToSuperview{
141 |
142 | [super didMoveToSuperview];
143 |
144 | UIView *superView=self.superview;
145 |
146 | if(superView==nil) return;
147 |
148 | UIView *selfView=self;
149 |
150 | self.translatesAutoresizingMaskIntoConstraints=NO;
151 |
152 | NSDictionary *views=NSDictionaryOfVariableBindings(selfView);
153 |
154 | NSString *vfl_H=@"";
155 | NSString *vfl_V=@"";
156 | NSDictionary *metrics=nil;
157 |
158 |
159 | if([superView isKindOfClass:[UIScrollView class]]){
160 |
161 | UIScrollView *scrollView=(UIScrollView *)superView;
162 |
163 | CGSize contentSize=scrollView.contentSize;
164 |
165 | BOOL hasContentSize=(CGSizeEqualToSize(contentSize, CGSizeZero));
166 |
167 | CGSize size=CGSizeZero;
168 | if(hasContentSize){
169 | size=scrollView.contentSize;
170 | }else{
171 | size=scrollView.frame.size;
172 | }
173 |
174 | metrics=@{@"w":@(size.width),@"h":@(size.height),@"y":@(_offsetY)};
175 | vfl_H=@"H:|-0-[selfView(==w)]-0-|";
176 | vfl_V=@"V:|-y-[selfView(==h)]-0-|";
177 |
178 | }else{
179 |
180 | metrics=@{@"y":@(_offsetY)};
181 |
182 | vfl_H=@"H:|-0-[selfView]-0-|";
183 | vfl_V=@"V:|-y-[selfView]-0-|";
184 | }
185 |
186 | [superView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:vfl_H options:0 metrics:metrics views:views]];
187 | [superView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:vfl_V options:0 metrics:metrics views:views]];
188 | }
189 |
190 |
191 | - (IBAction)btnClick:(id)sender {
192 |
193 | if(CMTypeError == _type && _failClickBlock!=nil) _failClickBlock();
194 | }
195 |
196 |
197 |
198 |
199 | @end
200 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/CoreViewNetWorkStausManager/Lib/CMView.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
30 |
36 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/MJExtension/MJConst.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef __MJConst__H__
3 | #define __MJConst__H__
4 |
5 | #import
6 |
7 | // 过期
8 | #define MJDeprecated(instead) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, instead)
9 |
10 | #ifdef DEBUG // 调试状态
11 | // 打开LOG功能
12 | #define MJLog(...) NSLog(__VA_ARGS__)
13 | #else // 发布状态
14 | // 关闭LOG功能
15 | #define MJLog(...)
16 | #endif
17 |
18 | // 构建错误
19 | #define MJBuildError(error, msg) \
20 | if (error) *error = [NSError errorWithDomain:msg code:250 userInfo:nil];
21 |
22 | /**
23 | * 断言
24 | * @param condition 条件
25 | * @param returnValue 返回值
26 | */
27 | #define MJAssertError(condition, returnValue, error, msg) \
28 | if ((condition) == NO) { \
29 | MJBuildError(error, msg); \
30 | return returnValue;\
31 | }
32 |
33 | #define MJAssert2(condition, returnValue) \
34 | if ((condition) == NO) return returnValue;
35 |
36 | /**
37 | * 断言
38 | * @param condition 条件
39 | */
40 | #define MJAssert(condition) MJAssert2(condition, )
41 |
42 | /**
43 | * 断言
44 | * @param param 参数
45 | * @param returnValue 返回值
46 | */
47 | #define MJAssertParamNotNil2(param, returnValue) \
48 | MJAssert2((param) != nil, returnValue)
49 |
50 | /**
51 | * 断言
52 | * @param param 参数
53 | */
54 | #define MJAssertParamNotNil(param) MJAssertParamNotNil2(param, )
55 |
56 | /**
57 | * 打印所有的属性
58 | */
59 | #define MJLogAllIvars \
60 | -(NSString *)description \
61 | { \
62 | return [self keyValues].description; \
63 | }
64 |
65 | /**
66 | * 类型(属性类型)
67 | */
68 | extern NSString *const MJTypeInt;
69 | extern NSString *const MJTypeFloat;
70 | extern NSString *const MJTypeDouble;
71 | extern NSString *const MJTypeLong;
72 | extern NSString *const MJTypeLongLong;
73 | extern NSString *const MJTypeChar;
74 | extern NSString *const MJTypeBOOL;
75 | extern NSString *const MJTypePointer;
76 |
77 | extern NSString *const MJTypeIvar;
78 | extern NSString *const MJTypeMethod;
79 | extern NSString *const MJTypeBlock;
80 | extern NSString *const MJTypeClass;
81 | extern NSString *const MJTypeSEL;
82 | extern NSString *const MJTypeId;
83 |
84 | #endif
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/MJExtension/MJConst.m:
--------------------------------------------------------------------------------
1 | #ifndef __MJConst__M__
2 | #define __MJConst__M__
3 |
4 | #import
5 |
6 | /**
7 | * 成员变量类型(属性类型)
8 | */
9 | NSString *const MJTypeInt = @"i";
10 | NSString *const MJTypeFloat = @"f";
11 | NSString *const MJTypeDouble = @"d";
12 | NSString *const MJTypeLong = @"q";
13 | NSString *const MJTypeLongLong = @"q";
14 | NSString *const MJTypeChar = @"c";
15 | NSString *const MJTypeBOOL = @"c";
16 | NSString *const MJTypePointer = @"*";
17 |
18 | NSString *const MJTypeIvar = @"^{objc_ivar=}";
19 | NSString *const MJTypeMethod = @"^{objc_method=}";
20 | NSString *const MJTypeBlock = @"@?";
21 | NSString *const MJTypeClass = @"#";
22 | NSString *const MJTypeSEL = @":";
23 | NSString *const MJTypeId = @"@";
24 |
25 | #endif
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/MJExtension/MJExtension.h:
--------------------------------------------------------------------------------
1 | //
2 | // MJExtension.h
3 | // MJExtension
4 | //
5 | // Created by mj on 14-1-15.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | // 代码地址:https://github.com/CoderMJLee/MJExtension
8 | // 代码地址:http://code4app.com/ios/%E5%AD%97%E5%85%B8-JSON-%E4%B8%8E%E6%A8%A1%E5%9E%8B%E7%9A%84%E8%BD%AC%E6%8D%A2/5339992a933bf062608b4c57
9 |
10 | #import "NSObject+MJCoding.h"
11 | #import "NSObject+MJProperty.h"
12 | #import "NSObject+MJKeyValue.h"
13 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/MJExtension/MJFoundation.h:
--------------------------------------------------------------------------------
1 | //
2 | // MJFoundation.h
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 14/7/16.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MJFoundation : NSObject
12 | + (BOOL)isClassFromFoundation:(Class)c;
13 | @end
14 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/MJExtension/MJFoundation.m:
--------------------------------------------------------------------------------
1 | //
2 | // MJFoundation.m
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 14/7/16.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | //
8 |
9 | #import "MJFoundation.h"
10 | #import "MJConst.h"
11 | #import
12 |
13 | static NSSet *_foundationClasses;
14 |
15 | @implementation MJFoundation
16 |
17 | + (void)load
18 | {
19 | _foundationClasses = [NSSet setWithObjects:
20 | [NSObject class],
21 | [NSURL class],
22 | [NSDate class],
23 | [NSNumber class],
24 | [NSDecimalNumber class],
25 | [NSData class],
26 | [NSMutableData class],
27 | [NSArray class],
28 | [NSMutableArray class],
29 | [NSDictionary class],
30 | [NSMutableDictionary class],
31 | [NSManagedObject class],
32 | [NSString class],
33 | [NSMutableString class], nil];
34 | }
35 |
36 | + (BOOL)isClassFromFoundation:(Class)c
37 | {
38 | return [_foundationClasses containsObject:c];
39 | }
40 | @end
41 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/MJExtension/MJProperty.h:
--------------------------------------------------------------------------------
1 | //
2 | // MJProperty.h
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/4/17.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | // 包装一个成员属性
8 |
9 | #import
10 | #import
11 | @class MJType;
12 |
13 | /**
14 | * 包装一个成员
15 | */
16 | @interface MJProperty : NSObject
17 | /** 成员属性 */
18 | @property (nonatomic, assign) objc_property_t property;
19 | /** 成员属性名 */
20 | @property (nonatomic, readonly) NSString *name;
21 |
22 | /** 成员变量的类型 */
23 | @property (nonatomic, readonly) MJType *type;
24 | /** 成员来源于哪个类(可能是父类) */
25 | @property (nonatomic, assign) Class srcClass;
26 |
27 | /**** 同一个成员变量 - 父类和子类的行为可能不一致(key、keys、objectClassInArray) ****/
28 | /** 对应着字典中的key */
29 | - (void)setKey:(NSString *)key forClass:(Class)c;
30 | - (NSString *)keyFromClass:(Class)c;
31 |
32 | /** 对应着字典中的多级key */
33 | - (NSArray *)keysFromClass:(Class)c;
34 |
35 | /** 模型数组中的模型类型 */
36 | - (void)setObjectClassInArray:(Class)objectClass forClass:(Class)c;
37 | - (Class)objectClassInArrayFromClass:(Class)c;
38 | /**** 同一个成员变量 - 父类和子类的行为可能不一致(key、keys、objectClassInArray) ****/
39 |
40 | /**
41 | * 设置成员变量的值
42 | */
43 | - (void)setValue:(id)value forObject:(id)object;
44 | /**
45 | * 得到成员变量的值
46 | */
47 | - (id)valueFromObject:(id)object;
48 |
49 | /**
50 | * 初始化
51 | */
52 | + (instancetype)cachedPropertyWithProperty:(objc_property_t)property;
53 | @end
54 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/MJExtension/MJProperty.m:
--------------------------------------------------------------------------------
1 | //
2 | // MJProperty.m
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/4/17.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | //
8 |
9 | #import "MJProperty.h"
10 | #import "MJType.h"
11 | #import "MJFoundation.h"
12 | #import "MJConst.h"
13 |
14 | @interface MJProperty()
15 | @property (strong, nonatomic) NSMutableDictionary *keyDict;
16 | @property (strong, nonatomic) NSMutableDictionary *keysDict;
17 | @property (strong, nonatomic) NSMutableDictionary *objectClassInArrayDict;
18 | @end
19 |
20 | @implementation MJProperty
21 |
22 | - (NSMutableDictionary *)keyDict
23 | {
24 | if (!_keyDict) {
25 | self.keyDict = [NSMutableDictionary dictionary];
26 | }
27 | return _keyDict;
28 | }
29 |
30 | - (NSMutableDictionary *)keysDict
31 | {
32 | if (!_keysDict) {
33 | self.keysDict = [NSMutableDictionary dictionary];
34 | }
35 | return _keysDict;
36 | }
37 |
38 | - (NSMutableDictionary *)objectClassInArrayDict
39 | {
40 | if (!_objectClassInArrayDict) {
41 | self.objectClassInArrayDict = [NSMutableDictionary dictionary];
42 | }
43 | return _objectClassInArrayDict;
44 | }
45 |
46 | + (instancetype)cachedPropertyWithProperty:(objc_property_t)property
47 | {
48 | MJProperty *propertyObj = objc_getAssociatedObject(self, property);
49 | if (propertyObj == nil) {
50 | propertyObj = [[self alloc] init];
51 | propertyObj.property = property;
52 | objc_setAssociatedObject(self, property, propertyObj, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
53 | }
54 | return propertyObj;
55 | }
56 |
57 | - (void)setProperty:(objc_property_t)property
58 | {
59 | _property = property;
60 |
61 | MJAssertParamNotNil(property);
62 |
63 | // 1.属性名
64 | _name = @(property_getName(property));
65 |
66 | // 2.成员类型
67 | NSString *attrs = @(property_getAttributes(property));
68 | NSUInteger loc = 1;
69 | NSUInteger len = [attrs rangeOfString:@","].location - loc;
70 | _type = [MJType cachedTypeWithCode:[attrs substringWithRange:NSMakeRange(loc, len)]];
71 | }
72 |
73 | /**
74 | * 获得成员变量的值
75 | */
76 | - (id)valueFromObject:(id)object
77 | {
78 | if (_type.KVCDisabled) return [NSNull null];
79 | return [object valueForKey:_name];
80 | }
81 |
82 | /**
83 | * 设置成员变量的值
84 | */
85 | - (void)setValue:(id)value forObject:(id)object
86 | {
87 | if (_type.KVCDisabled || value == nil) return;
88 | [object setValue:value forKey:_name];
89 | }
90 |
91 | /** 对应着字典中的key */
92 | - (void)setKey:(NSString *)key forClass:(Class)c
93 | {
94 | if (!key) return;
95 | self.keyDict[NSStringFromClass(c)] = key;
96 | // 如果有多级映射
97 | [self setKeys:[key componentsSeparatedByString:@"."] forClass:c];
98 | }
99 | - (NSString *)keyFromClass:(Class)c
100 | {
101 | return self.keyDict[NSStringFromClass(c)];
102 | }
103 |
104 | /** 对应着字典中的多级key */
105 | - (void)setKeys:(NSArray *)keys forClass:(Class)c
106 | {
107 | if (!keys) return;
108 | self.keysDict[NSStringFromClass(c)] = keys;
109 | }
110 | - (NSArray *)keysFromClass:(Class)c
111 | {
112 | return self.keysDict[NSStringFromClass(c)];
113 | }
114 |
115 | /** 模型数组中的模型类型 */
116 | - (void)setObjectClassInArray:(Class)objectClass forClass:(Class)c
117 | {
118 | if (!objectClass) return;
119 | self.objectClassInArrayDict[NSStringFromClass(c)] = objectClass;
120 | }
121 | - (Class)objectClassInArrayFromClass:(Class)c
122 | {
123 | return self.objectClassInArrayDict[NSStringFromClass(c)];
124 | }
125 | @end
126 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/MJExtension/MJType.h:
--------------------------------------------------------------------------------
1 | //
2 | // MJType.h
3 | // MJExtension
4 | //
5 | // Created by mj on 14-1-15.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | // 包装一种类型
8 |
9 | #import
10 | /**
11 | * 包装一种类型
12 | */
13 | @interface MJType : NSObject
14 | /** 类型标识符 */
15 | @property (nonatomic, copy) NSString *code;
16 |
17 | /** 是否为id类型 */
18 | @property (nonatomic, readonly, getter=isIdType) BOOL idType;
19 |
20 | /** 是否为基本数字类型:int、float等 */
21 | @property (nonatomic, readonly, getter=isNumberType) BOOL numberType;
22 |
23 | /** 对象类型(如果是基本数据类型,此值为nil) */
24 | @property (nonatomic, readonly) Class typeClass;
25 |
26 | /** 类型是否来自于Foundation框架,比如NSString、NSArray */
27 | @property (nonatomic, readonly, getter = isFromFoundation) BOOL fromFoundation;
28 | /** 类型是否不支持KVC */
29 | @property (nonatomic, readonly, getter = isKVCDisabled) BOOL KVCDisabled;
30 |
31 | /**
32 | * 获得缓存的类型对象
33 | */
34 | + (instancetype)cachedTypeWithCode:(NSString *)code;
35 | @end
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/MJExtension/MJType.m:
--------------------------------------------------------------------------------
1 | //
2 | // MJType.m
3 | // MJExtension
4 | //
5 | // Created by mj on 14-1-15.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | //
8 |
9 | #import "MJType.h"
10 | #import "MJExtension.h"
11 | #import "MJFoundation.h"
12 | #import "MJConst.h"
13 |
14 | @implementation MJType
15 |
16 | static NSMutableDictionary *_cachedTypes;
17 | + (void)load
18 | {
19 | _cachedTypes = [NSMutableDictionary dictionary];
20 | }
21 |
22 | + (instancetype)cachedTypeWithCode:(NSString *)code
23 | {
24 | MJAssertParamNotNil2(code, nil);
25 |
26 | MJType *type = _cachedTypes[code];
27 | if (type == nil) {
28 | type = [[self alloc] init];
29 | type.code = code;
30 | _cachedTypes[code] = type;
31 | }
32 | return type;
33 | }
34 |
35 | - (void)setCode:(NSString *)code
36 | {
37 | _code = code;
38 |
39 | MJAssertParamNotNil(code);
40 |
41 | if ([code isEqualToString:MJTypeId]) {
42 | _idType = YES;
43 | } else if (code.length == 0) {
44 | _KVCDisabled = YES;
45 | } else if (code.length > 3 && [code hasPrefix:@"@\""]) {
46 | // 去掉@"和",截取中间的类型名称
47 | _code = [code substringWithRange:NSMakeRange(2, code.length - 3)];
48 | _typeClass = NSClassFromString(_code);
49 | _fromFoundation = [MJFoundation isClassFromFoundation:_typeClass];
50 | _numberType = (_typeClass == [NSNumber class] || [_typeClass isSubclassOfClass:[NSNumber class]]);
51 | } else if ([code isEqualToString:MJTypeSEL] ||
52 | [code isEqualToString:MJTypeIvar] ||
53 | [code isEqualToString:MJTypeMethod]) {
54 | _KVCDisabled = YES;
55 | }
56 |
57 | // 是否为数字类型
58 | NSString *lowerCode = _code.lowercaseString;
59 | NSArray *numberTypes = @[MJTypeInt, MJTypeFloat, MJTypeDouble, MJTypeLong, MJTypeChar];
60 | if ([numberTypes containsObject:lowerCode]) {
61 | _numberType = YES;
62 | }
63 | }
64 | @end
65 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/MJExtension/NSObject+MJCoding.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+MJCoding.h
3 | // MJExtension
4 | //
5 | // Created by mj on 14-1-15.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | //
8 |
9 | #import
10 | /**
11 | * Codeing协议
12 | */
13 | @protocol MJCoding
14 | @optional
15 | /**
16 | * 这个数组中的属性名才会进行归档
17 | */
18 | + (NSArray *)allowedCodingPropertyNames;
19 | /**
20 | * 这个数组中的属性名将会被忽略:不进行归档
21 | */
22 | + (NSArray *)ignoredCodingPropertyNames;
23 | @end
24 |
25 | @interface NSObject (MJCoding)
26 | /**
27 | * 解码(从文件中解析对象)
28 | */
29 | - (void)decode:(NSCoder *)decoder;
30 | /**
31 | * 编码(将对象写入文件中)
32 | */
33 | - (void)encode:(NSCoder *)encoder;
34 | @end
35 |
36 | /**
37 | 归档的实现
38 | */
39 | #define MJCodingImplementation \
40 | - (id)initWithCoder:(NSCoder *)decoder \
41 | { \
42 | if (self = [super init]) { \
43 | [self decode:decoder]; \
44 | } \
45 | return self; \
46 | } \
47 | \
48 | - (void)encodeWithCoder:(NSCoder *)encoder \
49 | { \
50 | [self encode:encoder]; \
51 | }
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/MJExtension/NSObject+MJCoding.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+MJCoding.m
3 | // MJExtension
4 | //
5 | // Created by mj on 14-1-15.
6 | // Copyright (c) 2014年 小码哥. All rights reserved.
7 | //
8 |
9 | #import "NSObject+MJCoding.h"
10 | #import "NSObject+MJProperty.h"
11 | #import "MJProperty.h"
12 |
13 | @implementation NSObject (MJCoding)
14 |
15 | - (void)encode:(NSCoder *)encoder
16 | {
17 | Class class = [self class];
18 |
19 | NSArray *allowedCodingPropertyNames = [class totalAllowedCodingPropertyNames];
20 | NSArray *ignoredCodingPropertyNames = [class totalIgnoredCodingPropertyNames];
21 |
22 | [class enumeratePropertiesWithBlock:^(MJProperty *property, BOOL *stop) {
23 | if (allowedCodingPropertyNames.count && ![allowedCodingPropertyNames containsObject:property.name]) return;
24 | // 检测是否被忽略
25 | if ([ignoredCodingPropertyNames containsObject:property.name]) return;
26 |
27 | id value = [property valueFromObject:self];
28 | if (value == nil) return;
29 | [encoder encodeObject:value forKey:property.name];
30 | }];
31 | }
32 |
33 | - (void)decode:(NSCoder *)decoder
34 | {
35 | Class class = [self class];
36 |
37 | NSArray *allowedCodingPropertyNames = [class totalAllowedCodingPropertyNames];
38 | NSArray *ignoredCodingPropertyNames = [class totalIgnoredCodingPropertyNames];
39 |
40 | [class enumeratePropertiesWithBlock:^(MJProperty *property, BOOL *stop) {
41 | if (allowedCodingPropertyNames.count && ![allowedCodingPropertyNames containsObject:property.name]) return;
42 | // 检测是否被忽略
43 | if ([ignoredCodingPropertyNames containsObject:property.name]) return;
44 |
45 | id value = [decoder decodeObjectForKey:property.name];
46 | if (value == nil) return;
47 | [property setValue:value forObject:self];
48 | }];
49 | }
50 | @end
51 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/MJExtension/NSObject+MJKeyValue.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+MJKeyValue.h
3 | // MJExtension
4 | //
5 | // Created by mj on 13-8-24.
6 | // Copyright (c) 2013年 小码哥. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "MJConst.h"
11 | #import
12 |
13 | /**
14 | * KeyValue协议
15 | */
16 | @protocol MJKeyValue
17 | @optional
18 | /**
19 | * 只有这个数组中的属性名才允许进行字典和模型的转换
20 | */
21 | + (NSArray *)allowedPropertyNames;
22 |
23 | /**
24 | * 这个数组中的属性名将会被忽略:不进行字典和模型的转换
25 | */
26 | + (NSArray *)ignoredPropertyNames;
27 |
28 | /**
29 | * 将属性名换为其他key去字典中取值
30 | *
31 | * @return 字典中的key是属性名,value是从字典中取值用的key
32 | */
33 | + (NSDictionary *)replacedKeyFromPropertyName;
34 |
35 | /**
36 | * 数组中需要转换的模型类
37 | *
38 | * @return 字典中的key是数组属性名,value是数组中存放模型的Class(Class类型或者NSString类型)
39 | */
40 | + (NSDictionary *)objectClassInArray;
41 |
42 | /**
43 | * 当字典转模型完毕时调用
44 | */
45 | - (void)keyValuesDidFinishConvertingToObject;
46 |
47 | /**
48 | * 当模型转字典完毕时调用
49 | */
50 | - (void)objectDidFinishConvertingToKeyValues;
51 | @end
52 |
53 | @interface NSObject (MJKeyValue)
54 | /**
55 | * 将字典的键值对转成模型属性
56 | * @param keyValues 字典
57 | */
58 | - (instancetype)setKeyValues:(id)keyValues;
59 | - (instancetype)setKeyValues:(id)keyValues error:(NSError **)error;
60 |
61 | /**
62 | * 将字典的键值对转成模型属性
63 | * @param keyValues 字典
64 | * @param context CoreData上下文
65 | */
66 | - (instancetype)setKeyValues:(id)keyValues context:(NSManagedObjectContext *)context;
67 | - (instancetype)setKeyValues:(id)keyValues context:(NSManagedObjectContext *)context error:(NSError **)error;
68 |
69 | /**
70 | * 将模型转成字典
71 | * @return 字典
72 | */
73 | - (NSDictionary *)keyValues;
74 | - (NSDictionary *)keyValuesWithKeys:(NSArray *)keys;
75 | - (NSDictionary *)keyValuesWithIgnoredKeys:(NSArray *)ignoredKeys;
76 | - (NSDictionary *)keyValuesWithError:(NSError **)error;
77 | - (NSDictionary *)keyValuesWithKeys:(NSArray *)keys error:(NSError **)error;
78 | - (NSDictionary *)keyValuesWithIgnoredKeys:(NSArray *)ignoredKeys error:(NSError **)error;
79 |
80 | /**
81 | * 通过模型数组来创建一个字典数组
82 | * @param objectArray 模型数组
83 | * @return 字典数组
84 | */
85 | + (NSArray *)keyValuesArrayWithObjectArray:(NSArray *)objectArray;
86 | + (NSArray *)keyValuesArrayWithObjectArray:(NSArray *)objectArray keys:(NSArray *)keys;
87 | + (NSArray *)keyValuesArrayWithObjectArray:(NSArray *)objectArray ignoredKeys:(NSArray *)ignoredKeys;
88 | + (NSArray *)keyValuesArrayWithObjectArray:(NSArray *)objectArray error:(NSError **)error;
89 | + (NSArray *)keyValuesArrayWithObjectArray:(NSArray *)objectArray keys:(NSArray *)keys error:(NSError **)error;
90 | + (NSArray *)keyValuesArrayWithObjectArray:(NSArray *)objectArray ignoredKeys:(NSArray *)ignoredKeys error:(NSError **)error;
91 |
92 | #pragma mark - 字典转模型
93 | /**
94 | * 通过JSON数据来创建一个模型
95 | * @param data JSON数据
96 | * @return 新建的对象
97 | */
98 | + (instancetype)objectWithJSONData:(NSData *)data;
99 | + (instancetype)objectWithJSONData:(NSData *)data error:(NSError **)error;
100 |
101 | /**
102 | * 通过字典来创建一个模型
103 | * @param keyValues 字典
104 | * @return 新建的对象
105 | */
106 | + (instancetype)objectWithKeyValues:(id)keyValues;
107 | + (instancetype)objectWithKeyValues:(id)keyValues error:(NSError **)error;
108 |
109 | /**
110 | * 通过字典来创建一个CoreData模型
111 | * @param keyValues 字典
112 | * @param context CoreData上下文
113 | * @return 新建的对象
114 | */
115 | + (instancetype)objectWithKeyValues:(id)keyValues context:(NSManagedObjectContext *)context;
116 | + (instancetype)objectWithKeyValues:(id)keyValues context:(NSManagedObjectContext *)context error:(NSError **)error;
117 |
118 | /**
119 | * 通过plist来创建一个模型
120 | * @param filename 文件名(仅限于mainBundle中的文件)
121 | * @return 新建的对象
122 | */
123 | + (instancetype)objectWithFilename:(NSString *)filename;
124 | + (instancetype)objectWithFilename:(NSString *)filename error:(NSError **)error;
125 |
126 | /**
127 | * 通过plist来创建一个模型
128 | * @param file 文件全路径
129 | * @return 新建的对象
130 | */
131 | + (instancetype)objectWithFile:(NSString *)file;
132 | + (instancetype)objectWithFile:(NSString *)file error:(NSError **)error;
133 |
134 | #pragma mark - 字典数组转模型数组
135 | /**
136 | * 通过JSON数据来创建一个模型数组
137 | * @param data JSON数据
138 | * @return 新建的对象
139 | */
140 | + (NSArray *)objectArrayWithJSONData:(NSData *)data;
141 | + (NSArray *)objectArrayWithJSONData:(NSData *)data error:(NSError **)error;
142 |
143 | /**
144 | * 通过字典数组来创建一个模型数组
145 | * @param keyValuesArray 字典数组
146 | * @return 模型数组
147 | */
148 | + (NSArray *)objectArrayWithKeyValuesArray:(id)keyValuesArray;
149 | + (NSArray *)objectArrayWithKeyValuesArray:(id)keyValuesArray error:(NSError **)error;
150 |
151 | /**
152 | * 通过字典数组来创建一个模型数组
153 | * @param keyValuesArray 字典数组
154 | * @param context CoreData上下文
155 | * @return 模型数组
156 | */
157 | + (NSArray *)objectArrayWithKeyValuesArray:(id)keyValuesArray context:(NSManagedObjectContext *)context;
158 | + (NSArray *)objectArrayWithKeyValuesArray:(id)keyValuesArray context:(NSManagedObjectContext *)context error:(NSError **)error;
159 |
160 | /**
161 | * 通过plist来创建一个模型数组
162 | * @param filename 文件名(仅限于mainBundle中的文件)
163 | * @return 模型数组
164 | */
165 | + (NSArray *)objectArrayWithFilename:(NSString *)filename;
166 | + (NSArray *)objectArrayWithFilename:(NSString *)filename error:(NSError **)error;
167 |
168 | /**
169 | * 通过plist来创建一个模型数组
170 | * @param file 文件全路径
171 | * @return 模型数组
172 | */
173 | + (NSArray *)objectArrayWithFile:(NSString *)file;
174 | + (NSArray *)objectArrayWithFile:(NSString *)file error:(NSError **)error;
175 | @end
176 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/MJExtension/NSObject+MJProperty.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+MJProperty.h
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/4/17.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class MJProperty;
12 |
13 | /**
14 | * 遍历所有类的block(父类)
15 | */
16 | typedef void (^MJClassesBlock)(Class c, BOOL *stop);
17 |
18 | /**
19 | * 遍历成员变量用的block
20 | *
21 | * @param property 成员的包装对象
22 | * @param stop YES代表停止遍历,NO代表继续遍历
23 | */
24 | typedef void (^MJPropertiesBlock)(MJProperty *property, BOOL *stop);
25 |
26 | /** 将属性名换为其他key去字典中取值 */
27 | typedef NSDictionary * (^ReplacedKeyFromPropertyName)();
28 | /** 数组中需要转换的模型类 */
29 | typedef NSDictionary * (^ObjectClassInArray)();
30 |
31 |
32 | /** 这个数组中的属性名才会进行字典和模型的转换 */
33 | typedef NSArray * (^AllowedPropertyNames)();
34 | /** 这个数组中的属性名才会进行归档 */
35 | typedef NSArray * (^AllowedCodingPropertyNames)();
36 |
37 | /** 这个数组中的属性名将会被忽略:不进行字典和模型的转换 */
38 | typedef NSArray * (^IgnoredPropertyNames)();
39 | /** 这个数组中的属性名将会被忽略:不进行归档 */
40 | typedef NSArray * (^IgnoredCodingPropertyNames)();
41 |
42 | @interface NSObject (MJProperty)
43 |
44 | /**
45 | * 遍历所有的成员
46 | */
47 | + (void)enumeratePropertiesWithBlock:(MJPropertiesBlock)block;
48 |
49 | /**
50 | * 遍历所有的类
51 | */
52 | + (void)enumerateClassesWithBlock:(MJClassesBlock)block;
53 |
54 | /**
55 | * 配置模型属性
56 | *
57 | * @param replacedKeyFromPropertyName 将属性名换为其他key去字典中取值
58 | * @param objectClassInArray 数组中需要转换的模型类
59 | */
60 | + (void)setupReplacedKeyFromPropertyName:(ReplacedKeyFromPropertyName)replacedKeyFromPropertyName objectClassInArray:(ObjectClassInArray)objectClassInArray;
61 |
62 | /**
63 | * 配置模型属性
64 | *
65 | * @param replacedKeyFromPropertyName 将属性名换为其他key去字典中取值
66 | */
67 | + (void)setupReplacedKeyFromPropertyName:(ReplacedKeyFromPropertyName)replacedKeyFromPropertyName;
68 |
69 | /**
70 | * 配置模型属性
71 | *
72 | * @param objectClassInArray 数组中需要转换的模型类
73 | */
74 | + (void)setupObjectClassInArray:(ObjectClassInArray)objectClassInArray;
75 |
76 | /**
77 | * 配置模型属性
78 | *
79 | * @param allowedPropertyNames 这个数组中的属性名才会进行字典和模型的转换
80 | */
81 | + (void)setupAllowedPropertyNames:(AllowedPropertyNames)allowedPropertyNames;
82 |
83 | /**
84 | * 这个数组中的属性名才会进行字典和模型的转换
85 | */
86 | + (NSArray *)totalAllowedPropertyNames;
87 |
88 | /**
89 | * 配置模型属性
90 | *
91 | * @param allowedCodingPropertyNames 这个数组中的属性名才会进行归档
92 | */
93 | + (void)setupAllowedCodingPropertyNames:(AllowedCodingPropertyNames)allowedCodingPropertyNames;
94 |
95 | /**
96 | * 这个数组中的属性名才会进行字典和模型的转换
97 | */
98 | + (NSArray *)totalAllowedCodingPropertyNames;
99 |
100 | /**
101 | * 配置模型属性
102 | *
103 | * @param ignoredPropertyNames 这个数组中的属性名将会被忽略:不进行字典和模型的转换
104 | */
105 | + (void)setupIgnoredPropertyNames:(IgnoredPropertyNames)ignoredPropertyNames;
106 |
107 | /**
108 | * 这个数组中的属性名将会被忽略:不进行字典和模型的转换
109 | */
110 | + (NSArray *)totalIgnoredPropertyNames;
111 |
112 | /**
113 | * 配置模型属性
114 | *
115 | * @param ignoredCodingPropertyNames 这个数组中的属性名将会被忽略:不进行归档
116 | */
117 | + (void)setupIgnoredCodingPropertyNames:(IgnoredCodingPropertyNames)ignoredCodingPropertyNames;
118 |
119 | /**
120 | * 这个数组中的属性名将会被忽略:不进行归档
121 | */
122 | + (NSArray *)totalIgnoredCodingPropertyNames;
123 | @end
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/MJExtension/NSObject+MJProperty.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+MJProperty.m
3 | // MJExtensionExample
4 | //
5 | // Created by MJ Lee on 15/4/17.
6 | // Copyright (c) 2015年 小码哥. All rights reserved.
7 | //
8 |
9 | #import "NSObject+MJProperty.h"
10 | #import "NSObject+MJKeyValue.h"
11 | #import "NSObject+MJCoding.h"
12 | #import "MJProperty.h"
13 | #import "MJFoundation.h"
14 | #import
15 |
16 | static const char MJReplacedKeyFromPropertyNameKey;
17 | static const char MJObjectClassInArrayKey;
18 | static const char MJAllowedPropertyNamesKey;
19 | static const char MJAllowedCodingPropertyNamesKey;
20 | static const char MJIgnoredPropertyNamesKey;
21 | static const char MJIgnoredCodingPropertyNamesKey;
22 |
23 | @implementation NSObject (Property)
24 | #pragma mark - --私有方法--
25 | + (NSString *)propertyKey:(NSString *)propertyName
26 | {
27 | MJAssertParamNotNil2(propertyName, nil);
28 |
29 | __block NSString *key = nil;
30 | // 1.查看有没有需要替换的key
31 | if ([self respondsToSelector:@selector(replacedKeyFromPropertyName)]) {
32 | key = [self replacedKeyFromPropertyName][propertyName];
33 | }
34 |
35 | if (!key) {
36 | [self enumerateClassesWithBlock:^(__unsafe_unretained Class c, BOOL *stop) {
37 | NSDictionary *dict = objc_getAssociatedObject(c, &MJReplacedKeyFromPropertyNameKey);
38 | if (dict) {
39 | key = dict[propertyName];
40 | }
41 | if (key) *stop = YES;
42 | }];
43 | }
44 |
45 | // 2.用属性名作为key
46 | if (!key) key = propertyName;
47 |
48 | return key;
49 | }
50 |
51 | + (Class)propertyObjectClassInArray:(NSString *)propertyName
52 | {
53 | __block id class = nil;
54 | if ([self respondsToSelector:@selector(objectClassInArray)]) {
55 | class = [self objectClassInArray][propertyName];
56 | }
57 |
58 | if (!class) {
59 | [self enumerateClassesWithBlock:^(__unsafe_unretained Class c, BOOL *stop) {
60 | NSDictionary *dict = objc_getAssociatedObject(c, &MJObjectClassInArrayKey);
61 | if (dict) {
62 | class = dict[propertyName];
63 | }
64 | if (class) *stop = YES;
65 | }];
66 | }
67 |
68 | // 如果是NSString类型
69 | if ([class isKindOfClass:[NSString class]]) {
70 | class = NSClassFromString(class);
71 | }
72 | return class;
73 | }
74 |
75 | #pragma mark - --公共方法--
76 | + (void)enumeratePropertiesWithBlock:(MJPropertiesBlock)block
77 | {
78 | // 获得成员变量
79 | NSArray *cachedProperties = [self properties];
80 |
81 | // 遍历成员变量
82 | BOOL stop = NO;
83 | for (MJProperty *property in cachedProperties) {
84 | block(property, &stop);
85 | if (stop) break;
86 | }
87 | }
88 |
89 | + (void)enumerateClassesWithBlock:(MJClassesBlock)block
90 | {
91 | // 1.没有block就直接返回
92 | if (block == nil) return;
93 |
94 | // 2.停止遍历的标记
95 | BOOL stop = NO;
96 |
97 | // 3.当前正在遍历的类
98 | Class c = self;
99 |
100 | // 4.开始遍历每一个类
101 | while (c && !stop) {
102 | // 4.1.执行操作
103 | block(c, &stop);
104 |
105 | // 4.2.获得父类
106 | c = class_getSuperclass(c);
107 |
108 | if ([MJFoundation isClassFromFoundation:c]) break;
109 | }
110 | }
111 |
112 | #pragma mark - 公共方法
113 | + (NSArray *)properties
114 | {
115 | static const char MJCachedPropertiesKey;
116 |
117 | // 获得成员变量
118 | // 通过关联对象,以及提前定义好的MJCachedPropertiesKey来进行运行时,对所有属性的获取。
119 |
120 | //***objc_getAssociatedObject 方法用于判断当前是否已经获取过MJCachedPropertiesKey对应的关联对象
121 | // 1> 关联到的对象
122 | // 2> 关联的属性 key
123 | NSMutableArray *cachedProperties = objc_getAssociatedObject(self, &MJCachedPropertiesKey);
124 | //***
125 | if (cachedProperties == nil) {
126 | cachedProperties = [NSMutableArray array];
127 |
128 | /**遍历这个类的父类*/
129 | [self enumerateClassesWithBlock:^(__unsafe_unretained Class c, BOOL *stop) {
130 | // 1.获得所有的成员变量
131 | unsigned int outCount = 0;
132 | /**
133 | class_copyIvarList 成员变量,提示有很多第三方框架会使用 Ivar,能够获得更多的信息
134 | 但是:在 swift 中,由于语法结构的变化,使用 Ivar 非常不稳定,经常会崩溃!
135 | class_copyPropertyList 属性
136 | class_copyMethodList 方法
137 | class_copyProtocolList 协议
138 | */
139 | objc_property_t *properties = class_copyPropertyList(c, &outCount);
140 |
141 | // 2.遍历每一个成员变量
142 | for (unsigned int i = 0; i
10 |
11 | @interface NSString (MJExtension)
12 | - (id)JSONObject;
13 | @end
14 |
--------------------------------------------------------------------------------
/CorePagesView/Frameworks/MJExtension/NSString+MJExtension.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+MJExtension.m
3 | // TestTabBar
4 | //
5 | // Created by MJ Lee on 15/4/17.
6 | // Copyright (c) 2015年 Mac Z. All rights reserved.
7 | //
8 |
9 | #import "NSString+MJExtension.h"
10 |
11 | @implementation NSString (MJExtension)
12 | - (id)JSONObject
13 | {
14 | return [NSJSONSerialization JSONObjectWithData:[self dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:nil];
15 | }
16 | @end
17 |
--------------------------------------------------------------------------------
/CorePagesView/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/CorePagesView/Images.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "portrait",
5 | "idiom" : "iphone",
6 | "minimum-system-version" : "7.0",
7 | "subtype" : "retina4",
8 | "scale" : "2x"
9 | },
10 | {
11 | "idiom" : "iphone",
12 | "scale" : "1x",
13 | "orientation" : "portrait"
14 | },
15 | {
16 | "idiom" : "iphone",
17 | "scale" : "2x",
18 | "orientation" : "portrait"
19 | },
20 | {
21 | "orientation" : "portrait",
22 | "idiom" : "iphone",
23 | "subtype" : "retina4",
24 | "scale" : "2x"
25 | },
26 | {
27 | "orientation" : "portrait",
28 | "idiom" : "iphone",
29 | "minimum-system-version" : "7.0",
30 | "scale" : "2x"
31 | }
32 | ],
33 | "info" : {
34 | "version" : 1,
35 | "author" : "xcode"
36 | }
37 | }
--------------------------------------------------------------------------------
/CorePagesView/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.huaxi.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/CorePagesView/NewsListCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // NewsListCell.h
3 | // CorePagesView
4 | //
5 | // Created by 冯成林 on 15/5/26.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "LTCell.h"
10 |
11 | @interface NewsListCell : LTCell
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CorePagesView/NewsListCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // NewsListCell.m
3 | // CorePagesView
4 | //
5 | // Created by 冯成林 on 15/5/26.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "NewsListCell.h"
10 | #import "NewsListModel.h"
11 |
12 |
13 | @interface NewsListCell ()
14 |
15 | @property (weak, nonatomic) IBOutlet UILabel *indexLabel;
16 |
17 | @property (weak, nonatomic) IBOutlet UILabel *titleLabel;
18 |
19 | @property (weak, nonatomic) IBOutlet UILabel *contentLabel;
20 |
21 |
22 | @end
23 |
24 |
25 |
26 | @implementation NewsListCell
27 |
28 |
29 | /*
30 | * 数据填充
31 | */
32 | -(void)dataFill{
33 |
34 | //类型强转
35 | NewsListModel *model =(NewsListModel *) self.model;
36 |
37 | _indexLabel.text = [NSString stringWithFormat:@"%@",@(model.hostID)];
38 |
39 | _titleLabel.text = model.title;
40 |
41 | _contentLabel.text = model.content;
42 | }
43 |
44 | @end
45 |
--------------------------------------------------------------------------------
/CorePagesView/NewsListCell.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
22 |
28 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/CorePagesView/NewsListModel.h:
--------------------------------------------------------------------------------
1 | //
2 | // NewsListModel.h
3 | // CorePagesView
4 | //
5 | // Created by 冯成林 on 15/5/26.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "CoreListCommonModel.h"
10 |
11 | @interface NewsListModel : CoreListCommonModel
12 |
13 | @property (nonatomic,copy) NSString *title,*about,*content;
14 |
15 |
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/CorePagesView/NewsListModel.m:
--------------------------------------------------------------------------------
1 | //
2 | // NewsListModel.m
3 | // CorePagesView
4 | //
5 | // Created by 冯成林 on 15/5/26.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "NewsListModel.h"
10 |
11 | @implementation NewsListModel
12 |
13 | +(NSArray *)modelPrepare:(id)obj{
14 |
15 | return obj[@"data"];
16 | }
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/CorePagesView/NewsListTVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // NewsListTVC.h
3 | // CorePagesView
4 | //
5 | // Created by 冯成林 on 15/5/26.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "CoreLTVC.h"
10 |
11 | @interface NewsListTVC : CoreLTVC
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CorePagesView/NewsListTVC.m:
--------------------------------------------------------------------------------
1 | //
2 | // NewsListTVC.m
3 | // CorePagesView
4 | //
5 | // Created by 冯成林 on 15/5/26.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "NewsListTVC.h"
10 | #import "NewsListModel.h"
11 | #import "NewsListCell.h"
12 |
13 |
14 |
15 |
16 |
17 | @interface NewsListTVC ()
18 |
19 | @end
20 |
21 | @implementation NewsListTVC
22 |
23 | - (void)viewDidLoad {
24 | [super viewDidLoad];
25 |
26 | //模型配置
27 | [self config];
28 |
29 | self.view.layer.borderColor = [UIColor redColor].CGColor;
30 | self.view.layer.borderWidth = 5.0f;
31 | }
32 |
33 | /**
34 | * 模型配置
35 | */
36 | -(void)config{
37 |
38 | LTConfigModel *configModel=[[LTConfigModel alloc] init];
39 | //url
40 | configModel.url=@"http://211.149.151.92/Carpenter/index.php/Info/testdata";
41 | //请求方式
42 | configModel.httpMethod=LTConfigModelHTTPMethodGET;
43 | //模型类
44 | configModel.ModelClass=[NewsListModel class];
45 | //cell类
46 | configModel.ViewForCellClass=[NewsListCell class];
47 | //标识
48 | configModel.lid=NSStringFromClass(self.class);
49 | //pageName
50 | configModel.pageName=@"p";
51 | //pageSizeName
52 | configModel.pageSizeName=@"pagesize";
53 | //起始页码
54 | configModel.pageStartValue=1;
55 | //行高
56 | configModel.rowHeight=60;
57 |
58 | //移除返回顶部:(默认开启)
59 | configModel.removeBackToTopBtn=NO;
60 |
61 | configModel.refreshControlType = LTConfigModelRefreshControlTypeBoth;
62 |
63 | //配置完毕
64 | self.configModel=configModel;
65 | }
66 |
67 |
68 | @end
69 |
--------------------------------------------------------------------------------
/CorePagesView/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // CorePagesView
4 | //
5 | // Created by muxi on 15/3/20.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 |
12 | @interface ViewController : UIViewController
13 |
14 |
15 |
16 |
17 |
18 | @end
19 |
20 |
--------------------------------------------------------------------------------
/CorePagesView/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // CorePagesView
4 | //
5 | // Created by muxi on 15/3/20.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "CorePagesView.h"
11 | #import "NewsListTVC.h"
12 |
13 |
14 |
15 | @interface ViewController ()
16 |
17 | @property (nonatomic,strong) CorePagesView *pagesView;
18 |
19 | @end
20 |
21 | @implementation ViewController
22 |
23 |
24 |
25 | -(void)loadView{
26 | self.view=self.pagesView;
27 | }
28 |
29 |
30 |
31 | - (void)viewDidLoad {
32 | [super viewDidLoad];
33 | self.edgesForExtendedLayout=UIRectEdgeNone;
34 |
35 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(8 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
36 | [self.pagesView jumpToPage:3];
37 | });
38 | }
39 |
40 |
41 |
42 | -(CorePagesView *)pagesView{
43 |
44 | if(_pagesView==nil){
45 |
46 | NewsListTVC *tvc1 = [[NewsListTVC alloc] init];
47 | NewsListTVC *tvc2 = [[NewsListTVC alloc] init];
48 | NewsListTVC *tvc3 = [[NewsListTVC alloc] init];
49 | NewsListTVC *tvc4 = [[NewsListTVC alloc] init];
50 |
51 |
52 | CorePageModel *model1=[CorePageModel model:tvc1 pageBarName:@"新闻1"];
53 | CorePageModel *model2=[CorePageModel model:tvc2 pageBarName:@"新闻2"];
54 | CorePageModel *model3=[CorePageModel model:tvc3 pageBarName:@"新闻3"];
55 | CorePageModel *model4=[CorePageModel model:tvc4 pageBarName:@"新闻4"];
56 |
57 |
58 | NSArray *pageModels=@[model1,model2,model3,model4];
59 |
60 |
61 | //自定义配置
62 | CorePagesViewConfig *config = [[CorePagesViewConfig alloc] init];
63 |
64 | config.isBarBtnUseCustomWidth = YES;
65 |
66 | config.barBtnWidth = [UIScreen mainScreen].bounds.size.width/4;
67 |
68 | config.barViewH = 40;
69 |
70 | _pagesView=[CorePagesView viewWithOwnerVC:self pageModels:pageModels config:config];
71 |
72 | }
73 |
74 | return _pagesView;
75 | }
76 |
77 |
78 | @end
79 |
--------------------------------------------------------------------------------
/CorePagesView/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // CorePagesView
4 | //
5 | // Created by muxi on 15/3/20.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/CorePagesView/pic/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CorePagesView/905caceaf4b2d8ede868bb8c231f38daf802066b/CorePagesView/pic/1.png
--------------------------------------------------------------------------------
/CorePagesView/pic/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CorePagesView/905caceaf4b2d8ede868bb8c231f38daf802066b/CorePagesView/pic/2.png
--------------------------------------------------------------------------------
/CorePagesView/pic/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CorePagesView/905caceaf4b2d8ede868bb8c231f38daf802066b/CorePagesView/pic/3.png
--------------------------------------------------------------------------------
/CorePagesView/pic/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CorePagesView/905caceaf4b2d8ede868bb8c231f38daf802066b/CorePagesView/pic/4.png
--------------------------------------------------------------------------------
/CorePagesView/show2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlinFeng/CorePagesView/905caceaf4b2d8ede868bb8c231f38daf802066b/CorePagesView/show2.gif
--------------------------------------------------------------------------------
/CorePagesViewTests/CorePagesViewTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // CorePagesViewTests.m
3 | // CorePagesViewTests
4 | //
5 | // Created by muxi on 15/3/20.
6 | // Copyright (c) 2015年 muxi. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface CorePagesViewTests : XCTestCase
13 |
14 | @end
15 |
16 | @implementation CorePagesViewTests
17 |
18 | - (void)setUp {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown {
24 | // Put teardown code here. This method is called after the invocation of each test method in the class.
25 | [super tearDown];
26 | }
27 |
28 | - (void)testExample {
29 | // This is an example of a functional test case.
30 | XCTAssert(YES, @"Pass");
31 | }
32 |
33 | - (void)testPerformanceExample {
34 | // This is an example of a performance test case.
35 | [self measureBlock:^{
36 | // Put the code you want to measure the time of here.
37 | }];
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/CorePagesViewTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.huaxi.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ## CorePagesView (持续关注[信息公告牌](https://github.com/CharlinFeng/Show))
5 | 列表滚动视图,性能王者!
6 |
7 |
8 |
9 | #### 重磅推出
10 | Swift版
11 | 文档:https://github.com/nsdictionary/CFPagesVC
12 |
13 |
14 |
15 | 框架截图 SHOW
16 | ===============
17 | 
18 |
19 |
20 |
21 |
22 |
23 |
24 | 框架升级1.2版本 NEW FEATURE!
25 | ===============
26 |
27 | ####框架特性:
28 | >1.去除了宏定义配置,因为宏定义是全局的,我项目中遇到了不同的页面需要不同的配置,
29 | 所以页面参数配置变成了Model配置,更加灵活。
30 | >2.根据要求修复了右滑动越界崩溃的bug。
31 | >3.根据要求添加了代码动态设置页码,增加了相应的API
32 | >4.处理了用户疯狂点击顶部按钮因为复用机制导致的bug。
33 |
34 |
35 |
36 | 1.0版本使用说明 USAGE
37 | ===============
38 |
39 |
40 | 框架说明 EXPALIN
41 | ===============
42 | .本框架主要是为了解决类似以下界面的而生:
43 | .网易新闻列表
44 | .越狱版的同步推(没越狱的没用过,不知道是不是一样的)
45 | .还有我自己做的项目如铁路wifi,车联网都使用到了这样的界面
46 | .等等,这种需求非常常见。
47 | 大概的界面是:一个页面需要左右滑动,切换子控制器,同时顶部有tab标题,点击也可以滑动到对应的页面。
48 |
49 |
50 |
51 | 框架由来 FROM
52 | ===============
53 | 为什么要写这个框架,感觉功能不是很多啊?
54 | 首先要说的是这个需求其实是非常复杂的,我写的这个框架有上千行代码,里面有很多细节是需要注意的
55 | 2.1 子控制器的数量不是固定的,这个需求有3个,下一个需求有4个。甚至网易新闻那种可定制化菜单,数量是不确定的。
56 | 2.2 由于数量不确定,所以对整个需求加大了难度,同时如果像网易那种,有十来个子控制器,如果你敢一个全部加载,只能引发内存问题,我之前做了一个项目叫铁路wifi,有8个新闻栏目同时加载,在iphone 4上面直接卡死8秒左右才有反应。
57 | 2.3 你仔细观察网易新闻,你会发现当点击tab切换,3分钟左右会触发新闻列表页面的刷新,当然这个新闻页面的刷新绝对不是本框架去关心的,这个是属性CoreList类型的加载框架应该做的事情,换句话说,为了解耦,你点击切换tab,只有在一种情况下才能触发,那就是触发子控制器的生命周期方法如viewDidAppear:和viewDidDisappear:,同时也涉及性能问题,我们需要动态添加和移除子视图。这个也是比较复杂的。同时添加和移除需要考虑很多问题,如子列表的位置,比如移除前子列表是一个tableView显示在第20行,移除添加之后最好还是在这个位置,给人一种没有动过的感觉。
58 | 2.4 对于顶部的菜单来说,也有很多种样式,有的是一个按钮就很宽的,有的是图片加文字,有的是居中但是不是很宽,所以这些都是可以封装的,同时也是可以自定义修改的。
59 | 2.5 scrollView的滚动切换与点击tab的切换是逻辑的,是可以封装的,同时如果顶部菜单数量过多,还需要动态调整让当前显示在中间。这些都是可以封装起来的。
60 | 2.6 需要考虑屏幕旋转及横竖屏的问题。
61 |
62 | 项目解析 USAGE
63 | ===============
64 | 本框架写了一周左右(我正在做车联网,写框架的时间不是很多),写框架的时间考虑的问题还是算比较全面,
65 | 下面就对如果自定义出你想要的样式,核心思想、重要代码以及使用做出一个解释。
66 |
67 | 使用示例:
68 |
69 | 1.集成
70 |
71 | -(CorePagesView *)pagesView{
72 |
73 | if(_pagesView==nil){
74 |
75 | NewsListTVC *tvc1 = [[NewsListTVC alloc] init];
76 | NewsListTVC *tvc2 = [[NewsListTVC alloc] init];
77 | NewsListTVC *tvc3 = [[NewsListTVC alloc] init];
78 | NewsListTVC *tvc4 = [[NewsListTVC alloc] init];
79 |
80 |
81 | CorePageModel *model1=[CorePageModel model:tvc1 pageBarName:@"新闻1"];
82 | CorePageModel *model2=[CorePageModel model:tvc2 pageBarName:@"新闻2"];
83 | CorePageModel *model3=[CorePageModel model:tvc3 pageBarName:@"新闻3"];
84 | CorePageModel *model4=[CorePageModel model:tvc4 pageBarName:@"新闻4"];
85 |
86 |
87 | NSArray *pageModels=@[model1,model2,model3,model4];
88 |
89 |
90 | //自定义配置。如果传nil,则为默认值(全局有效)
91 | CorePagesViewConfig *config = [[CorePagesViewConfig alloc] init];
92 | config.isBarBtnUseCustomWidth = YES;
93 | config.barViewH = 80;
94 |
95 |
96 | _pagesView=[CorePagesView viewWithOwnerVC:self pageModels:pageModels config:config];
97 |
98 | }
99 |
100 | return _pagesView;
101 | }
102 |
103 |
104 | 2.代码跳转:
105 | /** 中转到指定页码 */
106 | -(void)jumpToPage:(NSUInteger)jumpPage;
107 |
108 |
109 |
110 |
111 |
112 | ####.效果图片
113 | 
114 | 
115 | 
116 | 
117 |
118 |
119 |
--------------------------------------------------------------------------------