-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
520 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// ____ ___ _ ___ _____ ____ ____ ____ | ||
// | \ / \ | T / _]/ ___/ / T| \| \ | ||
// | o )Y Y| | / [_( \_ Y o || o ) o ) | ||
// | _/ | O || l___ Y _]\__ T| || _/| _/ | ||
// | | | || T| [_ / \ || _ || | | | | ||
// | | l !| || T\ || | || | | | | ||
// l__j \___/ l_____jl_____j \___jl__j__jl__j l__j | ||
// | ||
// | ||
// Powered by Polesapp.com | ||
// | ||
// | ||
// RBCustomDatePickerView.h | ||
// | ||
// | ||
// Created by fangmi-huangchengda on 15/10/21. | ||
// | ||
// | ||
|
||
#define kScreen_Height [UIScreen mainScreen].bounds.size.height | ||
#define kScreen_Width [UIScreen mainScreen].bounds.size.width | ||
|
||
#define kScaleFrom_iPhone5_Desgin(_X_) (_X_ * (kScreen_Width/320)) | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "MXSCycleScrollView.h" | ||
|
||
typedef enum { | ||
DatePickerDateMode, | ||
DatePickerTimeMode, | ||
DatePickerDateTimeMode, | ||
DatePickerYearMonthMode, | ||
DatePickerMonthDayMode, | ||
DatePickerHourMinuteMode | ||
}DatePickerMode; | ||
|
||
typedef void(^DatePickerCompleteAnimationBlock)(BOOL Complete); | ||
typedef void(^ClickedOkBtn)(NSString *dateTimeStr); | ||
|
||
@interface HcdDateTimePickerView : UIView <MXSCycleScrollViewDatasource,MXSCycleScrollViewDelegate> | ||
@property (nonatomic,strong) ClickedOkBtn clickedOkBtn; | ||
@property (nonatomic,assign) NSInteger curYear;//当前年 | ||
@property (nonatomic,assign) NSInteger curMonth;//当前月 | ||
@property (nonatomic,assign) NSInteger curDay;//当前日 | ||
@property (nonatomic,assign) NSInteger curHour;//当前小时 | ||
@property (nonatomic,assign) NSInteger curMin;//当前分 | ||
@property (nonatomic,assign) NSInteger curSecond;//当前秒 | ||
|
||
@property (nonatomic,assign) DatePickerMode datePickerMode; | ||
|
||
-(instancetype)initWithDefaultDatetime:(NSDate*)dateTime; | ||
-(instancetype)initWithDatePickerMode:(DatePickerMode)datePickerMode defaultDateTime:(NSDate*)dateTime; | ||
-(void) showHcdDateTimePicker; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// ____ ___ _ ___ _____ ____ ____ ____ | ||
// | \ / \ | T / _]/ ___/ / T| \| \ | ||
// | o )Y Y| | / [_( \_ Y o || o ) o ) | ||
// | _/ | O || l___ Y _]\__ T| || _/| _/ | ||
// | | | || T| [_ / \ || _ || | | | | ||
// | | l !| || T\ || | || | | | | ||
// l__j \___/ l_____jl_____j \___jl__j__jl__j l__j | ||
// | ||
// | ||
// Powered by Polesapp.com | ||
// | ||
// | ||
// MXSCycleScrollView.h | ||
// | ||
// | ||
// Created by fangmi-huangchengda on 15/10/21. | ||
// | ||
// | ||
|
||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@protocol MXSCycleScrollViewDelegate; | ||
@protocol MXSCycleScrollViewDatasource; | ||
|
||
@interface MXSCycleScrollView : UIView<UIScrollViewDelegate> | ||
{ | ||
UIScrollView *_scrollView; | ||
|
||
NSInteger _totalPages; | ||
NSInteger _curPage; | ||
|
||
NSMutableArray *_curViews; | ||
} | ||
|
||
@property (nonatomic,readonly) UIScrollView *scrollView; | ||
@property (nonatomic,assign) NSInteger currentPage; | ||
@property (nonatomic,assign,setter = setDataource:) id<MXSCycleScrollViewDatasource> datasource; | ||
@property (nonatomic,assign,setter = setDelegate:) id<MXSCycleScrollViewDelegate> delegate; | ||
|
||
- (void)setCurrentSelectPage:(NSInteger)selectPage; //设置初始化页数 | ||
- (void)reloadData; | ||
- (void)setViewContent:(UIView *)view atIndex:(NSInteger)index; | ||
|
||
@end | ||
|
||
@protocol MXSCycleScrollViewDelegate <NSObject> | ||
|
||
@optional | ||
- (void)didClickPage:(MXSCycleScrollView *)csView atIndex:(NSInteger)index; | ||
- (void)scrollviewDidChangeNumber; | ||
|
||
@end | ||
|
||
@protocol MXSCycleScrollViewDatasource <NSObject> | ||
|
||
@required | ||
- (NSInteger)numberOfPages:(MXSCycleScrollView*)scrollView; | ||
- (UIView *)pageAtIndex:(NSInteger)index andScrollView:(MXSCycleScrollView*)scrollView; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,231 @@ | ||
// | ||
// ____ ___ _ ___ _____ ____ ____ ____ | ||
// | \ / \ | T / _]/ ___/ / T| \| \ | ||
// | o )Y Y| | / [_( \_ Y o || o ) o ) | ||
// | _/ | O || l___ Y _]\__ T| || _/| _/ | ||
// | | | || T| [_ / \ || _ || | | | | ||
// | | l !| || T\ || | || | | | | ||
// l__j \___/ l_____jl_____j \___jl__j__jl__j l__j | ||
// | ||
// | ||
// Powered by Polesapp.com | ||
// | ||
// | ||
// MXSCycleScrollView.m | ||
// | ||
// | ||
// Created by fangmi-huangchengda on 15/10/21. | ||
// | ||
// | ||
|
||
#import "MXSCycleScrollView.h" | ||
#import "UIColor+HcdCustom.h" | ||
|
||
@implementation MXSCycleScrollView | ||
|
||
@synthesize scrollView = _scrollView; | ||
@synthesize currentPage = _curPage; | ||
@synthesize datasource = _datasource; | ||
@synthesize delegate = _delegate; | ||
|
||
- (id)initWithFrame:(CGRect)frame | ||
{ | ||
self = [super initWithFrame:frame]; | ||
if (self) { | ||
// Initialization code | ||
_scrollView = [[UIScrollView alloc] initWithFrame:self.bounds]; | ||
_scrollView.delegate = self; | ||
_scrollView.contentSize = CGSizeMake(self.bounds.size.width, (self.bounds.size.height/5)*7); | ||
_scrollView.showsHorizontalScrollIndicator = NO; | ||
_scrollView.showsVerticalScrollIndicator = NO; | ||
_scrollView.contentOffset = CGPointMake(0, (self.bounds.size.height/5)); | ||
|
||
[self addSubview:_scrollView]; | ||
} | ||
return self; | ||
} | ||
//设置初始化页数 | ||
- (void)setCurrentSelectPage:(NSInteger)selectPage | ||
{ | ||
_curPage = selectPage; | ||
} | ||
|
||
- (void)setDataource:(id<MXSCycleScrollViewDatasource>)datasource | ||
{ | ||
_datasource = datasource; | ||
[self reloadData]; | ||
} | ||
|
||
- (void)reloadData | ||
{ | ||
_totalPages = [_datasource numberOfPages:self]; | ||
if (_totalPages == 0) { | ||
return; | ||
} | ||
[self loadData]; | ||
} | ||
|
||
- (void)loadData | ||
{ | ||
//从scrollView上移除所有的subview | ||
NSArray *subViews = [_scrollView subviews]; | ||
if([subViews count] != 0) { | ||
[subViews makeObjectsPerformSelector:@selector(removeFromSuperview)]; | ||
} | ||
|
||
[self getDisplayImagesWithCurpage:_curPage]; | ||
|
||
for (int i = 0; i < 7; i++) { | ||
UIView *v = [_curViews objectAtIndex:i]; | ||
// v.userInteractionEnabled = YES; | ||
// UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self | ||
// action:@selector(handleTap:)]; | ||
// [v addGestureRecognizer:singleTap]; | ||
v.frame = CGRectOffset(v.frame, 0, v.frame.size.height * i ); | ||
[_scrollView addSubview:v]; | ||
} | ||
|
||
[_scrollView setContentOffset:CGPointMake( 0, (self.bounds.size.height/5) )]; | ||
} | ||
|
||
- (void)getDisplayImagesWithCurpage:(NSInteger)page { | ||
NSInteger pre1 = [self validPageValue:_curPage-1]; | ||
NSInteger pre2 = [self validPageValue:_curPage]; | ||
NSInteger pre3 = [self validPageValue:_curPage+1]; | ||
NSInteger pre4 = [self validPageValue:_curPage+2]; | ||
NSInteger pre5 = [self validPageValue:_curPage+3]; | ||
NSInteger pre = [self validPageValue:_curPage+4]; | ||
NSInteger last = [self validPageValue:_curPage+5]; | ||
|
||
if (!_curViews) { | ||
_curViews = [[NSMutableArray alloc] init]; | ||
} | ||
|
||
[_curViews removeAllObjects]; | ||
|
||
[_curViews addObject:[_datasource pageAtIndex:pre1 andScrollView:self]]; | ||
[_curViews addObject:[_datasource pageAtIndex:pre2 andScrollView:self]]; | ||
[_curViews addObject:[_datasource pageAtIndex:pre3 andScrollView:self]]; | ||
[_curViews addObject:[_datasource pageAtIndex:pre4 andScrollView:self]]; | ||
[_curViews addObject:[_datasource pageAtIndex:pre5 andScrollView:self]]; | ||
[_curViews addObject:[_datasource pageAtIndex:pre andScrollView:self]]; | ||
[_curViews addObject:[_datasource pageAtIndex:last andScrollView:self]]; | ||
} | ||
|
||
- (NSInteger)validPageValue:(NSInteger)value { | ||
|
||
if(value < 0 ) value = _totalPages + value; | ||
if(value == _totalPages+1) value = 1; | ||
if (value == _totalPages+2) value = 2; | ||
if(value == _totalPages+3) value = 3; | ||
if (value == _totalPages+4) value = 4; | ||
if(value == _totalPages) value = 0; | ||
|
||
|
||
return value; | ||
|
||
} | ||
|
||
- (void)handleTap:(UITapGestureRecognizer *)tap { | ||
|
||
if ([_delegate respondsToSelector:@selector(didClickPage:atIndex:)]) { | ||
[_delegate didClickPage:self atIndex:_curPage]; | ||
} | ||
|
||
} | ||
|
||
- (void)setViewContent:(UIView *)view atIndex:(NSInteger)index | ||
{ | ||
if (index == _curPage) { | ||
[_curViews replaceObjectAtIndex:1 withObject:view]; | ||
for (int i = 0; i < 7; i++) { | ||
UIView *v = [_curViews objectAtIndex:i]; | ||
v.userInteractionEnabled = YES; | ||
// UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self | ||
// action:@selector(handleTap:)]; | ||
// [v addGestureRecognizer:singleTap]; | ||
v.frame = CGRectOffset(v.frame, 0, v.frame.size.height * i); | ||
[_scrollView addSubview:v]; | ||
} | ||
} | ||
} | ||
|
||
- (void)setAfterScrollShowView:(UIScrollView*)scrollview andCurrentPage:(NSInteger)pageNumber | ||
{ | ||
UILabel *oneLabel = (UILabel*)[[scrollview subviews] objectAtIndex:pageNumber]; | ||
[oneLabel setFont:[UIFont systemFontOfSize:14]]; | ||
[oneLabel setTextColor:[UIColor colorWithHexString:@"0xBABABA"]]; | ||
UILabel *twoLabel = (UILabel*)[[scrollview subviews] objectAtIndex:pageNumber+1]; | ||
[twoLabel setFont:[UIFont systemFontOfSize:16]]; | ||
[twoLabel setTextColor:[UIColor colorWithHexString:@"0x717171"]]; | ||
|
||
UILabel *currentLabel = (UILabel*)[[scrollview subviews] objectAtIndex:pageNumber+2]; | ||
[currentLabel setFont:[UIFont systemFontOfSize:18]]; | ||
[currentLabel setTextColor:[UIColor blackColor]]; | ||
|
||
UILabel *threeLabel = (UILabel*)[[scrollview subviews] objectAtIndex:pageNumber+3]; | ||
[threeLabel setFont:[UIFont systemFontOfSize:16]]; | ||
[threeLabel setTextColor:[UIColor colorWithHexString:@"0x717171"]]; | ||
UILabel *fourLabel = (UILabel*)[[scrollview subviews] objectAtIndex:pageNumber+4]; | ||
[fourLabel setFont:[UIFont systemFontOfSize:14]]; | ||
[fourLabel setTextColor:[UIColor colorWithHexString:@"0xBABABA"]]; | ||
} | ||
|
||
#pragma mark - UIScrollViewDelegate | ||
- (void)scrollViewDidScroll:(UIScrollView *)aScrollView { | ||
int y = aScrollView.contentOffset.y; | ||
NSInteger page = aScrollView.contentOffset.y/((self.bounds.size.height/5)); | ||
|
||
if (y>2*(self.bounds.size.height/5)) { | ||
_curPage = [self validPageValue:_curPage+1]; | ||
[self loadData]; | ||
} | ||
if (y<=0) { | ||
_curPage = [self validPageValue:_curPage-1]; | ||
[self loadData]; | ||
} | ||
// //往下翻一张 | ||
// if(x >= (4*self.frame.size.width)) { | ||
// _curPage = [self validPageValue:_curPage+1]; | ||
// [self loadData]; | ||
// } | ||
// | ||
// //往上翻 | ||
// if(x <= 0) { | ||
// | ||
// } | ||
if (page>1 || page <=0) { | ||
[self setAfterScrollShowView:aScrollView andCurrentPage:1]; | ||
} | ||
if ([_delegate respondsToSelector:@selector(scrollviewDidChangeNumber)]) { | ||
[_delegate scrollviewDidChangeNumber]; | ||
} | ||
} | ||
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView | ||
{ | ||
[self setAfterScrollShowView:scrollView andCurrentPage:1]; | ||
} | ||
|
||
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate | ||
{ | ||
[_scrollView setContentOffset:CGPointMake(0, (self.bounds.size.height/5)) animated:YES]; | ||
[self setAfterScrollShowView:scrollView andCurrentPage:1]; | ||
if ([_delegate respondsToSelector:@selector(scrollviewDidChangeNumber)]) { | ||
[_delegate scrollviewDidChangeNumber]; | ||
} | ||
} | ||
|
||
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView | ||
{ | ||
[self setAfterScrollShowView:scrollView andCurrentPage:1]; | ||
} | ||
|
||
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { | ||
[_scrollView setContentOffset:CGPointMake(0, (self.bounds.size.height/5)) animated:YES]; | ||
[self setAfterScrollShowView:scrollView andCurrentPage:1]; | ||
if ([_delegate respondsToSelector:@selector(scrollviewDidChangeNumber)]) { | ||
[_delegate scrollviewDidChangeNumber]; | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// ____ ___ _ ___ _____ ____ ____ ____ | ||
// | \ / \ | T / _]/ ___/ / T| \| \ | ||
// | o )Y Y| | / [_( \_ Y o || o ) o ) | ||
// | _/ | O || l___ Y _]\__ T| || _/| _/ | ||
// | | | || T| [_ / \ || _ || | | | | ||
// | | l !| || T\ || | || | | | | ||
// l__j \___/ l_____jl_____j \___jl__j__jl__j l__j | ||
// | ||
// | ||
// Powered by Polesapp.com | ||
// | ||
// | ||
// UIColor+HcdCustom.h | ||
// | ||
// | ||
// Created by fangmi-huangchengda on 15/7/16. | ||
// | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface UIColor (HcdCustom) | ||
|
||
@property (nonatomic, readonly) CGColorSpaceModel colorSpaceModel; | ||
@property (nonatomic, readonly) BOOL canProvideRGBComponents; | ||
@property (nonatomic, readonly) CGFloat red; // Only valid if canProvideRGBComponents is YES | ||
@property (nonatomic, readonly) CGFloat green; // Only valid if canProvideRGBComponents is YES | ||
@property (nonatomic, readonly) CGFloat blue; // Only valid if canProvideRGBComponents is YES | ||
@property (nonatomic, readonly) CGFloat white; // Only valid if colorSpaceModel == kCGColorSpaceModelMonochrome | ||
@property (nonatomic, readonly) CGFloat alpha; | ||
@property (nonatomic, readonly) UInt32 rgbHex; | ||
|
||
+ (UIColor *)colorWithRGBHex:(UInt32)hex; | ||
+ (UIColor *)colorWithHexString:(NSString *)stringToConvert; | ||
+ (UIColor *)colorWithHexString:(NSString *)stringToConvert andAlpha:(CGFloat)alpha; | ||
@end |
Oops, something went wrong.