fix 个人信息
This commit is contained in:
@@ -106,6 +106,25 @@
|
||||
838762E3214B9F580039D241 /* GiGaUserSexViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 838762E1214B9F580039D241 /* GiGaUserSexViewCell.xib */; };
|
||||
838762E7214B9FA60039D241 /* GIGaUserCityViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 838762E5214B9FA60039D241 /* GIGaUserCityViewCell.m */; };
|
||||
838762E8214B9FA60039D241 /* GIGaUserCityViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 838762E6214B9FA60039D241 /* GIGaUserCityViewCell.xib */; };
|
||||
8390116B214E20B2004CA790 /* LYSDateContentView.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901145214E20B1004CA790 /* LYSDateContentView.m */; };
|
||||
8390116C214E20B2004CA790 /* LYSDatePopViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901149214E20B1004CA790 /* LYSDatePopViewController.m */; };
|
||||
8390116D214E20B2004CA790 /* LYSDateBaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901151214E20B1004CA790 /* LYSDateBaseViewController.m */; };
|
||||
8390116E214E20B2004CA790 /* LYSDateLogicViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901152214E20B1004CA790 /* LYSDateLogicViewController.m */; };
|
||||
8390116F214E20B2004CA790 /* LYSDatePickerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901155214E20B1004CA790 /* LYSDatePickerViewController.m */; };
|
||||
83901170214E20B2004CA790 /* LYSDateHeaderViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901156214E20B1004CA790 /* LYSDateHeaderViewController.m */; };
|
||||
83901171214E20B2004CA790 /* LYSDatePickerLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901157214E20B1004CA790 /* LYSDatePickerLabel.m */; };
|
||||
83901172214E20B2004CA790 /* LYSDatePickerTypeDayAndTimeDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901159214E20B1004CA790 /* LYSDatePickerTypeDayAndTimeDelegate.m */; };
|
||||
83901173214E20B2004CA790 /* LYSDateBasicViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8390115A214E20B1004CA790 /* LYSDateBasicViewController.m */; };
|
||||
83901174214E20B2004CA790 /* LYSDateIndicatorViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8390115B214E20B1004CA790 /* LYSDateIndicatorViewController.m */; };
|
||||
83901175214E20B2004CA790 /* LYSDatePickerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 8390115D214E20B1004CA790 /* LYSDatePickerManager.m */; };
|
||||
83901176214E20B2004CA790 /* LYSDatePickerTypeDayDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8390115F214E20B1004CA790 /* LYSDatePickerTypeDayDelegate.m */; };
|
||||
83901177214E20B2004CA790 /* LYSDatePickerTypeTimeDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901160214E20B1004CA790 /* LYSDatePickerTypeTimeDelegate.m */; };
|
||||
83901178214E20B2004CA790 /* LYSDatePickerItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901161214E20B1004CA790 /* LYSDatePickerItem.m */; };
|
||||
83901179214E20B2004CA790 /* LYSDatePickerTypeBase.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901162214E20B1004CA790 /* LYSDatePickerTypeBase.m */; };
|
||||
8390117A214E20B2004CA790 /* LYSDatePickerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901164214E20B1004CA790 /* LYSDatePickerController.m */; };
|
||||
8390117B214E20B2004CA790 /* LYSDatePickerHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 83901165214E20B1004CA790 /* LYSDatePickerHeaderView.m */; };
|
||||
8390117C214E20B2004CA790 /* citys.json in Resources */ = {isa = PBXBuildFile; fileRef = 83901169214E20B2004CA790 /* citys.json */; };
|
||||
8390117D214E20B2004CA790 /* JYAddressPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 8390116A214E20B2004CA790 /* JYAddressPicker.m */; };
|
||||
83928FFA2134D8F60077D2E8 /* GiGaFlyingCommitInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = 83928FF92134D8F60077D2E8 /* GiGaFlyingCommitInputView.m */; };
|
||||
83928FFE2134F37D0077D2E8 /* GiGaSocketRocketUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = 83928FFD2134F37D0077D2E8 /* GiGaSocketRocketUtility.m */; };
|
||||
839290052134F4240077D2E8 /* LXDanMuTrackView.m in Sources */ = {isa = PBXBuildFile; fileRef = 839290002134F4230077D2E8 /* LXDanMuTrackView.m */; };
|
||||
@@ -327,6 +346,45 @@
|
||||
838762E4214B9FA60039D241 /* GIGaUserCityViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GIGaUserCityViewCell.h; sourceTree = "<group>"; };
|
||||
838762E5214B9FA60039D241 /* GIGaUserCityViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GIGaUserCityViewCell.m; sourceTree = "<group>"; };
|
||||
838762E6214B9FA60039D241 /* GIGaUserCityViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GIGaUserCityViewCell.xib; sourceTree = "<group>"; };
|
||||
83901142214E04D1004CA790 /* ApiRequestConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ApiRequestConfig.h; sourceTree = "<group>"; };
|
||||
83901144214E20B1004CA790 /* LYSDatePickerTypeDayAndTimeDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDatePickerTypeDayAndTimeDelegate.h; sourceTree = "<group>"; };
|
||||
83901145214E20B1004CA790 /* LYSDateContentView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDateContentView.m; sourceTree = "<group>"; };
|
||||
83901146214E20B1004CA790 /* LYSDateHeaderViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDateHeaderViewController.h; sourceTree = "<group>"; };
|
||||
83901147214E20B1004CA790 /* LYSDatePickerLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDatePickerLabel.h; sourceTree = "<group>"; };
|
||||
83901148214E20B1004CA790 /* LYSDatePickerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDatePickerManager.h; sourceTree = "<group>"; };
|
||||
83901149214E20B1004CA790 /* LYSDatePopViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDatePopViewController.m; sourceTree = "<group>"; };
|
||||
8390114A214E20B1004CA790 /* LYSDateIndicatorViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDateIndicatorViewController.h; sourceTree = "<group>"; };
|
||||
8390114B214E20B1004CA790 /* LYSDateBasicViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDateBasicViewController.h; sourceTree = "<group>"; };
|
||||
8390114C214E20B1004CA790 /* LYSDatePickerTypeBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDatePickerTypeBase.h; sourceTree = "<group>"; };
|
||||
8390114D214E20B1004CA790 /* LYSDatePickerSelectDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDatePickerSelectDelegate.h; sourceTree = "<group>"; };
|
||||
8390114E214E20B1004CA790 /* LYSDatePickerItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDatePickerItem.h; sourceTree = "<group>"; };
|
||||
8390114F214E20B1004CA790 /* LYSDatePickerTypeDayDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDatePickerTypeDayDelegate.h; sourceTree = "<group>"; };
|
||||
83901150214E20B1004CA790 /* LYSDatePickerTypeTimeDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDatePickerTypeTimeDelegate.h; sourceTree = "<group>"; };
|
||||
83901151214E20B1004CA790 /* LYSDateBaseViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDateBaseViewController.m; sourceTree = "<group>"; };
|
||||
83901152214E20B1004CA790 /* LYSDateLogicViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDateLogicViewController.m; sourceTree = "<group>"; };
|
||||
83901153214E20B1004CA790 /* LYSDatePickerHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDatePickerHeaderView.h; sourceTree = "<group>"; };
|
||||
83901154214E20B1004CA790 /* LYSDatePickerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDatePickerController.h; sourceTree = "<group>"; };
|
||||
83901155214E20B1004CA790 /* LYSDatePickerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDatePickerViewController.m; sourceTree = "<group>"; };
|
||||
83901156214E20B1004CA790 /* LYSDateHeaderViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDateHeaderViewController.m; sourceTree = "<group>"; };
|
||||
83901157214E20B1004CA790 /* LYSDatePickerLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDatePickerLabel.m; sourceTree = "<group>"; };
|
||||
83901158214E20B1004CA790 /* LYSDateContentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDateContentView.h; sourceTree = "<group>"; };
|
||||
83901159214E20B1004CA790 /* LYSDatePickerTypeDayAndTimeDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDatePickerTypeDayAndTimeDelegate.m; sourceTree = "<group>"; };
|
||||
8390115A214E20B1004CA790 /* LYSDateBasicViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDateBasicViewController.m; sourceTree = "<group>"; };
|
||||
8390115B214E20B1004CA790 /* LYSDateIndicatorViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDateIndicatorViewController.m; sourceTree = "<group>"; };
|
||||
8390115C214E20B1004CA790 /* LYSDatePopViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDatePopViewController.h; sourceTree = "<group>"; };
|
||||
8390115D214E20B1004CA790 /* LYSDatePickerManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDatePickerManager.m; sourceTree = "<group>"; };
|
||||
8390115E214E20B1004CA790 /* LYSDateBaseViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDateBaseViewController.h; sourceTree = "<group>"; };
|
||||
8390115F214E20B1004CA790 /* LYSDatePickerTypeDayDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDatePickerTypeDayDelegate.m; sourceTree = "<group>"; };
|
||||
83901160214E20B1004CA790 /* LYSDatePickerTypeTimeDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDatePickerTypeTimeDelegate.m; sourceTree = "<group>"; };
|
||||
83901161214E20B1004CA790 /* LYSDatePickerItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDatePickerItem.m; sourceTree = "<group>"; };
|
||||
83901162214E20B1004CA790 /* LYSDatePickerTypeBase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDatePickerTypeBase.m; sourceTree = "<group>"; };
|
||||
83901163214E20B1004CA790 /* LYSDatePickerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDatePickerViewController.h; sourceTree = "<group>"; };
|
||||
83901164214E20B1004CA790 /* LYSDatePickerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDatePickerController.m; sourceTree = "<group>"; };
|
||||
83901165214E20B1004CA790 /* LYSDatePickerHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LYSDatePickerHeaderView.m; sourceTree = "<group>"; };
|
||||
83901166214E20B1004CA790 /* LYSDateLogicViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LYSDateLogicViewController.h; sourceTree = "<group>"; };
|
||||
83901168214E20B2004CA790 /* JYAddressPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JYAddressPicker.h; sourceTree = "<group>"; };
|
||||
83901169214E20B2004CA790 /* citys.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = citys.json; sourceTree = "<group>"; };
|
||||
8390116A214E20B2004CA790 /* JYAddressPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JYAddressPicker.m; sourceTree = "<group>"; };
|
||||
83928FF82134D8F60077D2E8 /* GiGaFlyingCommitInputView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaFlyingCommitInputView.h; sourceTree = "<group>"; };
|
||||
83928FF92134D8F60077D2E8 /* GiGaFlyingCommitInputView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaFlyingCommitInputView.m; sourceTree = "<group>"; };
|
||||
83928FFC2134F37D0077D2E8 /* GiGaSocketRocketUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GiGaSocketRocketUtility.h; sourceTree = "<group>"; };
|
||||
@@ -474,6 +532,8 @@
|
||||
8340BFAC213E7374008F22E4 /* Views */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
83901167214E20B2004CA790 /* JYAddressPicker */,
|
||||
83901143214E20B1004CA790 /* LYSDatePickerController */,
|
||||
8338F6B62142504E00B4780B /* CustomSwitch */,
|
||||
8340BFAD213E739D008F22E4 /* GiGaNoNetWorkView.h */,
|
||||
8340BFAE213E739D008F22E4 /* GiGaNoNetWorkView.m */,
|
||||
@@ -678,6 +738,7 @@
|
||||
8361B42C2121812000238FEB /* GiGaServerConfig.h */,
|
||||
8361B42D2121812000238FEB /* GiGaServerConfig.m */,
|
||||
8314D2122133F44600B458BF /* MobClickList.h */,
|
||||
83901142214E04D1004CA790 /* ApiRequestConfig.h */,
|
||||
);
|
||||
path = Config;
|
||||
sourceTree = "<group>";
|
||||
@@ -1001,6 +1062,58 @@
|
||||
path = userInfoView;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
83901143214E20B1004CA790 /* LYSDatePickerController */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
83901144214E20B1004CA790 /* LYSDatePickerTypeDayAndTimeDelegate.h */,
|
||||
83901145214E20B1004CA790 /* LYSDateContentView.m */,
|
||||
83901146214E20B1004CA790 /* LYSDateHeaderViewController.h */,
|
||||
83901147214E20B1004CA790 /* LYSDatePickerLabel.h */,
|
||||
83901148214E20B1004CA790 /* LYSDatePickerManager.h */,
|
||||
83901149214E20B1004CA790 /* LYSDatePopViewController.m */,
|
||||
8390114A214E20B1004CA790 /* LYSDateIndicatorViewController.h */,
|
||||
8390114B214E20B1004CA790 /* LYSDateBasicViewController.h */,
|
||||
8390114C214E20B1004CA790 /* LYSDatePickerTypeBase.h */,
|
||||
8390114D214E20B1004CA790 /* LYSDatePickerSelectDelegate.h */,
|
||||
8390114E214E20B1004CA790 /* LYSDatePickerItem.h */,
|
||||
8390114F214E20B1004CA790 /* LYSDatePickerTypeDayDelegate.h */,
|
||||
83901150214E20B1004CA790 /* LYSDatePickerTypeTimeDelegate.h */,
|
||||
83901151214E20B1004CA790 /* LYSDateBaseViewController.m */,
|
||||
83901152214E20B1004CA790 /* LYSDateLogicViewController.m */,
|
||||
83901153214E20B1004CA790 /* LYSDatePickerHeaderView.h */,
|
||||
83901154214E20B1004CA790 /* LYSDatePickerController.h */,
|
||||
83901155214E20B1004CA790 /* LYSDatePickerViewController.m */,
|
||||
83901156214E20B1004CA790 /* LYSDateHeaderViewController.m */,
|
||||
83901157214E20B1004CA790 /* LYSDatePickerLabel.m */,
|
||||
83901158214E20B1004CA790 /* LYSDateContentView.h */,
|
||||
83901159214E20B1004CA790 /* LYSDatePickerTypeDayAndTimeDelegate.m */,
|
||||
8390115A214E20B1004CA790 /* LYSDateBasicViewController.m */,
|
||||
8390115B214E20B1004CA790 /* LYSDateIndicatorViewController.m */,
|
||||
8390115C214E20B1004CA790 /* LYSDatePopViewController.h */,
|
||||
8390115D214E20B1004CA790 /* LYSDatePickerManager.m */,
|
||||
8390115E214E20B1004CA790 /* LYSDateBaseViewController.h */,
|
||||
8390115F214E20B1004CA790 /* LYSDatePickerTypeDayDelegate.m */,
|
||||
83901160214E20B1004CA790 /* LYSDatePickerTypeTimeDelegate.m */,
|
||||
83901161214E20B1004CA790 /* LYSDatePickerItem.m */,
|
||||
83901162214E20B1004CA790 /* LYSDatePickerTypeBase.m */,
|
||||
83901163214E20B1004CA790 /* LYSDatePickerViewController.h */,
|
||||
83901164214E20B1004CA790 /* LYSDatePickerController.m */,
|
||||
83901165214E20B1004CA790 /* LYSDatePickerHeaderView.m */,
|
||||
83901166214E20B1004CA790 /* LYSDateLogicViewController.h */,
|
||||
);
|
||||
path = LYSDatePickerController;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
83901167214E20B2004CA790 /* JYAddressPicker */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
83901168214E20B2004CA790 /* JYAddressPicker.h */,
|
||||
83901169214E20B2004CA790 /* citys.json */,
|
||||
8390116A214E20B2004CA790 /* JYAddressPicker.m */,
|
||||
);
|
||||
path = JYAddressPicker;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
83928FFB2134F37D0077D2E8 /* SocketRocketUtility */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -1230,6 +1343,7 @@
|
||||
838388C4212F934400D14C53 /* pomodoSound.m4a in Resources */,
|
||||
83BFAE78213CDE91004EF801 /* GiGaSettingsViewCell.xib in Resources */,
|
||||
83346AC1212BB50A0054D597 /* PassWordResetVC.xib in Resources */,
|
||||
8390117C214E20B2004CA790 /* citys.json in Resources */,
|
||||
83BDC0592147B89900E74E0D /* GiGaAnswerViewCell.xib in Resources */,
|
||||
83346AD1212BF5B70054D597 /* useragreement.html in Resources */,
|
||||
838762D9214B9EF80039D241 /* GIGaUserIDViewCell.xib in Resources */,
|
||||
@@ -1357,33 +1471,46 @@
|
||||
8361B3CE212155C200238FEB /* ViewController.m in Sources */,
|
||||
8361B4382121847600238FEB /* UINavigationBar+Custom.m in Sources */,
|
||||
83BFAE6C213CD0E3004EF801 /* GiGaMineInfoViewCell.m in Sources */,
|
||||
8390116B214E20B2004CA790 /* LYSDateContentView.m in Sources */,
|
||||
83BC8A872148BE8A00820437 /* NYPopover.m in Sources */,
|
||||
83901176214E20B2004CA790 /* LYSDatePickerTypeDayDelegate.m in Sources */,
|
||||
8384643E214A484400F12B33 /* MaskTestResult.m in Sources */,
|
||||
83346AD4212BFF6E0054D597 /* UserGuardViewController.m in Sources */,
|
||||
83BC8A8A2148D28300820437 /* QustionAnswer.m in Sources */,
|
||||
8357ADC92123BFCA000816F2 /* GiGaUserManager.m in Sources */,
|
||||
8390116F214E20B2004CA790 /* LYSDatePickerViewController.m in Sources */,
|
||||
83835BB3212E50ED001480F2 /* ActiveMesagelistVC.m in Sources */,
|
||||
83835BC3212E677C001480F2 /* GiGaQuestionVC.m in Sources */,
|
||||
83A2271F212AC8C100B3E75C /* GiGaUserLoginVC.m in Sources */,
|
||||
83901177214E20B2004CA790 /* LYSDatePickerTypeTimeDelegate.m in Sources */,
|
||||
83346ACE212BD7830054D597 /* GiGaWebViewController.m in Sources */,
|
||||
8357ADD82124027D000816F2 /* GiGaUserDefault.m in Sources */,
|
||||
83835BB6212E5174001480F2 /* GiGaServiceViewController.m in Sources */,
|
||||
8390116E214E20B2004CA790 /* LYSDateLogicViewController.m in Sources */,
|
||||
8361B40721215E6F00238FEB /* GiGaHelper.m in Sources */,
|
||||
83901175214E20B2004CA790 /* LYSDatePickerManager.m in Sources */,
|
||||
83901173214E20B2004CA790 /* LYSDateBasicViewController.m in Sources */,
|
||||
8392900F2134FA0A0077D2E8 /* GiGaCommentModel.m in Sources */,
|
||||
8390116C214E20B2004CA790 /* LYSDatePopViewController.m in Sources */,
|
||||
83835BA0212E43BD001480F2 /* GiGaMasssagesVC.m in Sources */,
|
||||
8357ADCD2123C091000816F2 /* GiGaNetManager.m in Sources */,
|
||||
838388D4212FB7D700D14C53 /* JXTAlertView.m in Sources */,
|
||||
83901178214E20B2004CA790 /* LYSDatePickerItem.m in Sources */,
|
||||
83773FC221479FED0014EE4C /* UIColor+HexColor.m in Sources */,
|
||||
83901172214E20B2004CA790 /* LYSDatePickerTypeDayAndTimeDelegate.m in Sources */,
|
||||
835060A9212D38EE007E6220 /* GiGaStartAdView.m in Sources */,
|
||||
83928FFA2134D8F60077D2E8 /* GiGaFlyingCommitInputView.m in Sources */,
|
||||
8390116D214E20B2004CA790 /* LYSDateBaseViewController.m in Sources */,
|
||||
838388D3212FB7D700D14C53 /* JXTAlertController.m in Sources */,
|
||||
833DA7762122A62000A5C614 /* GiGaMaskTaskViewController.m in Sources */,
|
||||
836EE5D7213645E300F0ABB2 /* GiGaBaseAPiRequest.m in Sources */,
|
||||
83773FBC214769230014EE4C /* ExercisesModel.m in Sources */,
|
||||
83835BD0212E8B9C001480F2 /* GiGaQuestionModel.m in Sources */,
|
||||
83835BAF212E4FCD001480F2 /* MessageListViewCell.m in Sources */,
|
||||
8390117D214E20B2004CA790 /* JYAddressPicker.m in Sources */,
|
||||
8361B3D9212155C300238FEB /* main.m in Sources */,
|
||||
83773FBF214791E10014EE4C /* GIGaQuestionSlider.m in Sources */,
|
||||
83901179214E20B2004CA790 /* LYSDatePickerTypeBase.m in Sources */,
|
||||
835060A2212D1225007E6220 /* GiGaMeViewController.m in Sources */,
|
||||
8361B3CB212155C200238FEB /* AppDelegate.m in Sources */,
|
||||
838388C8212F9C4200D14C53 /* GiGaLocalNotificationManager.m in Sources */,
|
||||
@@ -1406,11 +1533,15 @@
|
||||
83BFAE67213CCF10004EF801 /* GiGaMineUserViewCell.m in Sources */,
|
||||
8392900C2134F9F80077D2E8 /* GiGaCommentView.m in Sources */,
|
||||
839290062134F4240077D2E8 /* LXDanMuManager.m in Sources */,
|
||||
83901171214E20B2004CA790 /* LYSDatePickerLabel.m in Sources */,
|
||||
838762E2214B9F580039D241 /* GiGaUserSexViewCell.m in Sources */,
|
||||
839290052134F4240077D2E8 /* LXDanMuTrackView.m in Sources */,
|
||||
83E40B2F21218BA0008149C4 /* GiGaUserViewController.m in Sources */,
|
||||
83901170214E20B2004CA790 /* LYSDateHeaderViewController.m in Sources */,
|
||||
835060A5212D3536007E6220 /* AppDelegate+GiGaConfig.m in Sources */,
|
||||
83901174214E20B2004CA790 /* LYSDateIndicatorViewController.m in Sources */,
|
||||
83E40B2B21218B6F008149C4 /* GiGaExercisesViewController.m in Sources */,
|
||||
8390117B214E20B2004CA790 /* LYSDatePickerHeaderView.m in Sources */,
|
||||
838762E7214B9FA60039D241 /* GIGaUserCityViewCell.m in Sources */,
|
||||
83BFAE77213CDE91004EF801 /* GiGaSettingsViewCell.m in Sources */,
|
||||
83835BA7212E4748001480F2 /* MAssaageCenterCell.m in Sources */,
|
||||
@@ -1425,6 +1556,7 @@
|
||||
83A22718212ABDFF00B3E75C /* GiGaBlockButton.m in Sources */,
|
||||
83928FFE2134F37D0077D2E8 /* GiGaSocketRocketUtility.m in Sources */,
|
||||
83A2270C212A97ED00B3E75C /* MaskViewBootomWaringView.m in Sources */,
|
||||
8390117A214E20B2004CA790 /* LYSDatePickerController.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
+2
-1
@@ -40,7 +40,8 @@
|
||||
//启动同步用户数据
|
||||
BOOL islogin = [GiGaUserDefault isUserLogin];
|
||||
if (islogin) {
|
||||
[[GiGaUserManager shareUser] synsisUserInfo:nil];
|
||||
|
||||
[[GiGaUserManager shareUser] synsisUserInfo:nil userErrorMsgBlock:nil];
|
||||
}
|
||||
|
||||
return YES;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
|
||||
typedef void (^userDataresponseBlock)(GiGaUser *user);
|
||||
typedef void (^userErrorMsgBlock)(NSDictionary *errorCodemsg);
|
||||
|
||||
@interface GiGaUserManager : NSObject
|
||||
|
||||
@@ -26,6 +27,6 @@ typedef void (^userDataresponseBlock)(GiGaUser *user);
|
||||
*/
|
||||
//-(void)detectionUserUpgrade;
|
||||
|
||||
-(void)synsisUserInfo:(userDataresponseBlock)block;
|
||||
-(void)synsisUserInfo:(userDataresponseBlock)block userErrorMsgBlock:(userErrorMsgBlock)errorCodeMsg;
|
||||
|
||||
@end
|
||||
|
||||
@@ -49,9 +49,9 @@ const static NSInteger GIGADB_USER_VER = 0;//当前数据库版本号
|
||||
}
|
||||
|
||||
//登录成功后请求用户数据
|
||||
-(void)synsisUserInfo:(userDataresponseBlock)block{
|
||||
-(void)synsisUserInfo:(userDataresponseBlock)block userErrorMsgBlock:(userErrorMsgBlock)errorCodeMsg{
|
||||
|
||||
GiGaBaseAPiRequest *requst = [GiGaBaseAPiRequest initWithRequestPath:@"user/v1/info" method:RequestPostMethod parms:nil];
|
||||
GiGaBaseAPiRequest *requst = [GiGaBaseAPiRequest initWithRequestPath:kApiUserInfo method:RequestPostMethod parms:nil];
|
||||
weakify(self);
|
||||
[requst requstDataWithResult:^(GiGaAPIResult *result) {
|
||||
|
||||
@@ -61,11 +61,14 @@ const static NSInteger GIGADB_USER_VER = 0;//当前数据库版本号
|
||||
GiGaUser *user = [[GiGaUser alloc] initWithDictionary:userDic error:nil];
|
||||
self.user = user;
|
||||
[weakSelf saveUser:user];
|
||||
|
||||
if (block) {
|
||||
block(user);
|
||||
}
|
||||
NSLog(@"user dic ***\n%@",result.dic);
|
||||
}else{
|
||||
if (errorCodeMsg) {
|
||||
errorCodeMsg(requst.resultDict);
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// JYAddressPicker.h
|
||||
// LakalaClient
|
||||
//
|
||||
// Created by flying on 2018/8/17.
|
||||
// Copyright © 2018年 LR. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
typedef void (^SelectedItemBlock)(NSArray *addressArr);
|
||||
|
||||
@interface JYAddressPicker : UIViewController
|
||||
|
||||
+(JYAddressPicker *)jy_showAt:(UIViewController *)vc;
|
||||
+(JYAddressPicker *)jy_showAt:(UIViewController *)vc defaultShow:(NSArray *)values;
|
||||
@property (nonatomic, copy) SelectedItemBlock selectedItemBlock;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,241 @@
|
||||
//
|
||||
// JYAddressPicker.m
|
||||
// LakalaClient
|
||||
//
|
||||
// Created by flying on 2018/8/17.
|
||||
// Copyright © 2018年 LR. All rights reserved.
|
||||
//
|
||||
|
||||
#import "JYAddressPicker.h"
|
||||
|
||||
#define PickerHeight 180
|
||||
#define PickerToolBarHeight 44
|
||||
|
||||
@interface JYAddressPicker ()<UIPickerViewDelegate,UIPickerViewDataSource>
|
||||
|
||||
//picker控件数据源
|
||||
@property(nonatomic,strong)NSMutableArray *showAddressArr;
|
||||
//picker控件默认展示的元素下标
|
||||
@property(nonatomic,strong)NSMutableArray *showIndexs;
|
||||
|
||||
@property (nonatomic, strong) UIView *pickerContainerView;
|
||||
@property (nonatomic, strong) UIPickerView *pickerView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation JYAddressPicker
|
||||
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
self.view.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.4];
|
||||
|
||||
[self initUI];
|
||||
|
||||
for (NSInteger index = 0; index < [self.showIndexs count]; index ++) {
|
||||
|
||||
[self.pickerView selectRow:[[self.showIndexs objectAtIndex:index] integerValue] inComponent:index animated:NO];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)initUI{
|
||||
|
||||
self.pickerContainerView = [[UIView alloc] initWithFrame:CGRectMake(0, [UIScreen mainScreen].bounds.size.height - (PickerHeight + PickerToolBarHeight), [UIScreen mainScreen].bounds.size.width, PickerHeight + PickerToolBarHeight)];
|
||||
|
||||
UIToolbar *toolBar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, PickerToolBarHeight)];
|
||||
toolBar.barTintColor = [UIColor whiteColor];
|
||||
|
||||
UIBarButtonItem *noSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
|
||||
noSpace.width=10;
|
||||
|
||||
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(done:)];;
|
||||
doneBtn.tintColor = [UIColor grayColor];
|
||||
|
||||
UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(cancel:)];
|
||||
cancelBtn.tintColor = [UIColor grayColor];
|
||||
|
||||
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
|
||||
[toolBar setItems:[NSArray arrayWithObjects:noSpace,cancelBtn,flexSpace,doneBtn,noSpace, nil]];
|
||||
UILabel *titleLabel = [UILabel new];
|
||||
titleLabel.frame = CGRectMake(0, 0, 200, PickerToolBarHeight);
|
||||
titleLabel.center = toolBar.center;
|
||||
titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
titleLabel.textColor = [UIColor darkTextColor];
|
||||
titleLabel.text = @"省市区选择";
|
||||
[toolBar addSubview:titleLabel];
|
||||
|
||||
self.pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, PickerToolBarHeight, [UIScreen mainScreen].bounds.size.width, PickerHeight)];
|
||||
self.pickerView.dataSource = self;
|
||||
self.pickerView.delegate = self;
|
||||
self.pickerView.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
[self.pickerContainerView addSubview:toolBar];
|
||||
[self.pickerContainerView addSubview:self.pickerView];
|
||||
[self.view addSubview:self.pickerContainerView];
|
||||
}
|
||||
|
||||
#pragma mark-- UIPickerViewDataSource
|
||||
//列数
|
||||
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
|
||||
{
|
||||
return [self.showIndexs count];
|
||||
}
|
||||
|
||||
//每列个数
|
||||
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
|
||||
{
|
||||
return [[self.showAddressArr objectAtIndex:component] count];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark-- UIPickerViewDelegate
|
||||
-(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
|
||||
{
|
||||
UILabel *label = (id)view;
|
||||
if (!label)
|
||||
{
|
||||
label= [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [pickerView rowSizeForComponent:component].width, [pickerView rowSizeForComponent:component].height)];
|
||||
label.textAlignment = NSTextAlignmentCenter;
|
||||
label.textColor = [UIColor blackColor];
|
||||
NSDictionary *dic = [[self.showAddressArr objectAtIndex:component] objectAtIndex:row];
|
||||
label.text = dic[@"text"];
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
//点击选择
|
||||
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
|
||||
{
|
||||
NSArray *columnItems = [self.showAddressArr objectAtIndex:component];
|
||||
NSDictionary *selectedItem = [columnItems objectAtIndex:row];
|
||||
|
||||
if ([selectedItem[@"childrens"] count] == 0) {
|
||||
//此时为最后一列可能就一列或多列的最后一列
|
||||
[self.showIndexs replaceObjectAtIndex:component withObject:@(row)];
|
||||
}else{
|
||||
|
||||
NSUInteger replaceIdx = component;
|
||||
BOOL next = true;
|
||||
while (next) {
|
||||
if (component == replaceIdx) {
|
||||
[self.showIndexs replaceObjectAtIndex:replaceIdx withObject:@(row)];
|
||||
}else{
|
||||
|
||||
if (replaceIdx < [self.showIndexs count]) {
|
||||
|
||||
[self.showAddressArr replaceObjectAtIndex:replaceIdx withObject:selectedItem[@"childrens"]];
|
||||
[self.showIndexs replaceObjectAtIndex:replaceIdx withObject:@(0)];
|
||||
selectedItem = [selectedItem[@"childrens"] firstObject];
|
||||
}else{
|
||||
next = false;
|
||||
}
|
||||
}
|
||||
|
||||
replaceIdx ++;
|
||||
}
|
||||
|
||||
}
|
||||
[pickerView reloadAllComponents];
|
||||
//实时更新选择数据及联数据
|
||||
for (NSInteger index = 0; index < [self.showIndexs count]; index ++) {
|
||||
|
||||
[self.pickerView selectRow:[[self.showIndexs objectAtIndex:index] integerValue] inComponent:index animated:NO];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-(instancetype)initWith:(NSArray *)defaultValues{
|
||||
|
||||
if (self = [super init]) {
|
||||
self.modalPresentationStyle = UIModalPresentationOverCurrentContext;
|
||||
|
||||
self.showIndexs = [NSMutableArray array];
|
||||
self.showAddressArr = [NSMutableArray array];
|
||||
//加载本地json数据
|
||||
NSString *jsonPath = [[NSBundle mainBundle] pathForResource:@"citys" ofType:@"json"];
|
||||
NSData *data = [[NSData alloc] initWithContentsOfFile:jsonPath];
|
||||
NSError *error = nil;
|
||||
NSArray *citysArr = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
|
||||
//初始化源数据
|
||||
[self defaultShowValue:[NSMutableArray arrayWithArray:defaultValues] items:citysArr];
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+(JYAddressPicker *)jy_showAt:(UIViewController *)vc{
|
||||
|
||||
JYAddressPicker *addressPicker = [[JYAddressPicker alloc] initWith:@[@"",@"",@""]];
|
||||
[vc presentViewController:addressPicker animated:YES completion:^{
|
||||
|
||||
}];
|
||||
return addressPicker;
|
||||
}
|
||||
|
||||
+(JYAddressPicker *)jy_showAt:(UIViewController *)vc defaultShow:(NSArray *)values{
|
||||
|
||||
NSParameterAssert(values);
|
||||
JYAddressPicker *addressPicker = [[JYAddressPicker alloc] initWith:values];
|
||||
[vc presentViewController:addressPicker animated:YES completion:^{
|
||||
|
||||
}];
|
||||
return addressPicker;
|
||||
}
|
||||
|
||||
-(void)defaultShowValue:(NSMutableArray *)values items:(NSArray *)items
|
||||
{
|
||||
[items enumerateObjectsUsingBlock:^(NSDictionary *obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
if ([@"" isEqualToString:[values firstObject]])
|
||||
{
|
||||
//values中没有默认值的时候values中的元素目前为@""空字符
|
||||
[self.showIndexs addObject:@(0)];
|
||||
[values removeObjectAtIndex:0];
|
||||
[self.showAddressArr addObject:items];
|
||||
[self defaultShowValue:values items:obj[@"childrens"]];
|
||||
|
||||
}
|
||||
else if ([obj[@"text"] isEqualToString:[values firstObject]])
|
||||
{
|
||||
[self.showIndexs addObject:@(idx)];
|
||||
[values removeObjectAtIndex:0];
|
||||
[self.showAddressArr addObject:items];
|
||||
[self defaultShowValue:values items:obj[@"childrens"]];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark--确定
|
||||
-(void)done:(id)sender{
|
||||
|
||||
if (self.selectedItemBlock) {
|
||||
NSMutableArray *resultArr = [NSMutableArray array];
|
||||
[self.showAddressArr enumerateObjectsUsingBlock:^(NSArray *objArr, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
|
||||
NSDictionary *selectedItem = [objArr objectAtIndex:[[self.showIndexs objectAtIndex:idx] integerValue]];
|
||||
[resultArr addObject:selectedItem];
|
||||
}];
|
||||
self.selectedItemBlock(resultArr);
|
||||
}
|
||||
[self hide];
|
||||
}
|
||||
|
||||
#pragma mark--取消
|
||||
-(void)cancel:(id)sender{
|
||||
|
||||
[self hide];
|
||||
}
|
||||
|
||||
-(void)hide{
|
||||
|
||||
[self dismissViewControllerAnimated:YES completion:^{
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// LYSDateBaseViewController.h
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/5.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDateBasicViewController.h"
|
||||
#import "LYSDatePickerSelectDelegate.h"
|
||||
|
||||
extern NSString *const LYSDatePickerWillAppearNotifition; // 窗口将要出现
|
||||
extern NSString *const LYSDatePickerDidAppearNotifition; // 窗口已经出现
|
||||
extern NSString *const LYSDatePickerWillDisAppearNotifition; // 窗口将要消失
|
||||
extern NSString *const LYSDatePickerDidDisAppearNotifition; // 窗口已经消失
|
||||
|
||||
extern NSString *const LYSDatePickerDidCancelNotifition; // 取消弹窗
|
||||
extern NSString *const LYSDatePickerDidSelectDateNotifition; // 提交日期
|
||||
|
||||
@interface LYSDateBaseViewController : LYSDateBasicViewController
|
||||
|
||||
// 监听代理
|
||||
@property(nonatomic, assign)id<LYSDatePickerSelectDelegate> delegate;
|
||||
|
||||
// 提交日期选择器
|
||||
@property(nonatomic, copy)void(^didSelectDatePicker)(NSDate *date);
|
||||
|
||||
// 获取选择日期
|
||||
@property(nonatomic, strong)NSDate *date;
|
||||
|
||||
// 提交日期
|
||||
- (void)commitDatePicker;
|
||||
|
||||
// 取消弹窗
|
||||
- (void)cancelDatePicker;
|
||||
|
||||
// 创建单例
|
||||
+ (instancetype)shareInstance;
|
||||
|
||||
// 释放单例
|
||||
+ (void)shareRelease;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// LYSDateBaseViewController.m
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/5.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDateBaseViewController.h"
|
||||
|
||||
NSString *const LYSDatePickerWillAppearNotifition = @"LYSDatePickerWillAppearNotifition";
|
||||
NSString *const LYSDatePickerDidAppearNotifition = @"LYSDatePickerDidAppearNotifition";
|
||||
NSString *const LYSDatePickerWillDisAppearNotifition = @"LYSDatePickerWillDisAppearNotifition";
|
||||
NSString *const LYSDatePickerDidDisAppearNotifition = @"LYSDatePickerDidDisAppearNotifition";
|
||||
|
||||
NSString *const LYSDatePickerDidCancelNotifition = @"LYSDatePickerDidCancelNotifition";
|
||||
NSString *const LYSDatePickerDidSelectDateNotifition = @"LYSDatePickerDidSelectDateNotifition";
|
||||
|
||||
@interface LYSDateBaseViewController ()
|
||||
|
||||
@end
|
||||
|
||||
static id datePicker = nil;
|
||||
|
||||
@implementation LYSDateBaseViewController
|
||||
|
||||
+ (instancetype)shareInstance
|
||||
{
|
||||
if (!datePicker) {
|
||||
datePicker = [[[self class] alloc] init];
|
||||
}
|
||||
return datePicker;
|
||||
}
|
||||
|
||||
+ (void)shareRelease
|
||||
{
|
||||
datePicker = nil;
|
||||
}
|
||||
|
||||
- (void)commitDatePicker
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:LYSDatePickerDidSelectDateNotifition
|
||||
object:nil
|
||||
userInfo:@{@"date":self.date}];
|
||||
if (self.didSelectDatePicker)
|
||||
{
|
||||
self.didSelectDatePicker(self.date);
|
||||
}
|
||||
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(pickerViewController:didSelectDate:)])
|
||||
{
|
||||
[self.delegate pickerViewController:(LYSDatePickerController *)self didSelectDate:self.date];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)cancelDatePicker {
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(pickerViewControllerDidCancel:)]) {
|
||||
[self.delegate pickerViewControllerDidCancel:(LYSDatePickerController *)self];
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:LYSDatePickerDidCancelNotifition object:nil];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// LYSDateBasicViewController.h
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/7.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface LYSDateBasicViewController : UIViewController
|
||||
// 获取最外层控制器
|
||||
+ (UIViewController *)windowRootViewController;
|
||||
// 创建给定颜色和透明度的图片
|
||||
- (UIImage *)imageWithColor:(UIColor *)color alpha:(CGFloat)alpha;
|
||||
@end
|
||||
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// LYSDateBasicViewController.m
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/7.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDateBasicViewController.h"
|
||||
|
||||
@interface LYSDateBasicViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation LYSDateBasicViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
// 获取最外层控制器
|
||||
+ (UIViewController *)windowRootViewController
|
||||
{
|
||||
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
|
||||
return keyWindow.rootViewController;
|
||||
}
|
||||
// 创建给定颜色和透明度的图片
|
||||
- (UIImage *)imageWithColor:(UIColor *)color alpha:(CGFloat)alpha
|
||||
{
|
||||
// 创建一个color对象
|
||||
UIColor *tempColor = [color colorWithAlphaComponent:alpha];
|
||||
// 声明一个绘制大小
|
||||
CGSize colorSize = CGSizeMake(1, 1);
|
||||
UIGraphicsBeginImageContext(colorSize);
|
||||
// 开始绘制颜色区域
|
||||
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||
// 根据提供的颜色给相应绘制内容填充
|
||||
CGContextSetFillColorWithColor(context, tempColor.CGColor);
|
||||
// 设置填充相应的区域
|
||||
CGContextFillRect(context, CGRectMake(0, 0, 1, 1));
|
||||
// 声明UIImage对象
|
||||
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
return img;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// LYSDateContentView.h
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/5.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface LYSDateContentView : UIView
|
||||
// 刷新视图高度
|
||||
- (void)refreshContentHeight;
|
||||
@end
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// LYSDateContentView.m
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/5.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDateContentView.h"
|
||||
|
||||
@implementation LYSDateContentView
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.frame = CGRectMake(0, CGRectGetHeight([UIScreen mainScreen].bounds), CGRectGetWidth([UIScreen mainScreen].bounds), 0);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)refreshContentHeight
|
||||
{
|
||||
CGFloat height = 0;
|
||||
for (UIView *view in self.subviews) {
|
||||
height += CGRectGetHeight(view.frame);
|
||||
}
|
||||
CGRect contentFrame = self.frame;
|
||||
contentFrame.size.height = height;
|
||||
self.frame = contentFrame;
|
||||
}
|
||||
|
||||
// 禁止事件向下传递
|
||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// LYSDateHeaderViewController.h
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/5.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDatePopViewController.h"
|
||||
#import "LYSDatePickerHeaderView.h"
|
||||
|
||||
@interface LYSDateHeaderViewController : LYSDatePopViewController
|
||||
// 头视图高度,只有当headerView是默认创建的时候,才有效
|
||||
@property (nonatomic,assign)CGFloat pickHeaderHeight;
|
||||
// 选择器头视图,可以自定义
|
||||
@property (nonatomic,strong)LYSDatePickerHeaderView *headerView;
|
||||
@end
|
||||
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// LYSDateHeaderViewController.m
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/5.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDateHeaderViewController.h"
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#define Rect(x,y,w,h) CGRectMake(x, y, w, h)
|
||||
#define ScreenWidth CGRectGetWidth([UIScreen mainScreen].bounds)
|
||||
#define ScreenHeight CGRectGetHeight([UIScreen mainScreen].bounds)
|
||||
|
||||
@interface LYSDateHeaderViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation LYSDateHeaderViewController
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.pickHeaderHeight = 40;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
// 初始化头视图
|
||||
[self initHeaderView];
|
||||
}
|
||||
|
||||
- (LYSDatePickerHeaderView *)headerView
|
||||
{
|
||||
if (!_headerView) {
|
||||
_headerView = [[LYSDatePickerHeaderView alloc] init];
|
||||
objc_setAssociatedObject(_headerView, @"tag", @(YES), OBJC_ASSOCIATION_ASSIGN);
|
||||
_headerView.backgroundColor = [UIColor whiteColor];
|
||||
}
|
||||
return _headerView;
|
||||
}
|
||||
|
||||
// 初始化头视图
|
||||
- (void)initHeaderView
|
||||
{
|
||||
id tag = objc_getAssociatedObject(self.headerView, @"tag");
|
||||
if (tag && [tag boolValue]) {
|
||||
CGFloat headerViewHeight = self.pickHeaderHeight;
|
||||
self.headerView.frame = Rect(0, 0, ScreenWidth, headerViewHeight);
|
||||
self.headerView.headerHeight = headerViewHeight;
|
||||
self.headerView.headerVC = self;
|
||||
[self.contentView addSubview:self.headerView];
|
||||
} else {
|
||||
CGRect headerFrame = self.headerView.frame;
|
||||
headerFrame.origin = CGPointZero;
|
||||
headerFrame.size.width = ScreenWidth;
|
||||
self.headerView.frame = headerFrame;
|
||||
[self.contentView addSubview:self.headerView];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// LYSDateIndicatorViewController.h
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/5.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDateHeaderViewController.h"
|
||||
|
||||
@interface LYSDateIndicatorViewController : LYSDateHeaderViewController
|
||||
// 是否显示分割线
|
||||
@property (nonatomic,assign)BOOL showIndicator;
|
||||
// 分割线颜色
|
||||
@property (nonatomic,strong)UIColor *indicatorColor;
|
||||
// 分割线高度
|
||||
@property(nonatomic, assign)CGFloat indicatorHeight;
|
||||
@end
|
||||
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// LYSDateIndicatorViewController.m
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/5.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDateIndicatorViewController.h"
|
||||
|
||||
#define Rect(x,y,w,h) CGRectMake(x, y, w, h)
|
||||
#define ScreenWidth CGRectGetWidth([UIScreen mainScreen].bounds)
|
||||
#define ScreenHeight CGRectGetHeight([UIScreen mainScreen].bounds)
|
||||
|
||||
@interface LYSDateIndicatorViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation LYSDateIndicatorViewController
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
// 默认显示分割线
|
||||
self.showIndicator = YES;
|
||||
// 分割线默认颜色
|
||||
self.indicatorColor = [UIColor colorWithRed:238/255.0 green:238/255.0 blue:238/255.0 alpha:1];
|
||||
// 分割线高度
|
||||
self.indicatorHeight = 5;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
// 设置分割线
|
||||
[self initIndicator];
|
||||
}
|
||||
|
||||
// 初始化分割线
|
||||
- (void)initIndicator
|
||||
{
|
||||
if (self.showIndicator) {
|
||||
CGFloat headerViewHeight = CGRectGetHeight(self.headerView.frame);
|
||||
UIImage *line = [self imageWithColor:self.indicatorColor alpha:1];
|
||||
UIImageView *lineView = [[UIImageView alloc] initWithImage:line];
|
||||
lineView.frame = Rect(0, headerViewHeight, ScreenWidth, self.indicatorHeight);
|
||||
[self.contentView addSubview:lineView];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// LYSDateLogicViewController.h
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/5.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDatePickerViewController.h"
|
||||
#import "LYSDatePickerTypeDayAndTimeDelegate.h"
|
||||
#import "LYSDatePickerTypeDayDelegate.h"
|
||||
#import "LYSDatePickerTypeTimeDelegate.h"
|
||||
|
||||
typedef enum : NSUInteger {
|
||||
LYSDatePickerTypeDay, // 年月日
|
||||
LYSDatePickerTypeDayAndTime, // 年月日,时分
|
||||
LYSDatePickerTypeTime, // 时分
|
||||
} LYSDatePickerType;
|
||||
|
||||
@interface LYSDateLogicViewController : LYSDatePickerViewController
|
||||
|
||||
// 选择器itemLabel,可以通过此属性对选择器设置字体大小和颜色,背景色以及对其方式
|
||||
@property (nonatomic,strong,readonly)UILabel *subLabel;
|
||||
// 日期开始时间
|
||||
@property (nonatomic,assign)int fromYear;
|
||||
// 日期结束时间
|
||||
@property (nonatomic,assign)int toYear;
|
||||
// 默认选中日期
|
||||
@property (nonatomic,strong)NSDate *selectDate;
|
||||
// 选择器类型
|
||||
@property (nonatomic,assign)LYSDatePickerType pickType;
|
||||
|
||||
// 是否对某一粒度进行无限循环,默认是NO
|
||||
@property(nonatomic, assign)BOOL yearLoop;
|
||||
@property(nonatomic, assign)BOOL monthLoop;
|
||||
@property(nonatomic, assign)BOOL dayLoop;
|
||||
@property(nonatomic, assign)BOOL hourLoop;
|
||||
@property(nonatomic, assign)BOOL minuteLoop;
|
||||
|
||||
// 是否显示星期几
|
||||
@property(nonatomic, assign)BOOL showWeakDay;
|
||||
// 星期显示类型
|
||||
@property(nonatomic, assign)LYSDatePickerWeakDayType weakDayType;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,119 @@
|
||||
//
|
||||
// LYSDateLogicViewController.m
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/5.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDateLogicViewController.h"
|
||||
|
||||
#define IS5SBOOL CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(320, 568))
|
||||
#define IS6SBOOL CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(375, 667))
|
||||
#define IS6SPBOOL CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(414, 736))
|
||||
#define ISXBOOL CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(375, 812))
|
||||
|
||||
#define FontRank(A,B,C,D,E) (IS5SBOOL ? A : (IS6SBOOL ? B : (IS6SPBOOL ? C : (ISXBOOL ? D : E))))
|
||||
|
||||
@interface LYSDateLogicViewController ()
|
||||
|
||||
@property (nonatomic,strong,readwrite)UILabel *subLabel; // 选择器itemLabel
|
||||
@property (nonatomic,strong)LYSDatePickerTypeBase *typeBase; // 默认选择类型
|
||||
|
||||
@end
|
||||
|
||||
@implementation LYSDateLogicViewController
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.fromYear = 1970; // 默认开始年份
|
||||
self.toYear = 2070; // 默认结束年份
|
||||
self.pickType = LYSDatePickerTypeDayAndTime; // 默认选择器类型
|
||||
self.selectDate = [NSDate date]; // 默认选中日期
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
// 初始化选择器类型
|
||||
[self initPickerType];
|
||||
|
||||
// 设置默认日期
|
||||
[self.typeBase defaultWithDate:self.selectDate];
|
||||
[self.typeBase updateDatePicker];
|
||||
}
|
||||
|
||||
- (UILabel *)subLabel
|
||||
{
|
||||
if (!_subLabel) {
|
||||
_subLabel = [[UILabel alloc] init];
|
||||
_subLabel = [[UILabel alloc] init];
|
||||
_subLabel.textAlignment = NSTextAlignmentCenter;
|
||||
_subLabel.textColor = [UIColor blackColor];
|
||||
_subLabel.font = [UIFont systemFontOfSize:FontRank(14,16,16,16,16)];
|
||||
#ifdef DEBUG
|
||||
// _subLabel.backgroundColor = [UIColor redColor];
|
||||
#endif
|
||||
}
|
||||
return _subLabel;
|
||||
}
|
||||
|
||||
// 初始化选择器类型
|
||||
- (void)initPickerType {
|
||||
|
||||
switch (self.pickType) {
|
||||
case LYSDatePickerTypeDayAndTime:
|
||||
{
|
||||
self.typeBase = [[LYSDatePickerTypeDayAndTimeDelegate alloc] initWithPickerView:self.pickView];
|
||||
}
|
||||
break;
|
||||
case LYSDatePickerTypeDay:
|
||||
{
|
||||
self.typeBase = [[LYSDatePickerTypeDayDelegate alloc] initWithPickerView:self.pickView];
|
||||
}
|
||||
break;
|
||||
case LYSDatePickerTypeTime:
|
||||
{
|
||||
self.typeBase = [[LYSDatePickerTypeTimeDelegate alloc] initWithPickerView:self.pickView];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
self.typeBase.fromYear = self.fromYear;
|
||||
self.typeBase.toYear = self.toYear;
|
||||
self.typeBase.titleLabel = self.subLabel;
|
||||
|
||||
self.typeBase.yearLoop = self.yearLoop;
|
||||
self.typeBase.monthLoop = self.monthLoop;
|
||||
self.typeBase.dayLoop = self.dayLoop;
|
||||
self.typeBase.hourLoop = self.hourLoop;
|
||||
self.typeBase.minuteLoop = self.minuteLoop;
|
||||
|
||||
self.typeBase.showWeakDay = self.showWeakDay;
|
||||
self.typeBase.weakDayType = self.weakDayType;
|
||||
|
||||
self.pickView.delegate = self.typeBase;
|
||||
self.pickView.dataSource = self.typeBase;
|
||||
|
||||
__weak LYSDateLogicViewController *weakSelf = self;
|
||||
[self.typeBase setDidSelectItem:^(NSDate *date) {
|
||||
weakSelf.date = date;
|
||||
if ([weakSelf.headerView respondsToSelector:@selector(updateDate:)]) {
|
||||
[weakSelf.headerView updateDate:date];
|
||||
}
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// LYSDatePickerController.h
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/2.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDateLogicViewController.h"
|
||||
#import "LYSDatePickerSelectDelegate.h"
|
||||
|
||||
@interface LYSDatePickerController : LYSDateLogicViewController
|
||||
|
||||
// 设置视图高度
|
||||
+ (void)customPickerViewHeight:(CGFloat)height;
|
||||
// 设置开始年份
|
||||
+ (void)customFromYear:(int)fromYear;
|
||||
// 设置结束年份
|
||||
+ (void)customToYear:(int)toYear;
|
||||
// 设置默认选中日期
|
||||
+ (void)customSelectDate:(NSDate *)date;
|
||||
// 设置弹出类型
|
||||
+ (void)customPickerType:(LYSDatePickerType)type;
|
||||
// 设置代理
|
||||
+ (void)customPickerDelegate:(id<LYSDatePickerSelectDelegate>)delegate;
|
||||
// 监听日期选择回调
|
||||
+ (void)customdidSelectDatePicker:(void(^)(NSDate *date))didSelectDatePicker;
|
||||
// 点击页面空白部分是否隐藏日期选择器
|
||||
+ (void)customClickOuterHiddenEnable:(BOOL)clickOuterHiddenEnable;
|
||||
// 设置头视图高度
|
||||
+ (void)customPickHeaderHeight:(CGFloat)pickHeaderHeight;
|
||||
// 自定义头视图
|
||||
+ (void)customHeaderView:(LYSDatePickerHeaderView *)headerView;
|
||||
// 设置是否显示分割线
|
||||
+ (void)customShowIndicator:(BOOL)showIndicator;
|
||||
// 设置分割线颜色
|
||||
+ (void)customIndicatorColor:(UIColor *)indicatorColor;
|
||||
// 设置分割线高度
|
||||
+ (void)customIndicatorHeight:(CGFloat)indicatorHeight;
|
||||
// 设置是否显示星期几
|
||||
+ (void)customShowWeakDay:(BOOL)showWeakDay;
|
||||
// 设置是星期类型
|
||||
+ (void)customWeakDayType:(BOOL)weakDayType;
|
||||
|
||||
// 弹出日期选择器,此方法没有设置类型和默认选中日期
|
||||
+ (void)alertDatePickerInWindowRootVC;
|
||||
+ (void)alertDatePickerWithController:(UIViewController *)controller;
|
||||
|
||||
// 弹出日期选择器,附带类型,日期为当前时间
|
||||
+ (void)alertDatePickerInWindowRootVCWithType:(LYSDatePickerType)pickerType;
|
||||
+ (void)alertDatePickerWithController:(UIViewController *)controller type:(LYSDatePickerType)pickerType;
|
||||
|
||||
// 弹出日期选择器,附带类型和默认选中日期
|
||||
+ (void)alertDatePickerInWindowRootVCWithType:(LYSDatePickerType)pickerType selectDate:(NSDate *)selectDate;
|
||||
+ (void)alertDatePickerWithController:(UIViewController *)controller type:(LYSDatePickerType)pickerType selectDate:(NSDate *)selectDate;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,176 @@
|
||||
//
|
||||
// LYSDatePickerController.m
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/2.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDatePickerController.h"
|
||||
|
||||
#define Rect(x,y,w,h) CGRectMake(x, y, w, h)
|
||||
#define ScreenWidth CGRectGetWidth([UIScreen mainScreen].bounds)
|
||||
#define ScreenHeight CGRectGetHeight([UIScreen mainScreen].bounds)
|
||||
|
||||
@interface LYSDatePickerController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation LYSDatePickerController
|
||||
|
||||
#pragma mark - 设置视图高度 -
|
||||
+ (void)customPickerViewHeight:(CGFloat)height
|
||||
{
|
||||
LYSDatePickerController *datePicker = [LYSDatePickerController shareInstance];
|
||||
datePicker.pickViewHeight = height;
|
||||
}
|
||||
|
||||
#pragma mark - 设置开始年份 -
|
||||
+ (void)customFromYear:(int)fromYear
|
||||
{
|
||||
LYSDatePickerController *datePicker = [LYSDatePickerController shareInstance];
|
||||
datePicker.fromYear = fromYear;
|
||||
}
|
||||
|
||||
#pragma mark - 设置结束年份 -
|
||||
+ (void)customToYear:(int)toYear
|
||||
{
|
||||
LYSDatePickerController *datePicker = [LYSDatePickerController shareInstance];
|
||||
datePicker.toYear = toYear;
|
||||
}
|
||||
|
||||
#pragma mark - 设置默认选中日期 -
|
||||
+ (void)customSelectDate:(NSDate *)date
|
||||
{
|
||||
LYSDatePickerController *datePicker = [LYSDatePickerController shareInstance];
|
||||
datePicker.selectDate = date;
|
||||
}
|
||||
|
||||
#pragma mark - 设置弹出类型 -
|
||||
+ (void)customPickerType:(LYSDatePickerType)type
|
||||
{
|
||||
LYSDatePickerController *datePicker = [LYSDatePickerController shareInstance];
|
||||
datePicker.pickType = type;
|
||||
}
|
||||
#pragma mark - 设置代理 -
|
||||
+ (void)customPickerDelegate:(id<LYSDatePickerSelectDelegate>)delegate {
|
||||
LYSDatePickerController *datePicker = [LYSDatePickerController shareInstance];
|
||||
datePicker.delegate = delegate;
|
||||
}
|
||||
|
||||
#pragma mark - 监听日期选择回调 -
|
||||
+ (void)customdidSelectDatePicker:(void(^)(NSDate *date))didSelectDatePicker {
|
||||
LYSDatePickerController *datePicker = [LYSDatePickerController shareInstance];
|
||||
datePicker.didSelectDatePicker = didSelectDatePicker;
|
||||
}
|
||||
|
||||
#pragma mark - 点击页面空白部分是否隐藏日期选择器 -
|
||||
+ (void)customClickOuterHiddenEnable:(BOOL)clickOuterHiddenEnable {
|
||||
LYSDatePickerController *datePicker = [LYSDatePickerController shareInstance];
|
||||
datePicker.clickOuterHiddenEnable = clickOuterHiddenEnable;
|
||||
}
|
||||
|
||||
#pragma mark - 设置头视图高度 -
|
||||
+ (void)customPickHeaderHeight:(CGFloat)pickHeaderHeight {
|
||||
LYSDatePickerController *datePicker = [LYSDatePickerController shareInstance];
|
||||
datePicker.pickHeaderHeight = pickHeaderHeight;
|
||||
}
|
||||
#pragma mark - 自定义头视图 -
|
||||
+ (void)customHeaderView:(LYSDatePickerHeaderView *)headerView {
|
||||
LYSDatePickerController *datePicker = [LYSDatePickerController shareInstance];
|
||||
datePicker.headerView = headerView;
|
||||
}
|
||||
#pragma mark - 设置是否显示分割线 -
|
||||
+ (void)customShowIndicator:(BOOL)showIndicator {
|
||||
LYSDatePickerController *datePicker = [LYSDatePickerController shareInstance];
|
||||
datePicker.showIndicator = showIndicator;
|
||||
}
|
||||
#pragma mark - 设置分割线颜色 -
|
||||
+ (void)customIndicatorColor:(UIColor *)indicatorColor {
|
||||
LYSDatePickerController *datePicker = [LYSDatePickerController shareInstance];
|
||||
datePicker.indicatorColor = indicatorColor;
|
||||
}
|
||||
#pragma mark - 设置分割线高度 -
|
||||
+ (void)customIndicatorHeight:(CGFloat)indicatorHeight {
|
||||
LYSDatePickerController *datePicker = [LYSDatePickerController shareInstance];
|
||||
datePicker.indicatorHeight = indicatorHeight;
|
||||
}
|
||||
// 设置是否显示星期几
|
||||
+ (void)customShowWeakDay:(BOOL)showWeakDay {
|
||||
LYSDatePickerController *datePicker = [LYSDatePickerController shareInstance];
|
||||
datePicker.showWeakDay = showWeakDay;
|
||||
}
|
||||
// 设置是星期类型
|
||||
+ (void)customWeakDayType:(BOOL)showWeakDay {
|
||||
LYSDatePickerController *datePicker = [LYSDatePickerController shareInstance];
|
||||
datePicker.showWeakDay = showWeakDay;
|
||||
}
|
||||
|
||||
#pragma mark - 弹出日期选择器 -
|
||||
+ (void)alertDatePickerInWindowRootVC
|
||||
{
|
||||
[LYSDatePickerController showDatePickerInWindowRootVC];
|
||||
}
|
||||
|
||||
+ (void)alertDatePickerWithController:(UIViewController *)controller
|
||||
{
|
||||
[LYSDatePickerController showDatePickerWithController:controller];
|
||||
}
|
||||
|
||||
#pragma mark - 弹出日期选择器,附带类型 -
|
||||
+ (void)alertDatePickerInWindowRootVCWithType:(LYSDatePickerType)pickerType
|
||||
{
|
||||
LYSDatePickerController *datePicker = [LYSDatePickerController shareInstance];
|
||||
datePicker.selectDate = [NSDate date];
|
||||
datePicker.pickType = pickerType;
|
||||
[LYSDatePickerController showDatePickerInWindowRootVC];
|
||||
}
|
||||
|
||||
+ (void)alertDatePickerWithController:(UIViewController *)controller type:(LYSDatePickerType)pickerType
|
||||
{
|
||||
LYSDatePickerController *datePicker = [LYSDatePickerController shareInstance];
|
||||
datePicker.selectDate = [NSDate date];
|
||||
datePicker.pickType = pickerType;
|
||||
[LYSDatePickerController showDatePickerWithController:controller];
|
||||
}
|
||||
|
||||
#pragma mark - 弹出日期选择器,附带类型和默认选中日期 -
|
||||
+ (void)alertDatePickerInWindowRootVCWithType:(LYSDatePickerType)pickerType selectDate:(NSDate *)selectDate
|
||||
{
|
||||
LYSDatePickerController *datePicker = [LYSDatePickerController shareInstance];
|
||||
datePicker.selectDate = selectDate;
|
||||
datePicker.pickType = pickerType;
|
||||
[LYSDatePickerController showDatePickerInWindowRootVC];
|
||||
}
|
||||
|
||||
+ (void)alertDatePickerWithController:(UIViewController *)controller type:(LYSDatePickerType)pickerType selectDate:(NSDate *)selectDate
|
||||
{
|
||||
LYSDatePickerController *datePicker = [LYSDatePickerController shareInstance];
|
||||
datePicker.selectDate = selectDate;
|
||||
datePicker.pickType = pickerType;
|
||||
[LYSDatePickerController showDatePickerWithController:controller];;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
if (self.clickOuterHiddenEnable) {
|
||||
[self hiddenDatePicker];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
#ifdef DEBUG
|
||||
NSLog(@"释放");
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// LYSDatePickerHeaderView.h
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/4.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "LYSDatePickerItem.h"
|
||||
|
||||
@class LYSDateHeaderViewController;
|
||||
|
||||
// 如果要自定义头视图,并且要实时获取选择时间,可以让自定义视图遵循这个代理方法即可
|
||||
@protocol LYSDatePickerHeaderViewProtocol <NSObject>
|
||||
|
||||
- (void)updateDate:(NSDate *)date;
|
||||
|
||||
@end
|
||||
|
||||
@interface LYSDatePickerHeaderView : UIView<LYSDatePickerHeaderViewProtocol>
|
||||
|
||||
@property(nonatomic, weak)LYSDateHeaderViewController *headerVC;
|
||||
|
||||
// 头视图左侧按钮,可以自定义
|
||||
@property(nonatomic, strong)LYSDatePickerItem *leftItem;
|
||||
// 头视图右侧按钮,可以自定义
|
||||
@property(nonatomic, strong)LYSDatePickerItem *rightItem;
|
||||
// 头视图中间按钮,可以自定义
|
||||
@property(nonatomic, strong)LYSDatePickerItem *centerItem;
|
||||
|
||||
// 默认是NO,即不实时显示选择时间
|
||||
@property(nonatomic, assign)BOOL showTimeLabel;
|
||||
// 当showTimeLabel为YES时,默认使用这个属性作为中间按钮
|
||||
@property(nonatomic, strong)LYSDatePickerItem *tileLabelItem;
|
||||
// 当实时监控选择时间时,默认显示的时间格式
|
||||
@property(nonatomic, copy)NSString *titleDateFormat;
|
||||
|
||||
@property(nonatomic, assign)CGFloat headerHeight;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,140 @@
|
||||
//
|
||||
// LYSDatePickerHeaderView.m
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/4.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDatePickerHeaderView.h"
|
||||
#import "LYSDateHeaderViewController.h"
|
||||
|
||||
@implementation LYSDatePickerHeaderView
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.showTimeLabel = YES;
|
||||
self.titleDateFormat = @"yyyy-MM-dd HH:mm:ss";
|
||||
[self customSubViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (LYSDatePickerItem *)leftItem
|
||||
{
|
||||
if (!_leftItem) {
|
||||
_leftItem = [LYSDatePickerItem btnWithTitle:@"取消" target:self action:@selector(cancelAction:)];
|
||||
}
|
||||
return _leftItem;
|
||||
}
|
||||
|
||||
- (LYSDatePickerItem *)rightItem
|
||||
{
|
||||
if (!_rightItem) {
|
||||
_rightItem = [LYSDatePickerItem btnWithTitle:@"确定" target:self action:@selector(commitAction:)];
|
||||
}
|
||||
return _rightItem;
|
||||
}
|
||||
|
||||
- (LYSDatePickerItem *)centerItem
|
||||
{
|
||||
if (!_centerItem) {
|
||||
_centerItem = [LYSDatePickerItem labelWithTitle:@"日期选择器"];
|
||||
}
|
||||
return _centerItem;
|
||||
}
|
||||
|
||||
- (LYSDatePickerItem *)tileLabelItem
|
||||
{
|
||||
if (!_tileLabelItem) {
|
||||
_tileLabelItem = [LYSDatePickerItem labelWithTitle:@""];
|
||||
}
|
||||
return _tileLabelItem;
|
||||
}
|
||||
|
||||
- (void)cancelAction:(LYSDatePickerItem *)sender {
|
||||
[self.headerVC cancelDatePicker];
|
||||
[self.headerVC hiddenDatePicker];
|
||||
}
|
||||
|
||||
- (void)commitAction:(LYSDatePickerItem *)sender {
|
||||
[self.headerVC commitDatePicker];
|
||||
[self.headerVC hiddenDatePicker];
|
||||
}
|
||||
|
||||
- (void)customSubViews {
|
||||
[self addSubview:self.leftItem.itemView];
|
||||
[self addSubview:self.rightItem.itemView];
|
||||
if (self.showTimeLabel) {
|
||||
[self addSubview:self.tileLabelItem.itemView];
|
||||
} else {
|
||||
[self addSubview:self.centerItem.itemView];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setShowTimeLabel:(BOOL)showTimeLabel
|
||||
{
|
||||
_showTimeLabel = showTimeLabel;
|
||||
if (_showTimeLabel) {
|
||||
[self.centerItem.itemView removeFromSuperview];
|
||||
[self addSubview:self.tileLabelItem.itemView];
|
||||
} else {
|
||||
[self.tileLabelItem.itemView removeFromSuperview];
|
||||
[self addSubview:self.centerItem.itemView];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setHeaderHeight:(CGFloat)headerHeight
|
||||
{
|
||||
_headerHeight = headerHeight;
|
||||
|
||||
[self.leftItem updateSize];
|
||||
|
||||
CGRect leftItemFrame = self.leftItem.itemView.frame;
|
||||
leftItemFrame.origin.x = 5;
|
||||
leftItemFrame.origin.y = (_headerHeight - CGRectGetHeight(leftItemFrame))/2.0;
|
||||
self.leftItem.itemView.frame = leftItemFrame;
|
||||
|
||||
[self.rightItem updateSize];
|
||||
|
||||
CGRect rightItemFrame = self.rightItem.itemView.frame;
|
||||
rightItemFrame.origin.x = [UIScreen mainScreen].bounds.size.width - CGRectGetWidth(rightItemFrame) - 5;
|
||||
rightItemFrame.origin.y = (_headerHeight - CGRectGetHeight(rightItemFrame))/2.0;
|
||||
self.rightItem.itemView.frame = rightItemFrame;
|
||||
|
||||
if (self.showTimeLabel) {
|
||||
[self.tileLabelItem updateSize];
|
||||
CGRect titleLabelItemFrame = self.tileLabelItem.itemView.frame;
|
||||
titleLabelItemFrame.origin.x = ([UIScreen mainScreen].bounds.size.width - CGRectGetWidth(titleLabelItemFrame))/2.0;
|
||||
titleLabelItemFrame.origin.y = (_headerHeight - CGRectGetHeight(titleLabelItemFrame))/2.0;
|
||||
self.tileLabelItem.itemView.frame = titleLabelItemFrame;
|
||||
} else {
|
||||
[self.centerItem updateSize];
|
||||
CGRect centerItemFrame = self.centerItem.itemView.frame;
|
||||
centerItemFrame.origin.x = ([UIScreen mainScreen].bounds.size.width - CGRectGetWidth(centerItemFrame))/2.0;
|
||||
centerItemFrame.origin.y = (_headerHeight - CGRectGetHeight(centerItemFrame))/2.0;
|
||||
self.centerItem.itemView.frame = centerItemFrame;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)updateDate:(NSDate *)date {
|
||||
if (self.showTimeLabel) {
|
||||
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
|
||||
[dateFormat setDateFormat:self.titleDateFormat];
|
||||
self.tileLabelItem.title = [dateFormat stringFromDate:date];
|
||||
[self.tileLabelItem updateSize];
|
||||
CGRect titleLabelItemFrame = self.tileLabelItem.itemView.frame;
|
||||
titleLabelItemFrame.origin.x = ([UIScreen mainScreen].bounds.size.width - CGRectGetWidth(titleLabelItemFrame))/2.0;
|
||||
titleLabelItemFrame.origin.y = (_headerHeight - CGRectGetHeight(titleLabelItemFrame))/2.0;
|
||||
self.tileLabelItem.itemView.frame = titleLabelItemFrame;
|
||||
}
|
||||
}
|
||||
|
||||
- (CGSize)sizeWithTitle:(NSString *)title font:(UIFont *)font {
|
||||
return [title boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width, 100) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName: font} context:nil].size;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// LYSDatePickerItem.h
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/4.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface LYSDatePickerItem : NSObject
|
||||
|
||||
@property (nonatomic,strong,readonly)UIView *itemView;
|
||||
|
||||
@property(nonatomic, strong)UIFont *itemFont;
|
||||
@property(nonatomic, strong)UIColor *textColor;
|
||||
@property(nonatomic, strong)NSString *title;
|
||||
|
||||
+ (instancetype)btnWithTitle:(NSString *)title target:(id)target action:(SEL)action;
|
||||
- (instancetype)initBtnWithTitle:(NSString *)title target:(id)target action:(SEL)action;
|
||||
|
||||
+ (instancetype)labelWithTitle:(NSString *)title;
|
||||
- (instancetype)initLabelWithTitle:(NSString *)title;
|
||||
|
||||
- (void)updateSize;
|
||||
@end
|
||||
@@ -0,0 +1,150 @@
|
||||
//
|
||||
// LYSDatePickerItem.m
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/4.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDatePickerItem.h"
|
||||
|
||||
@interface LYSDatePickerItem ()
|
||||
|
||||
@property (nonatomic,strong)NSInvocation *invocation;
|
||||
@property (nonatomic,strong,readwrite)UIView *itemView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation LYSDatePickerItem
|
||||
|
||||
@synthesize textColor = _textColor;
|
||||
@synthesize itemFont = _itemFont;
|
||||
@synthesize title = _title;
|
||||
|
||||
+ (instancetype)btnWithTitle:(NSString *)title target:(id)target action:(SEL)action
|
||||
{
|
||||
return [[LYSDatePickerItem alloc] initBtnWithTitle:title target:target action:action];
|
||||
}
|
||||
|
||||
+ (instancetype)labelWithTitle:(NSString *)title
|
||||
{
|
||||
return [[LYSDatePickerItem alloc] initLabelWithTitle:title];
|
||||
}
|
||||
|
||||
- (instancetype)initBtnWithTitle:(NSString *)title target:(id)target action:(SEL)action
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
UIButton *btn = [[UIButton alloc] init];
|
||||
btn.titleLabel.font = [UIFont systemFontOfSize:16];
|
||||
[btn setTitle:title forState:(UIControlStateNormal)];
|
||||
[btn setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
|
||||
[btn addTarget:self action:@selector(btnAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
self.invocation = [NSInvocation invocationWithMethodSignature:[target methodSignatureForSelector:action]];
|
||||
[self.invocation setSelector:action];
|
||||
[self.invocation setTarget:target];
|
||||
// 从2开始是因为前两个参数已经被selector和target占用
|
||||
[self.invocation setArgument:&self atIndex:2];
|
||||
self.itemView = btn;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initLabelWithTitle:(NSString *)title
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
UILabel *label = [[UILabel alloc] init];
|
||||
label.textColor = [UIColor blackColor];
|
||||
label.font = [UIFont systemFontOfSize:16];
|
||||
label.text = title;
|
||||
self.itemView = label;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)btnAction {
|
||||
[_invocation invoke];
|
||||
}
|
||||
|
||||
- (void)updateSize
|
||||
{
|
||||
CGRect frame = self.itemView.frame;
|
||||
frame.size = [self sizeWithTitle:self.title font:self.itemFont];
|
||||
self.itemView.frame = frame;
|
||||
}
|
||||
|
||||
- (CGSize)sizeWithTitle:(NSString *)title font:(UIFont *)font {
|
||||
return [title boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width, 100) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName: font} context:nil].size;
|
||||
}
|
||||
|
||||
- (UIColor *)textColor {
|
||||
if ([self.itemView isKindOfClass:[UIButton class]]) {
|
||||
UIButton *itemView = (UIButton *)self.itemView;
|
||||
return [itemView titleColorForState:(UIControlStateNormal)];
|
||||
}
|
||||
if ([self.itemView isKindOfClass:[UILabel class]]) {
|
||||
UILabel *itemView = (UILabel *)self.itemView;
|
||||
return itemView.textColor;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (UIFont *)itemFont {
|
||||
if ([self.itemView isKindOfClass:[UIButton class]]) {
|
||||
UIButton *itemView = (UIButton *)self.itemView;
|
||||
return itemView.titleLabel.font;
|
||||
}
|
||||
if ([self.itemView isKindOfClass:[UILabel class]]) {
|
||||
UILabel *itemView = (UILabel *)self.itemView;
|
||||
return itemView.font;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSString *)title {
|
||||
if ([self.itemView isKindOfClass:[UIButton class]]) {
|
||||
UIButton *itemView = (UIButton *)self.itemView;
|
||||
return [itemView titleForState:(UIControlStateNormal)];
|
||||
}
|
||||
if ([self.itemView isKindOfClass:[UILabel class]]) {
|
||||
UILabel *itemView = (UILabel *)self.itemView;
|
||||
return itemView.text;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)setTextColor:(UIColor *)textColor {
|
||||
_textColor = textColor;
|
||||
if ([self.itemView isKindOfClass:[UIButton class]]) {
|
||||
UIButton *itemView = (UIButton *)self.itemView;
|
||||
[itemView setTitleColor:_textColor forState:(UIControlStateNormal)];
|
||||
}
|
||||
if ([self.itemView isKindOfClass:[UILabel class]]) {
|
||||
UILabel *itemView = (UILabel *)self.itemView;
|
||||
itemView.textColor = _textColor;
|
||||
}
|
||||
}
|
||||
- (void)setItemFont:(UIFont *)itemFont {
|
||||
_itemFont = itemFont;
|
||||
if ([self.itemView isKindOfClass:[UIButton class]]) {
|
||||
UIButton *itemView = (UIButton *)self.itemView;
|
||||
itemView.titleLabel.font = _itemFont;
|
||||
}
|
||||
if ([self.itemView isKindOfClass:[UILabel class]]) {
|
||||
UILabel *itemView = (UILabel *)self.itemView;
|
||||
itemView.font = _itemFont;
|
||||
}
|
||||
}
|
||||
- (void)setTitle:(NSString *)title {
|
||||
_title = title;
|
||||
if ([self.itemView isKindOfClass:[UIButton class]]) {
|
||||
UIButton *itemView = (UIButton *)self.itemView;
|
||||
[itemView setTitle:_title forState:(UIControlStateNormal)];
|
||||
}
|
||||
if ([self.itemView isKindOfClass:[UILabel class]]) {
|
||||
UILabel *itemView = (UILabel *)self.itemView;
|
||||
itemView.text = _title;
|
||||
}
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// LYSDatePickerLabel.h
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/7.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface LYSDatePickerLabel : UILabel
|
||||
+ (instancetype)Label;
|
||||
@end
|
||||
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// LYSDatePickerLabel.m
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/7.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDatePickerLabel.h"
|
||||
|
||||
@interface LYSDatePickerLabel ()
|
||||
|
||||
@end
|
||||
|
||||
static NSMutableArray *useingLabelAry = nil;
|
||||
static NSMutableArray *spareLabelAry = nil;
|
||||
|
||||
@implementation LYSDatePickerLabel
|
||||
|
||||
+ (instancetype)Label
|
||||
{
|
||||
if (!useingLabelAry) {
|
||||
useingLabelAry = [NSMutableArray array];
|
||||
}
|
||||
|
||||
if (!spareLabelAry) {
|
||||
spareLabelAry = [NSMutableArray array];
|
||||
}
|
||||
|
||||
if ([spareLabelAry count] > 0) {
|
||||
LYSDatePickerLabel *label = [spareLabelAry lastObject];
|
||||
[useingLabelAry addObject:label];
|
||||
[spareLabelAry removeObject:label];
|
||||
label.frame = CGRectZero;
|
||||
return label;
|
||||
} else {
|
||||
LYSDatePickerLabel *label = [[LYSDatePickerLabel alloc] init];
|
||||
[useingLabelAry addObject:label];
|
||||
return label;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)willMoveToSuperview:(UIView *)newSuperview {
|
||||
if (!newSuperview) {
|
||||
[spareLabelAry addObject:self];
|
||||
[useingLabelAry removeObject:self];
|
||||
}
|
||||
if (useingLabelAry.count == 0) {
|
||||
useingLabelAry = nil;
|
||||
spareLabelAry = nil;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// Only override drawRect: if you perform custom drawing.
|
||||
// An empty implementation adversely affects performance during animation.
|
||||
- (void)drawRect:(CGRect)rect {
|
||||
// Drawing code
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// LYSDatePickerManager.h
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/3.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface LYSDatePickerManager : NSObject
|
||||
// 获取年列表
|
||||
- (NSArray<NSString *> *)fetchYearsWithFromYear:(int)fromYear to:(int)toYear;
|
||||
// 获取月列表
|
||||
- (NSArray<NSString *> *)fetchMonthsWithYear:(int)year;
|
||||
// 获取天列表(不包含星期几)
|
||||
- (NSArray<NSString *> *)fetchDaysWithYear:(int)year month:(int)month;
|
||||
// 获取日列表(包含星期几)
|
||||
- (NSArray<NSString *> *)fetchDaysAndWeekDayWithYear:(int)year month:(int)month isShortWeekName:(BOOL)isShortName identifier:(NSString *)identifier;
|
||||
// 获取小时
|
||||
- (NSArray<NSString *> *)fetchHour;
|
||||
// 获取分钟
|
||||
- (NSArray<NSString *> *)fetchMinutes;
|
||||
// 获取给定日期所在的月有多少天
|
||||
- (NSUInteger)fetchDaysOfMonthWithDate:(NSDate *)date;
|
||||
// 获取给定日期所在的年有多少天
|
||||
- (NSUInteger)fecthDaysOfYearWithDate:(NSDate *)date;
|
||||
// 获取给定日期所在月第一天的日期
|
||||
- (NSDate *)fetchFirstDayOfMonthWithDate:(NSDate *)date;
|
||||
// 获取给定日期所在月最后一天的日期
|
||||
- (NSDate *)fetchLastDayOfMonthWithDate:(NSDate *)date;
|
||||
// 获取给定日期是星期几
|
||||
- (NSInteger)fetchWeekdayNumWithDate:(NSDate *)date;
|
||||
// 获取给定日期是星期几
|
||||
- (NSString *)fetchWeekdayNameWithDate:(NSDate *)date isShortName:(BOOL)isShortName localeIdentifier:(NSString *)localeIdentifier;
|
||||
// 获取给定日期是星期几
|
||||
- (NSString *)fetchWeekdayCNNameWithDate:(NSDate *)date isShortName:(BOOL)isShortName;
|
||||
// 获取给定日期是星期几
|
||||
- (NSString *)fetchWeekdayENNameWithDate:(NSDate *)date isShortName:(BOOL)isShortName;
|
||||
@end
|
||||
@@ -0,0 +1,225 @@
|
||||
//
|
||||
// LYSDatePickerManager.m
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/3.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDatePickerManager.h"
|
||||
|
||||
@interface LYSDatePickerManager ()
|
||||
|
||||
@property (nonatomic,strong)NSCalendar *gregorian;
|
||||
// 获取年列表
|
||||
@property (nonatomic,assign)int year_from;
|
||||
@property (nonatomic,assign)int year_to;
|
||||
@property (nonatomic,strong)NSArray<NSString *> *years;
|
||||
|
||||
// 获取月列表
|
||||
@property (nonatomic,assign)int month_year;
|
||||
@property (nonatomic,strong)NSArray<NSString *> *months;
|
||||
|
||||
// 获取天列表(不包含星期几)
|
||||
@property (nonatomic,assign)int day_year;
|
||||
@property (nonatomic,assign)int day_month;
|
||||
@property (nonatomic,strong)NSArray<NSString *> *days;
|
||||
|
||||
// 获取天列表(包含星期几)
|
||||
@property (nonatomic,assign)int weekday_year;
|
||||
@property (nonatomic,assign)int weekday_month;
|
||||
@property (nonatomic,strong)NSArray<NSString *> *weekdays;
|
||||
|
||||
// 获取小时
|
||||
@property (nonatomic,strong)NSArray<NSString *> *hours;
|
||||
|
||||
// 获取分钟
|
||||
@property (nonatomic,strong)NSArray<NSString *> *minutes;
|
||||
@end
|
||||
|
||||
@implementation LYSDatePickerManager
|
||||
|
||||
#pragma mark - 计算日期 -
|
||||
- (NSCalendar *)gregorian
|
||||
{
|
||||
if (!_gregorian) {
|
||||
_gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
|
||||
}
|
||||
return _gregorian;
|
||||
}
|
||||
// 获取年列表
|
||||
- (NSArray<NSString *> *)fetchYearsWithFromYear:(int)fromYear to:(int)toYear
|
||||
{
|
||||
BOOL isCan = _year_from == fromYear && _year_to == toYear && _years && [_years count] > 0;
|
||||
if (!isCan) {
|
||||
NSMutableArray *tempAry = [NSMutableArray array];
|
||||
for (int i = fromYear; i <= toYear; i++) {
|
||||
[tempAry addObject:[NSString stringWithFormat:@"%d",i]];
|
||||
}
|
||||
_years = tempAry;_year_from = fromYear;_year_to = toYear;
|
||||
}
|
||||
return _years;
|
||||
}
|
||||
// 获取月列表
|
||||
- (NSArray<NSString *> *)fetchMonthsWithYear:(int)year
|
||||
{
|
||||
BOOL isCan = _month_year == year && _months && [_months count] > 0;
|
||||
if (!isCan) {
|
||||
NSDate *tempDate = [self dateWithString:[NSString stringWithFormat:@"%@",@(year)] formatter:@"yyyy"];
|
||||
NSInteger length = [self.gregorian rangeOfUnit:NSCalendarUnitMonth inUnit:NSCalendarUnitYear forDate:tempDate].length;
|
||||
NSMutableArray *tempAry = [NSMutableArray array];
|
||||
for (int i = 1; i <= length; i++) {
|
||||
[tempAry addObject:[NSString stringWithFormat:@"%d",i]];
|
||||
}
|
||||
_months = tempAry;_month_year= year;
|
||||
}
|
||||
return _months;
|
||||
}
|
||||
// 获取日列表(不包含星期几)
|
||||
- (NSArray<NSString *> *)fetchDaysWithYear:(int)year month:(int)month
|
||||
{
|
||||
BOOL isCan = _day_year == year && _day_month == month && _days && [_days count] > 0;
|
||||
if (!isCan) {
|
||||
NSDate *tempDate = [self dateWithString:[NSString stringWithFormat:@"%@/%@",@(year),@(month)] formatter:@"yyyy/MM"];
|
||||
NSInteger length = [self.gregorian rangeOfUnit:NSCalendarUnitDay inUnit:NSCalendarUnitMonth forDate:tempDate].length;
|
||||
NSMutableArray *tempAry = [NSMutableArray array];
|
||||
for (int i = 1; i <= length; i++) {
|
||||
[tempAry addObject:[NSString stringWithFormat:@"%d",i]];
|
||||
}
|
||||
_days = tempAry;_day_month = month;_day_year = year;
|
||||
}
|
||||
return _days;
|
||||
}
|
||||
|
||||
// 获取日列表(包含星期几)
|
||||
- (NSArray<NSString *> *)fetchDaysAndWeekDayWithYear:(int)year month:(int)month isShortWeekName:(BOOL)isShortName identifier:(NSString *)identifier
|
||||
{
|
||||
BOOL isCan = _weekday_year == year && _weekday_month == month && _weekdays && [_weekdays count] > 0;
|
||||
if (!isCan) {
|
||||
NSDate *tempDate = [self dateWithString:[NSString stringWithFormat:@"%@/%@",@(year),@(month)] formatter:@"yyyy/MM"];
|
||||
NSInteger length = [self.gregorian rangeOfUnit:NSCalendarUnitDay inUnit:NSCalendarUnitMonth forDate:tempDate].length;
|
||||
unsigned unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
|
||||
NSDateComponents *comps = [self.gregorian components:unitFlags fromDate:tempDate];
|
||||
[comps setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
|
||||
NSMutableArray *tempAry = [NSMutableArray array];
|
||||
for (int i = 1; i <= length; i++) {
|
||||
[comps setDay:i];
|
||||
NSString *str = @"";
|
||||
if ([identifier isEqualToString:@"zh_CN"]) {
|
||||
str = [self fetchWeekdayCNNameWithDate:[self.gregorian dateFromComponents:comps] isShortName:isShortName];
|
||||
}
|
||||
if ([identifier isEqualToString:@"en_US"]) {
|
||||
str = [self fetchWeekdayENNameWithDate:[self.gregorian dateFromComponents:comps] isShortName:isShortName];
|
||||
}
|
||||
[tempAry addObject:str];
|
||||
}
|
||||
_weekdays = tempAry;_weekday_month = month;_weekday_year = year;
|
||||
}
|
||||
return _weekdays;
|
||||
}
|
||||
// 获取小时
|
||||
- (NSArray<NSString *> *)fetchHour
|
||||
{
|
||||
BOOL isCan = _hours && [_hours count] > 0;
|
||||
if (!isCan) {
|
||||
NSMutableArray *tempAry = [NSMutableArray array];
|
||||
for (int i = 0; i <= 23; i++) {
|
||||
NSString *str = [NSString stringWithFormat:@"%d",i];
|
||||
if (i < 10) {
|
||||
str = [NSString stringWithFormat:@"0%@",str];
|
||||
}
|
||||
[tempAry addObject:str];
|
||||
}
|
||||
_hours = tempAry;
|
||||
}
|
||||
return _hours;
|
||||
}
|
||||
|
||||
// 获取分钟
|
||||
- (NSArray<NSString *> *)fetchMinutes
|
||||
{
|
||||
BOOL isCan = _minutes && [_minutes count] > 0;
|
||||
if (!isCan) {
|
||||
NSMutableArray *tempAry = [NSMutableArray array];
|
||||
for (int i = 0; i <= 59; i++) {
|
||||
NSString *str = [NSString stringWithFormat:@"%d",i];
|
||||
if (i < 10) {
|
||||
str = [NSString stringWithFormat:@"0%@",str];
|
||||
}
|
||||
[tempAry addObject:str];
|
||||
}
|
||||
_minutes = tempAry;
|
||||
}
|
||||
return _minutes;
|
||||
}
|
||||
|
||||
- (NSDate *)dateWithString:(NSString *)dateStr formatter:(NSString *)formatStr
|
||||
{
|
||||
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
||||
formatter.dateFormat = formatStr;
|
||||
return [formatter dateFromString:dateStr];
|
||||
}
|
||||
// 获取给定日期所在的月有多少天
|
||||
- (NSUInteger)fetchDaysOfMonthWithDate:(NSDate *)date
|
||||
{
|
||||
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
|
||||
NSRange range = [gregorian rangeOfUnit:NSCalendarUnitDay inUnit:NSCalendarUnitMonth forDate:date];
|
||||
return range.length;
|
||||
}
|
||||
// 获取给定日期所在的年有多少天
|
||||
- (NSUInteger)fecthDaysOfYearWithDate:(NSDate *)date
|
||||
{
|
||||
NSUInteger days = 0;
|
||||
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
|
||||
NSDateComponents *comps = [gregorian components:NSCalendarUnitYear fromDate:date];
|
||||
for (NSUInteger i=1; i<=12; i++) {
|
||||
[comps setMonth:i];
|
||||
days += [self fetchDaysOfMonthWithDate:[gregorian dateFromComponents:comps]];
|
||||
}
|
||||
return days;
|
||||
}
|
||||
// 获取给定日期所在月第一天的日期
|
||||
- (NSDate *)fetchFirstDayOfMonthWithDate:(NSDate *)date
|
||||
{
|
||||
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
|
||||
unsigned unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
|
||||
NSDateComponents *comps = [gregorian components:unitFlags fromDate:date];
|
||||
[comps setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]]; // 使用UTC或GMT解决时区相差8小时的问题
|
||||
[comps setDay:1];
|
||||
return [gregorian dateFromComponents:comps];
|
||||
}
|
||||
// 获取给定日期所在月最后一天的日期
|
||||
- (NSDate *)fetchLastDayOfMonthWithDate:(NSDate *)date
|
||||
{
|
||||
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
|
||||
unsigned unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
|
||||
NSDateComponents *comps = [gregorian components:unitFlags fromDate:date];
|
||||
[comps setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]]; // 使用UTC或GMT解决时区相差8小时的问题
|
||||
[comps setDay:[self fetchDaysOfMonthWithDate:date]];
|
||||
return [gregorian dateFromComponents:comps];
|
||||
}
|
||||
// 获取给定日期是星期几
|
||||
- (NSInteger)fetchWeekdayNumWithDate:(NSDate *)date
|
||||
{
|
||||
return [[[NSCalendar currentCalendar] components:NSCalendarUnitWeekday fromDate:date] weekday];
|
||||
}
|
||||
// 获取给定日期是星期几
|
||||
- (NSString *)fetchWeekdayNameWithDate:(NSDate *)date isShortName:(BOOL)isShortName localeIdentifier:(NSString *)localeIdentifier
|
||||
{
|
||||
NSDateFormatter *formatter = [NSDateFormatter new];
|
||||
formatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
|
||||
formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:localeIdentifier];
|
||||
formatter.dateFormat = isShortName ? @"EE" : @"EEEE";
|
||||
return [formatter stringFromDate:date];
|
||||
}
|
||||
// 获取给定日期是星期几
|
||||
- (NSString *)fetchWeekdayCNNameWithDate:(NSDate *)date isShortName:(BOOL)isShortName
|
||||
{
|
||||
return [self fetchWeekdayNameWithDate:date isShortName:isShortName localeIdentifier:@"zh_CN"];
|
||||
}
|
||||
// 获取给定日期是星期几
|
||||
- (NSString *)fetchWeekdayENNameWithDate:(NSDate *)date isShortName:(BOOL)isShortName
|
||||
{
|
||||
return [self fetchWeekdayNameWithDate:date isShortName:isShortName localeIdentifier:@"en_US"];
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// LYSDatePickerSelectDelegate.h
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by liyangshuai on 2018/5/5.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class LYSDatePickerController;
|
||||
|
||||
@protocol LYSDatePickerSelectDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
// 日期选择器点击确定按钮时触发
|
||||
- (void)pickerViewController:(LYSDatePickerController *)pickerVC didSelectDate:(NSDate *)date;
|
||||
// 日期选择器生命周期
|
||||
- (void)pickerViewControllerWillAppear:(LYSDatePickerController *)pickerVC;
|
||||
- (void)pickerViewControllerDidAppear:(LYSDatePickerController *)pickerVC;
|
||||
- (void)pickerViewControllerWillDisAppear:(LYSDatePickerController *)pickerVC;
|
||||
- (void)pickerViewControllerdidDisAppear:(LYSDatePickerController *)pickerVC;
|
||||
// 日期选择器点击取消按钮时触发
|
||||
- (void)pickerViewControllerDidCancel:(LYSDatePickerController *)pickerVC;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// LYSDatePickerTypeBase.h
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/4.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
typedef enum : NSUInteger {
|
||||
LYSDatePickerWeakDayTypeCNDefault,
|
||||
LYSDatePickerWeakDayTypeCNShort,
|
||||
LYSDatePickerWeakDayTypeUSDefault,
|
||||
LYSDatePickerWeakDayTypeUSShort
|
||||
} LYSDatePickerWeakDayType;
|
||||
|
||||
@interface LYSDatePickerTypeBase : NSObject<UIPickerViewDataSource,UIPickerViewDelegate>
|
||||
|
||||
@property (nonatomic,weak)UIPickerView *pickView;
|
||||
|
||||
@property(nonatomic, copy)void(^didSelectItem)(NSDate *date);
|
||||
|
||||
- (instancetype)initWithPickerView:(UIPickerView *)pickerView;
|
||||
|
||||
// 日期开始时间
|
||||
@property (nonatomic,assign)int fromYear;
|
||||
// 日期结束时间
|
||||
@property (nonatomic,assign)int toYear;
|
||||
|
||||
@property(nonatomic, weak)UILabel *titleLabel;
|
||||
|
||||
@property (nonatomic,assign)int currentYear;
|
||||
@property (nonatomic,assign)int currentMonth;
|
||||
@property (nonatomic,assign)int currentDay;
|
||||
@property (nonatomic,assign)int currentHour;
|
||||
@property (nonatomic,assign)int currentMinute;
|
||||
|
||||
@property(nonatomic, assign)BOOL yearLoop;
|
||||
@property(nonatomic, assign)BOOL monthLoop;
|
||||
@property(nonatomic, assign)BOOL dayLoop;
|
||||
@property(nonatomic, assign)BOOL hourLoop;
|
||||
@property(nonatomic, assign)BOOL minuteLoop;
|
||||
|
||||
@property(nonatomic, assign)BOOL showWeakDay;
|
||||
@property(nonatomic, assign)LYSDatePickerWeakDayType weakDayType;
|
||||
|
||||
@property (nonatomic,strong,readonly)NSArray<NSString *> *years;
|
||||
@property (nonatomic,strong,readonly)NSArray<NSString *> *months;
|
||||
@property (nonatomic,strong,readonly)NSArray<NSString *> *days;
|
||||
@property (nonatomic,strong,readonly)NSArray<NSString *> *weekDays;
|
||||
@property (nonatomic,strong,readonly)NSArray<NSString *> *weekDaysShortName;
|
||||
@property (nonatomic,strong,readonly)NSArray<NSString *> *hours;
|
||||
@property (nonatomic,strong,readonly)NSArray<NSString *> *minutes;
|
||||
|
||||
// 拆分日期对象,获取时间粒度
|
||||
- (void)defaultWithDate:(NSDate *)date;
|
||||
// 更新选择器
|
||||
- (void)updateDatePicker;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,90 @@
|
||||
//
|
||||
// LYSDatePickerTypeBase.m
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/4.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDatePickerTypeBase.h"
|
||||
#import "LYSDatePickerManager.h"
|
||||
|
||||
@interface LYSDatePickerTypeBase ()
|
||||
|
||||
@property (nonatomic,strong)LYSDatePickerManager *pickerManager;
|
||||
|
||||
@end
|
||||
|
||||
@implementation LYSDatePickerTypeBase
|
||||
|
||||
- (instancetype)initWithPickerView:(UIPickerView *)pickerView
|
||||
{
|
||||
if (self = [super init]) {
|
||||
self.pickView = pickerView;
|
||||
self.pickerManager = [[LYSDatePickerManager alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSArray<NSString *> *)years
|
||||
{
|
||||
return [self.pickerManager fetchYearsWithFromYear:self.fromYear to:self.toYear];
|
||||
}
|
||||
|
||||
- (NSArray<NSString *> *)months
|
||||
{
|
||||
return [self.pickerManager fetchMonthsWithYear:self.currentYear];
|
||||
}
|
||||
|
||||
- (NSArray<NSString *> *)days
|
||||
{
|
||||
return [self.pickerManager fetchDaysWithYear:self.currentYear month:self.currentMonth];
|
||||
}
|
||||
|
||||
- (NSArray<NSString *> *)weekDays
|
||||
{
|
||||
if (self.weakDayType == LYSDatePickerWeakDayTypeCNDefault) {
|
||||
return [self.pickerManager fetchDaysAndWeekDayWithYear:self.currentYear month:self.currentMonth isShortWeekName:NO identifier:@"zh_CN"];
|
||||
}
|
||||
if (self.weakDayType == LYSDatePickerWeakDayTypeUSDefault) {
|
||||
return [self.pickerManager fetchDaysAndWeekDayWithYear:self.currentYear month:self.currentMonth isShortWeekName:NO identifier:@"en_US"];
|
||||
}
|
||||
return [self.pickerManager fetchDaysAndWeekDayWithYear:self.currentYear month:self.currentMonth isShortWeekName:NO identifier:@"zh_CN"];
|
||||
}
|
||||
|
||||
- (NSArray<NSString *> *)weekDaysShortName
|
||||
{
|
||||
if (self.weakDayType == LYSDatePickerWeakDayTypeCNShort) {
|
||||
return [self.pickerManager fetchDaysAndWeekDayWithYear:self.currentYear month:self.currentMonth isShortWeekName:YES identifier:@"zh_CN"];
|
||||
}
|
||||
if (self.weakDayType == LYSDatePickerWeakDayTypeUSShort) {
|
||||
return [self.pickerManager fetchDaysAndWeekDayWithYear:self.currentYear month:self.currentMonth isShortWeekName:YES identifier:@"en_US"];
|
||||
}
|
||||
return [self.pickerManager fetchDaysAndWeekDayWithYear:self.currentYear month:self.currentMonth isShortWeekName:YES identifier:@"zh_CN"];
|
||||
}
|
||||
|
||||
- (NSArray<NSString *> *)hours
|
||||
{
|
||||
return [self.pickerManager fetchHour];
|
||||
}
|
||||
|
||||
- (NSArray<NSString *> *)minutes
|
||||
{
|
||||
return [self.pickerManager fetchMinutes];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfComponentsInPickerView:(nonnull UIPickerView *)pickerView
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (NSInteger)pickerView:(nonnull UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
// 拆分日期对象,获取时间粒度
|
||||
- (void)defaultWithDate:(NSDate *)date {}
|
||||
// 更新选择器
|
||||
- (void)updateDatePicker {}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// LYSDatePickerTypeDayAndTimeDelegate.h
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/4.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDatePickerTypeBase.h"
|
||||
|
||||
@interface LYSDatePickerTypeDayAndTimeDelegate : LYSDatePickerTypeBase
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,239 @@
|
||||
//
|
||||
// LYSDatePickerTypeDayAndTimeDelegate.m
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/4.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDatePickerTypeDayAndTimeDelegate.h"
|
||||
#import "LYSDatePickerLabel.h"
|
||||
|
||||
#define IS5SBOOL CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(320, 568))
|
||||
#define IS6SBOOL CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(375, 667))
|
||||
#define IS6SPBOOL CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(414, 736))
|
||||
#define ISXBOOL CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(375, 812))
|
||||
|
||||
#define WidthRank(A,B,C,D,E) (IS5SBOOL ? A : (IS6SBOOL ? B : (IS6SPBOOL ? C : (ISXBOOL ? D : E))))
|
||||
|
||||
@implementation LYSDatePickerTypeDayAndTimeDelegate
|
||||
|
||||
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
|
||||
{
|
||||
switch (component) {
|
||||
case 0:
|
||||
{
|
||||
return [self.years count] * (self.yearLoop ? 100 : 1);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
return [self.months count] * (self.monthLoop ? 100 : 1);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
return [self.days count] * (self.dayLoop ? 100 : 1);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
return [self.hours count] * (self.hourLoop ? 100 : 1);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
return [self.minutes count] * (self.minuteLoop ? 100 : 1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
|
||||
switch (component) {
|
||||
case 0:
|
||||
{
|
||||
return CGRectGetWidth(pickerView.frame) / WidthRank(5.5, 5.5, 5.5, 5.5, 5.5);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
return CGRectGetWidth(pickerView.frame) / WidthRank(7.0, 7.0, 7.0, 7.0, 7.0);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
if (self.showWeakDay && self.weakDayType == LYSDatePickerWeakDayTypeUSDefault) {
|
||||
return CGRectGetWidth(pickerView.frame) / WidthRank(3.0, 3.0, 3.0, 3.0, 3.0);
|
||||
} else {
|
||||
return CGRectGetWidth(pickerView.frame) / WidthRank(4.0, 4.0, 4.0, 4.0, 4.0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
return CGRectGetWidth(pickerView.frame) / WidthRank(7.0, 7.0, 7.0, 7.0, 7.0);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
return CGRectGetWidth(pickerView.frame) / WidthRank(7.0, 7.0, 7.0, 7.0, 7.0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
|
||||
LYSDatePickerLabel *label = [LYSDatePickerLabel Label];
|
||||
label.textAlignment = self.titleLabel.textAlignment;
|
||||
label.backgroundColor = self.titleLabel.backgroundColor;
|
||||
label.font = self.titleLabel.font;
|
||||
label.textColor = self.titleLabel.textColor;
|
||||
switch (component) {
|
||||
case 0:
|
||||
{
|
||||
id str = [self.years objectAtIndex:(row % [[self years] count])];
|
||||
label.text = [NSString stringWithFormat:@"%@年",str];
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
id str = [self.months objectAtIndex:(row % [[self months] count])];
|
||||
label.text = [NSString stringWithFormat:@"%@月",str];
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
id str = [self.days objectAtIndex:(row % [[self days] count])];
|
||||
if (self.showWeakDay) {
|
||||
id week = @"";
|
||||
if (self.weakDayType == LYSDatePickerWeakDayTypeUSShort || self.weakDayType == LYSDatePickerWeakDayTypeCNShort) {
|
||||
week = [self.weekDaysShortName objectAtIndex:(row % [[self weekDaysShortName] count])];
|
||||
}
|
||||
if (self.weakDayType == LYSDatePickerWeakDayTypeUSDefault || self.weakDayType == LYSDatePickerWeakDayTypeCNDefault) {
|
||||
week = [self.weekDays objectAtIndex:(row % [[self weekDays] count])];
|
||||
}
|
||||
label.text = [NSString stringWithFormat:@"%@日 %@",str,week];
|
||||
}else {
|
||||
label.text = [NSString stringWithFormat:@"%@日",str];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
id str = [self.hours objectAtIndex:(row % [[self hours] count])];
|
||||
label.text = [NSString stringWithFormat:@"%@时",str];
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
id str = [self.minutes objectAtIndex:(row % [[self minutes] count])];
|
||||
label.text = [NSString stringWithFormat:@"%@分",str];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
|
||||
switch (component) {
|
||||
case 0:
|
||||
{
|
||||
self.currentYear = [[self.years objectAtIndex:(row % [[self years] count])] intValue];
|
||||
[pickerView reloadComponent:2];
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
self.currentMonth = [[self.months objectAtIndex:(row % [[self months] count])] intValue];
|
||||
[pickerView reloadComponent:2];
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
self.currentDay = [[self.days objectAtIndex:(row % [[self days] count])] intValue];
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
self.currentHour = [[self.hours objectAtIndex:(row % [[self hours] count])] intValue];
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
self.currentMinute = [[self.minutes objectAtIndex:(row % [[self minutes] count])] intValue];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (self.didSelectItem) {
|
||||
self.didSelectItem([self dateWithYear:self.currentYear month:self.currentMonth day:self.currentDay hour:self.currentHour minute:self.currentMinute]);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSDate *)dateWithYear:(int)year month:(int)month day:(int)day hour:(int)hour minute:(int)minute
|
||||
{
|
||||
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
|
||||
unsigned unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
|
||||
NSDateComponents *comps = [gregorian components:unitFlags fromDate:[NSDate date]];
|
||||
// [comps setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
|
||||
[comps setYear:year];
|
||||
[comps setMonth:month];
|
||||
[comps setDay:day];
|
||||
[comps setHour:hour];
|
||||
[comps setMinute:minute];
|
||||
[comps setSecond:0];
|
||||
return [gregorian dateFromComponents:comps];
|
||||
}
|
||||
|
||||
// 拆分日期对象,获取时间粒度
|
||||
- (void)defaultWithDate:(NSDate *)date {
|
||||
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
|
||||
[dateFormat setDateFormat:@"yyyy/MM/dd/HH/mm"];
|
||||
NSString *currentDate = [dateFormat stringFromDate:date];
|
||||
NSArray *currentDateAry = [currentDate componentsSeparatedByString:@"/"];
|
||||
self.currentYear = [[currentDateAry objectAtIndex:0] intValue];
|
||||
self.currentMonth = [[currentDateAry objectAtIndex:1] intValue];
|
||||
self.currentDay = [[currentDateAry objectAtIndex:2] intValue];
|
||||
self.currentHour = [[currentDateAry objectAtIndex:3] intValue];
|
||||
self.currentMinute = [[currentDateAry objectAtIndex:4] intValue];
|
||||
if (self.didSelectItem) {
|
||||
self.didSelectItem([self dateWithYear:self.currentYear month:self.currentMonth day:self.currentDay hour:self.currentHour minute:self.currentMinute]);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新选择器
|
||||
- (void)updateDatePicker {
|
||||
NSInteger yearIndex = self.currentYear - self.fromYear;
|
||||
NSInteger monthIndex = self.currentMonth - 1;
|
||||
NSInteger dayIndex = self.currentDay - 1;
|
||||
NSInteger hourIndex = self.currentHour;
|
||||
NSInteger minuteIndex = self.currentMinute;
|
||||
yearIndex = yearIndex > [self.years count] - 1 ? [self.years count] - 1 : yearIndex;
|
||||
monthIndex = monthIndex > [self.months count] - 1 ? [self.months count] - 1 : monthIndex;
|
||||
dayIndex = dayIndex > [self.days count] - 1 ? [self.days count] - 1 : dayIndex;
|
||||
hourIndex = hourIndex > [self.hours count] - 1 ? [self.hours count] - 1 : hourIndex;
|
||||
minuteIndex = minuteIndex > [self.minutes count] - 1 ? [self.minutes count] - 1 : minuteIndex;
|
||||
[self.pickView selectRow:yearIndex inComponent:0 animated:NO];
|
||||
[self.pickView selectRow:monthIndex inComponent:1 animated:NO];
|
||||
[self.pickView selectRow:dayIndex inComponent:2 animated:NO];
|
||||
[self.pickView selectRow:hourIndex inComponent:3 animated:NO];
|
||||
[self.pickView selectRow:minuteIndex inComponent:4 animated:NO];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// LYSDatePickerTypeDayDelegate.h
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/4.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDatePickerTypeBase.h"
|
||||
|
||||
@interface LYSDatePickerTypeDayDelegate : LYSDatePickerTypeBase
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,185 @@
|
||||
//
|
||||
// LYSDatePickerTypeDayDelegate.m
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/4.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDatePickerTypeDayDelegate.h"
|
||||
#import "LYSDatePickerLabel.h"
|
||||
|
||||
#define IS5SBOOL CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(320, 568))
|
||||
#define IS6SBOOL CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(375, 667))
|
||||
#define IS6SPBOOL CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(414, 736))
|
||||
#define ISXBOOL CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(375, 812))
|
||||
|
||||
#define WidthRank(A,B,C,D,E) (IS5SBOOL ? A : (IS6SBOOL ? B : (IS6SPBOOL ? C : (ISXBOOL ? D : E))))
|
||||
|
||||
@implementation LYSDatePickerTypeDayDelegate
|
||||
|
||||
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
|
||||
{
|
||||
switch (component) {
|
||||
case 0:
|
||||
{
|
||||
return [self.years count] * (self.yearLoop ? 100 : 1);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
return [self.months count] * (self.monthLoop ? 100 : 1);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
return [self.days count] * (self.dayLoop ? 100 : 1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
|
||||
{
|
||||
switch (component) {
|
||||
case 0:
|
||||
{
|
||||
return CGRectGetWidth(pickerView.frame) / WidthRank(5.5, 5.5, 5.5, 5.5, 5.5);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
return CGRectGetWidth(pickerView.frame) / WidthRank(7.0, 7.0, 7.0, 7.0, 7.0);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
if (self.showWeakDay && self.weakDayType == LYSDatePickerWeakDayTypeUSDefault) {
|
||||
return CGRectGetWidth(pickerView.frame) / WidthRank(3.0, 3.0, 3.0, 3.0, 3.0);
|
||||
} else {
|
||||
return CGRectGetWidth(pickerView.frame) / WidthRank(4.0, 4.0, 4.0, 4.0, 4.0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
|
||||
{
|
||||
LYSDatePickerLabel *label = [LYSDatePickerLabel Label];
|
||||
label.textAlignment = self.titleLabel.textAlignment;
|
||||
label.backgroundColor = self.titleLabel.backgroundColor;
|
||||
label.font = self.titleLabel.font;
|
||||
label.textColor = self.titleLabel.textColor;
|
||||
switch (component) {
|
||||
case 0:
|
||||
{
|
||||
id str = [self.years objectAtIndex:(row % [[self years] count])];
|
||||
label.text = [NSString stringWithFormat:@"%@年",str];
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
id str = [self.months objectAtIndex:(row % [[self months] count])];
|
||||
label.text = [NSString stringWithFormat:@"%@月",str];
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
id str = [self.days objectAtIndex:(row % [[self days] count])];
|
||||
if (self.showWeakDay) {
|
||||
id week = @"";
|
||||
if (self.weakDayType == LYSDatePickerWeakDayTypeUSShort || self.weakDayType == LYSDatePickerWeakDayTypeCNShort) {
|
||||
week = [self.weekDaysShortName objectAtIndex:(row % [[self weekDaysShortName] count])];
|
||||
}
|
||||
if (self.weakDayType == LYSDatePickerWeakDayTypeUSDefault || self.weakDayType == LYSDatePickerWeakDayTypeCNDefault) {
|
||||
week = [self.weekDays objectAtIndex:(row % [[self weekDays] count])];
|
||||
}
|
||||
label.text = [NSString stringWithFormat:@"%@日 %@",str,week];
|
||||
}else {
|
||||
label.text = [NSString stringWithFormat:@"%@日",str];
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return label;
|
||||
}
|
||||
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
|
||||
switch (component) {
|
||||
case 0:
|
||||
{
|
||||
self.currentYear = [[self.years objectAtIndex:(row % [[self years] count])] intValue];
|
||||
[pickerView reloadComponent:2];
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
self.currentMonth = [[self.months objectAtIndex:(row % [[self months] count])] intValue];
|
||||
[pickerView reloadComponent:2];
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
self.currentDay = [[self.days objectAtIndex:(row % [[self days] count])] intValue];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (self.didSelectItem) {
|
||||
self.didSelectItem([self dateWithYear:self.currentYear month:self.currentMonth day:self.currentDay]);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSDate *)dateWithYear:(int)year month:(int)month day:(int)day
|
||||
{
|
||||
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
|
||||
unsigned unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
|
||||
NSDateComponents *comps = [gregorian components:unitFlags fromDate:[NSDate date]];
|
||||
// [comps setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
|
||||
[comps setYear:year];
|
||||
[comps setMonth:month];
|
||||
[comps setDay:day];
|
||||
[comps setHour:0];
|
||||
[comps setMinute:0];
|
||||
[comps setSecond:0];
|
||||
return [gregorian dateFromComponents:comps];
|
||||
}
|
||||
|
||||
// 拆分日期对象,获取时间粒度
|
||||
- (void)defaultWithDate:(NSDate *)date {
|
||||
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
|
||||
[dateFormat setDateFormat:@"yyyy/MM/dd"];
|
||||
NSString *currentDate = [dateFormat stringFromDate:date];
|
||||
NSArray *currentDateAry = [currentDate componentsSeparatedByString:@"/"];
|
||||
self.currentYear = [[currentDateAry objectAtIndex:0] intValue];
|
||||
self.currentMonth = [[currentDateAry objectAtIndex:1] intValue];
|
||||
self.currentDay = [[currentDateAry objectAtIndex:2] intValue];
|
||||
if (self.didSelectItem) {
|
||||
self.didSelectItem([self dateWithYear:self.currentYear month:self.currentMonth day:self.currentDay]);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新选择器
|
||||
- (void)updateDatePicker {
|
||||
NSInteger yearIndex = self.currentYear - self.fromYear;
|
||||
NSInteger monthIndex = self.currentMonth - 1;
|
||||
NSInteger dayIndex = self.currentDay - 1;
|
||||
yearIndex = yearIndex > [self.years count] - 1 ? [self.years count] - 1 : yearIndex;
|
||||
monthIndex = monthIndex > [self.months count] - 1 ? [self.months count] - 1 : monthIndex;
|
||||
dayIndex = dayIndex > [self.days count] - 1 ? [self.days count] - 1 : dayIndex;
|
||||
[self.pickView selectRow:yearIndex inComponent:0 animated:NO];
|
||||
[self.pickView selectRow:monthIndex inComponent:1 animated:NO];
|
||||
[self.pickView selectRow:dayIndex inComponent:2 animated:NO];
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// LYSDatePickerTypeTimeDelegate.h
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/4.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDatePickerTypeBase.h"
|
||||
|
||||
@interface LYSDatePickerTypeTimeDelegate : LYSDatePickerTypeBase
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,142 @@
|
||||
//
|
||||
// LYSDatePickerTypeTimeDelegate.m
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/4.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDatePickerTypeTimeDelegate.h"
|
||||
#import "LYSDatePickerLabel.h"
|
||||
|
||||
#define IS5SBOOL CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(320, 568))
|
||||
#define IS6SBOOL CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(375, 667))
|
||||
#define IS6SPBOOL CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(414, 736))
|
||||
#define ISXBOOL CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(375, 812))
|
||||
|
||||
#define WidthRank(A,B,C,D,E) (IS5SBOOL ? A : (IS6SBOOL ? B : (IS6SPBOOL ? C : (ISXBOOL ? D : E))))
|
||||
|
||||
@implementation LYSDatePickerTypeTimeDelegate
|
||||
|
||||
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
|
||||
{
|
||||
switch (component) {
|
||||
case 0:
|
||||
{
|
||||
return [self.hours count] * (self.hourLoop ? 100 : 1);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
return [self.minutes count] * (self.minuteLoop ? 100 : 1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
|
||||
{
|
||||
switch (component) {
|
||||
case 0:
|
||||
{
|
||||
return CGRectGetWidth(pickerView.frame) / WidthRank(5.5, 5.5, 5.5, 5.5, 5.5);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
return CGRectGetWidth(pickerView.frame) / WidthRank(5.5, 5.5, 5.5, 5.5, 5.5);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
|
||||
{
|
||||
LYSDatePickerLabel *label = [LYSDatePickerLabel Label];
|
||||
label.textAlignment = self.titleLabel.textAlignment;
|
||||
label.backgroundColor = self.titleLabel.backgroundColor;
|
||||
label.font = self.titleLabel.font;
|
||||
label.textColor = self.titleLabel.textColor;
|
||||
switch (component) {
|
||||
case 0:
|
||||
{
|
||||
id str = [self.hours objectAtIndex:(row % [[self hours] count])];
|
||||
label.text = [NSString stringWithFormat:@"%@时",str];
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
id str = [self.minutes objectAtIndex:(row % [[self minutes] count])];
|
||||
label.text = [NSString stringWithFormat:@"%@分",str];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return label;
|
||||
}
|
||||
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
|
||||
{
|
||||
switch (component) {
|
||||
case 0:
|
||||
{
|
||||
self.currentHour = [[self.hours objectAtIndex:(row % [[self hours] count])] intValue];
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
self.currentMinute = [[self.minutes objectAtIndex:(row % [[self minutes] count])] intValue];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (self.didSelectItem) {
|
||||
self.didSelectItem([self dateWithHour:self.currentHour minute:self.currentMinute]);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSDate *)dateWithHour:(int)hour minute:(int)minute
|
||||
{
|
||||
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
|
||||
unsigned unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
|
||||
NSDateComponents *comps = [gregorian components:unitFlags fromDate:[NSDate date]];
|
||||
// [comps setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
|
||||
[comps setHour:hour];
|
||||
[comps setMinute:minute];
|
||||
[comps setSecond:0];
|
||||
return [gregorian dateFromComponents:comps];
|
||||
}
|
||||
|
||||
// 拆分日期对象,获取时间粒度
|
||||
- (void)defaultWithDate:(NSDate *)date {
|
||||
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
|
||||
[dateFormat setDateFormat:@"HH/mm"];
|
||||
NSString *currentDate = [dateFormat stringFromDate:date];
|
||||
NSArray *currentDateAry = [currentDate componentsSeparatedByString:@"/"];
|
||||
self.currentHour = [[currentDateAry objectAtIndex:0] intValue];
|
||||
self.currentMinute = [[currentDateAry objectAtIndex:1] intValue];
|
||||
if (self.didSelectItem) {
|
||||
self.didSelectItem([self dateWithHour:self.currentHour minute:self.currentMinute]);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新选择器
|
||||
- (void)updateDatePicker {
|
||||
NSInteger hourIndex = self.currentHour;
|
||||
NSInteger minuteIndex = self.currentMinute;
|
||||
hourIndex = hourIndex > [self.hours count] - 1 ? [self.hours count] - 1 : hourIndex;
|
||||
minuteIndex = minuteIndex > [self.minutes count] - 1 ? [self.minutes count] - 1 : minuteIndex;
|
||||
[self.pickView selectRow:hourIndex inComponent:0 animated:NO];
|
||||
[self.pickView selectRow:minuteIndex inComponent:1 animated:NO];
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// LYSDatePickerViewController.h
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/5.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDateIndicatorViewController.h"
|
||||
|
||||
@interface LYSDatePickerViewController : LYSDateIndicatorViewController
|
||||
// 选择器视图
|
||||
@property (nonatomic,strong,readonly)UIPickerView *pickView;
|
||||
// 选择器视图颜色
|
||||
@property (nonatomic,assign)CGFloat pickViewHeight;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// LYSDatePickerViewController.m
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/5.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDatePickerViewController.h"
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#define Rect(x,y,w,h) CGRectMake(x, y, w, h)
|
||||
#define ScreenWidth CGRectGetWidth([UIScreen mainScreen].bounds)
|
||||
#define ScreenHeight CGRectGetHeight([UIScreen mainScreen].bounds)
|
||||
|
||||
@interface LYSDatePickerViewController ()
|
||||
|
||||
// 选择器视图
|
||||
@property (nonatomic,strong,readwrite)UIPickerView *pickView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation LYSDatePickerViewController
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
// 默认选择器高度
|
||||
self.pickViewHeight = 220;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
// 初始化选择器
|
||||
[self initPickerView];
|
||||
}
|
||||
|
||||
- (UIPickerView *)pickView
|
||||
{
|
||||
if (!_pickView) {
|
||||
CGFloat headerViewHeight = 0;
|
||||
id tag = objc_getAssociatedObject(self.headerView, @"tag");
|
||||
if (tag && [tag boolValue]) {
|
||||
headerViewHeight = self.pickHeaderHeight;
|
||||
}else {
|
||||
headerViewHeight = CGRectGetHeight(self.headerView.frame);
|
||||
}
|
||||
if (self.showIndicator) {
|
||||
headerViewHeight += self.indicatorHeight;
|
||||
}
|
||||
_pickView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, headerViewHeight, ScreenWidth, self.pickViewHeight)];
|
||||
}
|
||||
return _pickView;
|
||||
}
|
||||
|
||||
// 初始化选择器
|
||||
- (void)initPickerView
|
||||
{
|
||||
[self.contentView addSubview:self.pickView];
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// LYSDatePopViewController.h
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/5.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDateBaseViewController.h"
|
||||
#import "LYSDateContentView.h"
|
||||
|
||||
@interface LYSDatePopViewController : LYSDateBaseViewController
|
||||
// 弹窗弹出视图
|
||||
@property (nonatomic,strong,readonly)LYSDateContentView *contentView;
|
||||
|
||||
@property(nonatomic, assign)BOOL clickOuterHiddenEnable;
|
||||
|
||||
// 动画显示contentView
|
||||
- (void)showAnimationContentViewWithCompletion:(void(^)(BOOL finished))completion;
|
||||
// 动画隐藏contentView
|
||||
- (void)hiddenAnimationContentViewWithCompletion:(void(^)(BOOL finished))completion;
|
||||
|
||||
// 弹出
|
||||
- (void)showDatePickerWithController:(UIViewController *)controller;
|
||||
// 弹出
|
||||
+ (void)showDatePickerWithController:(UIViewController *)controller;
|
||||
|
||||
// 在UIWindow的根视图上弹出
|
||||
- (void)showDatePickerInWindowRootVC;
|
||||
// 在UIWindow的根视图上弹出
|
||||
+ (void)showDatePickerInWindowRootVC;
|
||||
|
||||
// 隐藏
|
||||
- (void)hiddenDatePicker;
|
||||
// 隐藏
|
||||
+ (void)hiddenDatePicker;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,175 @@
|
||||
//
|
||||
// LYSDatePopViewController.m
|
||||
// LYSDatePickerController
|
||||
//
|
||||
// Created by HENAN on 2018/5/5.
|
||||
// Copyright © 2018年 liyangshuai. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LYSDatePopViewController.h"
|
||||
|
||||
#define Rect(x,y,w,h) CGRectMake(x, y, w, h)
|
||||
#define ScreenWidth CGRectGetWidth([UIScreen mainScreen].bounds)
|
||||
#define ScreenHeight CGRectGetHeight([UIScreen mainScreen].bounds)
|
||||
|
||||
@interface LYSDatePopViewController ()
|
||||
|
||||
@property (nonatomic,strong,readwrite)LYSDateContentView *contentView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation LYSDatePopViewController
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.modalPresentationStyle = UIModalPresentationOverCurrentContext;
|
||||
self.clickOuterHiddenEnable = YES;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
// self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.2];
|
||||
// self.view.alpha = 0;
|
||||
// 设置内容视图
|
||||
[self initContentView];
|
||||
}
|
||||
|
||||
- (LYSDateContentView *)contentView
|
||||
{
|
||||
if (!_contentView) {
|
||||
_contentView = [[LYSDateContentView alloc] init];
|
||||
_contentView.backgroundColor = [UIColor whiteColor];
|
||||
_contentView.layer.shadowColor = [UIColor colorWithRed:238/255.0 green:238/255.0 blue:238/255.0 alpha:1].CGColor;
|
||||
_contentView.layer.shadowOffset = CGSizeMake(0, -3);
|
||||
_contentView.layer.shadowOpacity = 0.2;
|
||||
}
|
||||
return _contentView;
|
||||
}
|
||||
|
||||
// 设置内容视图
|
||||
- (void)initContentView
|
||||
{
|
||||
[self.view addSubview:self.contentView];
|
||||
}
|
||||
|
||||
// 动画显示contentView
|
||||
- (void)showAnimationContentViewWithCompletion:(void(^)(BOOL finished))completion
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:LYSDatePickerWillAppearNotifition object:nil];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(pickerViewControllerWillAppear:)]) {
|
||||
[self.delegate pickerViewControllerWillAppear:(LYSDatePickerController *)self];
|
||||
}
|
||||
[self.contentView refreshContentHeight];
|
||||
CGFloat contentHeight = CGRectGetHeight(self.contentView.frame);
|
||||
CGFloat tabHeight = [self superExistTab] ? 49 : 0;
|
||||
[UIView animateWithDuration:0.2 delay:0 options:(UIViewAnimationOptionCurveEaseOut) animations:^{
|
||||
// self.view.alpha = 1;
|
||||
self.contentView.frame = Rect(0, ScreenHeight - contentHeight - tabHeight, ScreenWidth, contentHeight);
|
||||
} completion:^(BOOL finished) {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:LYSDatePickerDidAppearNotifition object:nil];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(pickerViewControllerDidAppear:)]) {
|
||||
[self.delegate pickerViewControllerDidAppear:(LYSDatePickerController *)self];
|
||||
}
|
||||
if (completion) {
|
||||
completion(finished);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
// 动画隐藏contentView
|
||||
- (void)hiddenAnimationContentViewWithCompletion:(void(^)(BOOL finished))completion
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:LYSDatePickerWillDisAppearNotifition object:nil];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(pickerViewControllerWillDisAppear:)]) {
|
||||
[self.delegate pickerViewControllerWillDisAppear:(LYSDatePickerController *)self];
|
||||
}
|
||||
[self.contentView refreshContentHeight];
|
||||
CGFloat contentHeight = CGRectGetHeight(self.contentView.frame);
|
||||
[UIView animateWithDuration:0.2 delay:0 options:(UIViewAnimationOptionCurveEaseIn) animations:^{
|
||||
self.view.alpha = 0;
|
||||
self.contentView.frame = Rect(0, ScreenHeight, ScreenWidth, contentHeight);
|
||||
} completion:^(BOOL finished) {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:LYSDatePickerDidDisAppearNotifition object:nil];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(pickerViewControllerdidDisAppear:)]) {
|
||||
[self.delegate pickerViewControllerdidDisAppear:(LYSDatePickerController *)self];
|
||||
}
|
||||
if (completion) {
|
||||
completion(finished);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
// 弹出
|
||||
- (void)showDatePickerWithController:(UIViewController *)controller {
|
||||
[controller presentViewController:self animated:NO completion:^{
|
||||
[self showAnimationContentViewWithCompletion:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
// 弹出
|
||||
+ (void)showDatePickerWithController:(UIViewController *)controller {
|
||||
[controller presentViewController:[[self class] shareInstance] animated:NO completion:^{
|
||||
[[[self class] shareInstance] showAnimationContentViewWithCompletion:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
// 在UIWindow的根视图上弹出
|
||||
- (void)showDatePickerInWindowRootVC {
|
||||
[[[self class] windowRootViewController] presentViewController:self animated:NO completion:^{
|
||||
[self showAnimationContentViewWithCompletion:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
// 在UIWindow的根视图上弹出
|
||||
+ (void)showDatePickerInWindowRootVC {
|
||||
[[[self class] windowRootViewController] presentViewController:[[self class] shareInstance] animated:NO completion:^{
|
||||
[[[self class] shareInstance] showAnimationContentViewWithCompletion:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
// 隐藏
|
||||
- (void)hiddenDatePicker {
|
||||
[self hiddenAnimationContentViewWithCompletion:^(BOOL finished) {
|
||||
[self dismissViewControllerAnimated:NO completion:^{
|
||||
[[self class] shareRelease];
|
||||
}];
|
||||
}];
|
||||
}
|
||||
|
||||
// 隐藏
|
||||
+ (void)hiddenDatePicker {
|
||||
[[[self class] shareInstance] hiddenAnimationContentViewWithCompletion:^(BOOL finished) {
|
||||
[[[self class] shareInstance] dismissViewControllerAnimated:NO completion:^{
|
||||
[[self class] shareRelease];
|
||||
}];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
if (self.clickOuterHiddenEnable) {
|
||||
[self hiddenDatePicker];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)superExistTab
|
||||
{
|
||||
UIViewController *parentVC = self.presentingViewController;
|
||||
while (parentVC != nil && ![parentVC isKindOfClass:[UITabBarController class]]) {
|
||||
parentVC = parentVC.parentViewController;
|
||||
}
|
||||
return [parentVC isKindOfClass:[UITabBarController class]];
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// ApiRequestConfig.h
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/9/16.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef ApiRequestConfig_h
|
||||
#define ApiRequestConfig_h
|
||||
//登录
|
||||
#define kApiUserLogin @"sys/v1/login"
|
||||
//获取用户信息
|
||||
#define kApiUserInfo @"user/v1/info"
|
||||
|
||||
#endif /* ApiRequestConfig_h */
|
||||
@@ -23,6 +23,9 @@
|
||||
#import "MobClickList.h"
|
||||
#import "TTTAttributedLabel.h"
|
||||
#import "GiGaUserManager.h"
|
||||
#import "GiGaUser.h"
|
||||
#import "ApiRequestConfig.h"
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
#define GILog(fmt,...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
|
||||
@@ -201,8 +201,8 @@
|
||||
|
||||
//[GIGAMBHUDHelper messageAddto:self.view title:@"登录中..."];
|
||||
[self.view makeToastActivity:CSToastPositionCenter];
|
||||
|
||||
NSString *url = [NSString stringWithFormat:@"%@sys/v1/login",[GiGaServerConfig getMainUrl]];
|
||||
NSString *baseapi = [GiGaServerConfig getMainUrl];
|
||||
NSString *url = [NSString stringWithFormat:@"%@%@",baseapi,kApiUserLogin];
|
||||
[GiGaNetManager userbodyRequest:url params:params completionHandler:^(NSURLResponse *response, NSDictionary *resDic, NSError * _Nullable error) {
|
||||
GILog(@"%@",resDic);
|
||||
[self.view hideToastActivity];
|
||||
@@ -320,10 +320,14 @@
|
||||
[MobClick endEvent:MobClick_UserLogin];
|
||||
GIGA_WIndowTost(@"登录成功!");
|
||||
//请求用户数据
|
||||
|
||||
[[GiGaUserManager shareUser] synsisUserInfo:^(GiGaUser *user) {
|
||||
NSLog(@"%@",user.userId);
|
||||
}];
|
||||
GILog(@"user.userId:%@",user.userId);
|
||||
NC_POST_NAME_OBJECT(kUserLoginSuccessNoti, nil);
|
||||
} userErrorMsgBlock:^(NSDictionary *errorCodemsg) {
|
||||
|
||||
}];
|
||||
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
|
||||
}
|
||||
|
||||
@@ -597,7 +597,6 @@
|
||||
|
||||
NSURL *url = [NSURL URLWithString:imageUrl];
|
||||
[self.rightNavUserBtn sd_setImageWithURL:url forState:UIControlStateNormal];
|
||||
//[self.rightNavUserBtn sd_setBackgroundImageWithURL:url forState:UIControlStateNormal];
|
||||
|
||||
}
|
||||
|
||||
@@ -663,7 +662,6 @@
|
||||
if (user.headImgUrl && ![user.headImgUrl isKindOfClass:[NSNull class]] ) {
|
||||
[self refreshUserIcon:user.headImgUrl];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - 退出登录通知
|
||||
|
||||
@@ -47,9 +47,13 @@
|
||||
|
||||
if (!currentuser) {
|
||||
[self.view makeToastActivity:CSToastPositionCenter];
|
||||
|
||||
[[GiGaUserManager shareUser] synsisUserInfo:^(GiGaUser *user) {
|
||||
[self.view hideToastActivity];
|
||||
self.user = user;
|
||||
} userErrorMsgBlock:^(NSDictionary *errorCodemsg) {
|
||||
[self.view hideToastActivity];
|
||||
GIGA_ShowToast(errorCodemsg[@"msg"]);
|
||||
}];
|
||||
}else{
|
||||
self.user = currentuser;
|
||||
|
||||
@@ -12,9 +12,13 @@
|
||||
#import "GIGaUserWeChatViewCell.h"
|
||||
#import "GiGaUserSexViewCell.h"
|
||||
#import "GIGaUserCityViewCell.h"
|
||||
#import "GiGaUser.h"
|
||||
#import "GiGaUserManager.h"
|
||||
#import "LYSDatePickerController.h"
|
||||
#import "JYAddressPicker.h"
|
||||
|
||||
@interface GiGaUserViewController ()
|
||||
|
||||
@interface GiGaUserViewController ()<LYSDatePickerSelectDelegate>
|
||||
@property (nonatomic,strong) GiGaUser *user;
|
||||
@end
|
||||
|
||||
@implementation GiGaUserViewController
|
||||
@@ -24,6 +28,7 @@
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
//self.title = @"个人中心";
|
||||
self.user = [[GiGaUserManager shareUser] getCurrentUser];
|
||||
[self addNavTitile:@"个人信息"];
|
||||
|
||||
UIButton *saveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
@@ -73,7 +78,7 @@
|
||||
cell = [[[NSBundle mainBundle] loadNibNamed:@"GIGaUserInfoAvatorCell" owner:self options:nil] lastObject];
|
||||
|
||||
}
|
||||
|
||||
[cell loadCellData:indexPath user:self.user];
|
||||
return cell;
|
||||
}else if (indexPath.section == 1 && indexPath.row < 2){
|
||||
GIGaUserIDViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GIGaUserIDViewCell"];
|
||||
@@ -82,6 +87,8 @@
|
||||
|
||||
}
|
||||
|
||||
[cell loadCellData:indexPath user: self.user];
|
||||
|
||||
return cell;
|
||||
|
||||
}else if (indexPath.section == 1 && indexPath.row == 2){
|
||||
@@ -90,6 +97,7 @@
|
||||
cell = [[[NSBundle mainBundle] loadNibNamed:@"GIGaUserWeChatViewCell" owner:self options:nil] lastObject];
|
||||
}
|
||||
|
||||
[cell loadCellData:indexPath user:self.user];
|
||||
return cell;
|
||||
|
||||
}else if (indexPath.section == 2 && indexPath.row == 0){
|
||||
@@ -98,7 +106,13 @@
|
||||
cell = [[[NSBundle mainBundle] loadNibNamed:@"GiGaUserSexViewCell" owner:self options:nil] lastObject];
|
||||
|
||||
}
|
||||
|
||||
[cell loadCellData:indexPath user:self.user];
|
||||
//0 女 1 男
|
||||
weakify(self);
|
||||
[cell userSelectSexAction:^(int sex) {
|
||||
weakSelf.user.sexCode = sex;
|
||||
}];
|
||||
GILog(@"sex:%d",self.user.sexCode);
|
||||
return cell;
|
||||
|
||||
}else if (indexPath.section == 2 && indexPath.row >= 1){
|
||||
@@ -106,15 +120,38 @@
|
||||
if(!cell){
|
||||
cell = [[[NSBundle mainBundle] loadNibNamed:@"GIGaUserCityViewCell" owner:self options:nil] lastObject];
|
||||
}
|
||||
|
||||
[cell loadCellData:indexPath user:self.user];
|
||||
return cell;
|
||||
}
|
||||
|
||||
return nil;
|
||||
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
GILog(@"sex:%d",self.user.sexCode);
|
||||
if (indexPath.section == 2 && indexPath.row == 1) {
|
||||
[LYSDatePickerController alertDatePickerWithController:self type:(LYSDatePickerTypeDay)];
|
||||
[LYSDatePickerController customPickerDelegate:self];
|
||||
[LYSDatePickerController customdidSelectDatePicker:^(NSDate *date) {
|
||||
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
|
||||
[dateFormat setDateFormat:@"yyyy/MM/dd"];
|
||||
NSString *currentDate = [dateFormat stringFromDate:date];
|
||||
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
|
||||
cell.detailTextLabel.text = currentDate;
|
||||
}];
|
||||
|
||||
}else if (indexPath.section == 2 && indexPath.row == 2){
|
||||
JYAddressPicker *addressPicker = [JYAddressPicker jy_showAt:self];
|
||||
addressPicker.selectedItemBlock = ^(NSArray *addressArr) {
|
||||
|
||||
NSString *province = [addressArr objectAtIndex:0][@"text"];
|
||||
NSString *city = [addressArr objectAtIndex:1][@"text"];
|
||||
NSString *county = [addressArr objectAtIndex:2][@"text"];
|
||||
|
||||
NSString *addres = [NSString stringWithFormat:@"%@%@%@",province,city,county];
|
||||
GILog(@"%@",addres);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
@property(nonatomic,copy) NSString *occupationCode;
|
||||
@property(nonatomic,copy) NSString *provinceId;
|
||||
@property(nonatomic,copy) NSString *provinceName;
|
||||
@property(nonatomic,copy) NSString *sexCode;
|
||||
@property(nonatomic,assign) int sexCode;
|
||||
@property(nonatomic,copy) NSString *sexName;
|
||||
@property(nonatomic,copy) NSString *weixin;
|
||||
|
||||
|
||||
@@ -9,5 +9,8 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface GIGaUserCityViewCell : UITableViewCell
|
||||
-(void)loadCellData:(NSIndexPath*)indexPath user:(GiGaUser*)user;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *cityLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *detalTitle;
|
||||
|
||||
@end
|
||||
|
||||
@@ -15,6 +15,33 @@
|
||||
// Initialization code
|
||||
}
|
||||
|
||||
-(void)loadCellData:(NSIndexPath*)indexPath user:(GiGaUser*)user{
|
||||
if (indexPath.section == 2 && indexPath.row == 1) {
|
||||
self.cityLabel.text = @"生日";
|
||||
if (user.birthday && ![user.birthday isKindOfClass:[NSNull class]]) {
|
||||
self.detalTitle.text = user.birthday;
|
||||
}else{
|
||||
self.detalTitle.text = @"选择生日";
|
||||
}
|
||||
|
||||
}else if (indexPath.section == 2 && indexPath.row == 2){
|
||||
self.cityLabel.text = @"城市";
|
||||
if (user.cityName && ![user.cityName isKindOfClass:[NSNull class]]) {
|
||||
self.detalTitle.text = user.cityName;
|
||||
}else{
|
||||
self.detalTitle.text = @"选择城市";
|
||||
}
|
||||
}else if (indexPath.section == 2 && indexPath.row == 3){
|
||||
self.cityLabel.text = @"职业";
|
||||
if (user.occupationCode && ![user.occupationCode isKindOfClass:[NSNull class]]) {
|
||||
self.detalTitle.text = user.occupationCode;
|
||||
}else{
|
||||
self.detalTitle.text = @"选择职业";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
||||
[super setSelected:selected animated:animated];
|
||||
|
||||
|
||||
@@ -59,7 +59,11 @@
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
|
||||
<point key="canvasLocation" x="33.5" y="68"/>
|
||||
<connections>
|
||||
<outlet property="cityLabel" destination="OA0-rJ-5qY" id="sFb-nt-6vY"/>
|
||||
<outlet property="detalTitle" destination="y6H-zg-4yv" id="Yhl-Hx-EGv"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="-41" y="69"/>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
<resources>
|
||||
|
||||
@@ -9,5 +9,8 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface GIGaUserIDViewCell : UITableViewCell
|
||||
-(void)loadCellData:(NSIndexPath*)indexPath user:(GiGaUser*)user;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *IdLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *userTitle;
|
||||
|
||||
@end
|
||||
|
||||
@@ -14,7 +14,22 @@
|
||||
[super awakeFromNib];
|
||||
// Initialization code
|
||||
}
|
||||
- (void)loadCellData:(NSIndexPath *)indexPath user:(GiGaUser*)user{
|
||||
|
||||
if (indexPath.section == 1 && indexPath.row == 0 ) {
|
||||
|
||||
self.IdLabel.text = user.userId;
|
||||
self.userTitle.text = @"用户ID";
|
||||
|
||||
}else if (indexPath.section == 1 && indexPath.row == 1){
|
||||
self.userTitle.text = @"昵称";
|
||||
if (user.nickName && ![user.nickName isKindOfClass:[NSNull class]]) {
|
||||
self.IdLabel.text = user.nickName;
|
||||
}else{
|
||||
self.IdLabel.text = @"昵称";
|
||||
}
|
||||
}
|
||||
}
|
||||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
||||
[super setSelected:selected animated:animated];
|
||||
|
||||
|
||||
@@ -50,6 +50,10 @@
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
|
||||
<connections>
|
||||
<outlet property="IdLabel" destination="4Oa-fe-SvG" id="zho-2s-rPC"/>
|
||||
<outlet property="userTitle" destination="HzQ-bQ-e0n" id="kPd-kc-XZU"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="33.5" y="68"/>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface GIGaUserInfoAvatorCell : UITableViewCell
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *userAvator;
|
||||
-(void)loadCellData:(NSIndexPath*)indexPath user:(GiGaUser*)user;
|
||||
@end
|
||||
|
||||
@@ -7,12 +7,22 @@
|
||||
//
|
||||
|
||||
#import "GIGaUserInfoAvatorCell.h"
|
||||
#import "UIImageView+WebCache.h"
|
||||
|
||||
@implementation GIGaUserInfoAvatorCell
|
||||
|
||||
- (void)awakeFromNib {
|
||||
[super awakeFromNib];
|
||||
// Initialization code
|
||||
self.userAvator.layer.masksToBounds = YES;
|
||||
self.userAvator.layer.cornerRadius = self.userAvator.frame.size.height /2 ;
|
||||
|
||||
}
|
||||
- (void)loadCellData:(NSIndexPath *)indexPath user:(GiGaUser *)user{
|
||||
if (user.headImgUrl && ![user.headImgUrl isKindOfClass:[NSNull class]]) {
|
||||
[self.userAvator sd_setImageWithURL:[NSURL URLWithString:user.headImgUrl]];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<constraint firstAttribute="height" constant="82" id="ipN-ci-Ha3"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" 用户名" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bZT-xd-Nax">
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" 点击修改头像" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bZT-xd-Nax">
|
||||
<rect key="frame" x="16" y="106" width="343" height="16"/>
|
||||
<fontDescription key="fontDescription" name="PingFangSC-Medium" family="PingFang SC" pointSize="11"/>
|
||||
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
@@ -43,6 +43,9 @@
|
||||
</tableViewCellContentView>
|
||||
<color key="backgroundColor" red="0.51372549020000002" green="0.039215686270000001" blue="0.039215686270000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
|
||||
<connections>
|
||||
<outlet property="userAvator" destination="L0Q-5Y-jXq" id="IIT-bz-CcZ"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="9.5" y="62.5"/>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
|
||||
@@ -10,5 +10,5 @@
|
||||
|
||||
@interface GIGaUserWeChatViewCell : UITableViewCell
|
||||
@property (weak, nonatomic) IBOutlet UITextField *weiXinCount;
|
||||
|
||||
-(void)loadCellData:(NSIndexPath*)indexPath user:(GiGaUser*)user;
|
||||
@end
|
||||
|
||||
@@ -15,7 +15,13 @@
|
||||
// Initialization code
|
||||
|
||||
}
|
||||
-(void)loadCellData:(NSIndexPath*)indexPath user:(GiGaUser*)user{
|
||||
|
||||
if (user.weixin && ![user.weixin isKindOfClass:[NSNull class]]) {
|
||||
self.weiXinCount.text = user.weixin;
|
||||
}
|
||||
|
||||
}
|
||||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
||||
[super setSelected:selected animated:animated];
|
||||
|
||||
|
||||
@@ -8,8 +8,14 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
typedef void (^femaleBtnAction)(int sex);
|
||||
|
||||
@interface GiGaUserSexViewCell : UITableViewCell
|
||||
@property (weak, nonatomic) IBOutlet UIButton *usefemale;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *usermale;
|
||||
-(void)loadCellData:(NSIndexPath*)indexPath user:(GiGaUser*)user;
|
||||
-(void)userSelectSexAction:(femaleBtnAction)block;
|
||||
@property (nonatomic,copy) femaleBtnAction actionblock;
|
||||
-(void)configUserSex:(int)sex;
|
||||
|
||||
@end
|
||||
|
||||
@@ -13,8 +13,39 @@
|
||||
- (void)awakeFromNib {
|
||||
[super awakeFromNib];
|
||||
// Initialization code
|
||||
[self.usermale addTarget:self action:@selector(usermaleClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.usefemale addTarget:self action:@selector(userfemaleClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
-(void)loadCellData:(NSIndexPath*)indexPath user:(GiGaUser*)user{
|
||||
|
||||
int sex = user.sexCode;
|
||||
[self configUserSex:sex];
|
||||
|
||||
}
|
||||
|
||||
-(void)configUserSex:(int)sex{
|
||||
|
||||
if (sex == 0) {
|
||||
[self.usefemale setImage:[UIImage imageNamed:@"sex_selected"] forState:UIControlStateNormal];
|
||||
[self.usermale setImage:[UIImage imageNamed:@"sex_disselect"] forState:UIControlStateNormal];
|
||||
}else{
|
||||
[self.usermale setImage:[UIImage imageNamed:@"sex_selected"] forState:UIControlStateNormal];
|
||||
[self.usefemale setImage:[UIImage imageNamed:@"sex_disselect"] forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
}
|
||||
-(void)usermaleClick{
|
||||
self.actionblock(1);
|
||||
[self configUserSex:1];
|
||||
}
|
||||
|
||||
-(void)userfemaleClick{
|
||||
self.actionblock(0);
|
||||
[self configUserSex:0];
|
||||
}
|
||||
-(void)userSelectSexAction:(femaleBtnAction)block{
|
||||
self.actionblock = block;
|
||||
}
|
||||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
||||
[super setSelected:selected animated:animated];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user