diff --git a/ManagerDemo.xcodeproj/project.pbxproj b/ManagerDemo.xcodeproj/project.pbxproj index 783fed8..8070820 100644 --- a/ManagerDemo.xcodeproj/project.pbxproj +++ b/ManagerDemo.xcodeproj/project.pbxproj @@ -68,6 +68,18 @@ A9AF6CA41994D0660076C0EE /* ad2@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6CA11994D0660076C0EE /* ad2@2x.png */; }; A9AF6CA51994D0660076C0EE /* ad3@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6CA21994D0660076C0EE /* ad3@2x.png */; }; A9AF6CA61994D0660076C0EE /* ad4@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9AF6CA31994D0660076C0EE /* ad4@2x.png */; }; + A9EAA035199857F5001A872A /* HomeMainView.m in Sources */ = {isa = PBXBuildFile; fileRef = A9EAA034199857F5001A872A /* HomeMainView.m */; }; + A9EAA04019985EDE001A872A /* HomeMainView.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9EAA03F19985EDE001A872A /* HomeMainView.xib */; }; + A9EAA04519986DC3001A872A /* fund_cell_label_bg_blue@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9EAA04119986DC3001A872A /* fund_cell_label_bg_blue@2x.png */; }; + A9EAA04619986DC3001A872A /* fund_cell_label_bg_gray@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9EAA04219986DC3001A872A /* fund_cell_label_bg_gray@2x.png */; }; + A9EAA04719986DC3001A872A /* fund_cell_label_bg_green@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9EAA04319986DC3001A872A /* fund_cell_label_bg_green@2x.png */; }; + A9EAA04819986DC3001A872A /* fund_cell_label_bg_red@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9EAA04419986DC3001A872A /* fund_cell_label_bg_red@2x.png */; }; + A9EAA04A19986E8C001A872A /* pull_arrow_down_black@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9EAA04919986E8C001A872A /* pull_arrow_down_black@2x.png */; }; + A9EAA04E1998787B001A872A /* hk_home_center__cycle@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9EAA04B1998787B001A872A /* hk_home_center__cycle@2x.png */; }; + A9EAA04F1998787B001A872A /* hk_home_center_bg@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9EAA04C1998787B001A872A /* hk_home_center_bg@2x.png */; }; + A9EAA0501998787B001A872A /* hk_home_center_cover@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9EAA04D1998787B001A872A /* hk_home_center_cover@2x.png */; }; + A9EAA052199879CC001A872A /* pie_chart_center.png in Resources */ = {isa = PBXBuildFile; fileRef = A9EAA051199879CC001A872A /* pie_chart_center.png */; }; + A9EAA05619988C55001A872A /* MRCircularProgressView.m in Sources */ = {isa = PBXBuildFile; fileRef = A9EAA05519988C55001A872A /* MRCircularProgressView.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -163,6 +175,20 @@ A9AF6CA11994D0660076C0EE /* ad2@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ad2@2x.png"; sourceTree = ""; }; A9AF6CA21994D0660076C0EE /* ad3@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ad3@2x.png"; sourceTree = ""; }; A9AF6CA31994D0660076C0EE /* ad4@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ad4@2x.png"; sourceTree = ""; }; + A9EAA033199857F5001A872A /* HomeMainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HomeMainView.h; sourceTree = ""; }; + A9EAA034199857F5001A872A /* HomeMainView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeMainView.m; sourceTree = ""; }; + A9EAA03F19985EDE001A872A /* HomeMainView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = HomeMainView.xib; sourceTree = ""; }; + A9EAA04119986DC3001A872A /* fund_cell_label_bg_blue@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "fund_cell_label_bg_blue@2x.png"; sourceTree = ""; }; + A9EAA04219986DC3001A872A /* fund_cell_label_bg_gray@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "fund_cell_label_bg_gray@2x.png"; sourceTree = ""; }; + A9EAA04319986DC3001A872A /* fund_cell_label_bg_green@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "fund_cell_label_bg_green@2x.png"; sourceTree = ""; }; + A9EAA04419986DC3001A872A /* fund_cell_label_bg_red@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "fund_cell_label_bg_red@2x.png"; sourceTree = ""; }; + A9EAA04919986E8C001A872A /* pull_arrow_down_black@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "pull_arrow_down_black@2x.png"; sourceTree = ""; }; + A9EAA04B1998787B001A872A /* hk_home_center__cycle@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "hk_home_center__cycle@2x.png"; sourceTree = ""; }; + A9EAA04C1998787B001A872A /* hk_home_center_bg@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "hk_home_center_bg@2x.png"; sourceTree = ""; }; + A9EAA04D1998787B001A872A /* hk_home_center_cover@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "hk_home_center_cover@2x.png"; sourceTree = ""; }; + A9EAA051199879CC001A872A /* pie_chart_center.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pie_chart_center.png; sourceTree = ""; }; + A9EAA05419988C55001A872A /* MRCircularProgressView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MRCircularProgressView.h; sourceTree = ""; }; + A9EAA05519988C55001A872A /* MRCircularProgressView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MRCircularProgressView.m; sourceTree = ""; }; C7B3792862C24377B1ACD469 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -198,6 +224,9 @@ A9AA325D19970335000BE4FB /* HomeAdView.m */, A9AA325E19970335000BE4FB /* ImagePlayerView.h */, A9AA325F19970335000BE4FB /* ImagePlayerView.m */, + A9EAA033199857F5001A872A /* HomeMainView.h */, + A9EAA034199857F5001A872A /* HomeMainView.m */, + A9EAA03F19985EDE001A872A /* HomeMainView.xib */, ); path = HomeView; sourceTree = ""; @@ -306,6 +335,7 @@ A9AF6C4A19949B510076C0EE /* Common */ = { isa = PBXGroup; children = ( + A9EAA05319988C55001A872A /* MRCircularProgressView */, A9AF6C7E1994C5700076C0EE /* MJRefresh */, A9AF6C4B19949B7B0076C0EE /* ManagerConstants.h */, ); @@ -315,6 +345,15 @@ A9AF6C4D19949CAD0076C0EE /* Resource */ = { isa = PBXGroup; children = ( + A9EAA051199879CC001A872A /* pie_chart_center.png */, + A9EAA04B1998787B001A872A /* hk_home_center__cycle@2x.png */, + A9EAA04C1998787B001A872A /* hk_home_center_bg@2x.png */, + A9EAA04D1998787B001A872A /* hk_home_center_cover@2x.png */, + A9EAA04919986E8C001A872A /* pull_arrow_down_black@2x.png */, + A9EAA04119986DC3001A872A /* fund_cell_label_bg_blue@2x.png */, + A9EAA04219986DC3001A872A /* fund_cell_label_bg_gray@2x.png */, + A9EAA04319986DC3001A872A /* fund_cell_label_bg_green@2x.png */, + A9EAA04419986DC3001A872A /* fund_cell_label_bg_red@2x.png */, A9AF6C9F1994D0210076C0EE /* ad1@2x.png */, A9AF6CA11994D0660076C0EE /* ad2@2x.png */, A9AF6CA21994D0660076C0EE /* ad3@2x.png */, @@ -376,6 +415,15 @@ path = MainView; sourceTree = ""; }; + A9EAA05319988C55001A872A /* MRCircularProgressView */ = { + isa = PBXGroup; + children = ( + A9EAA05419988C55001A872A /* MRCircularProgressView.h */, + A9EAA05519988C55001A872A /* MRCircularProgressView.m */, + ); + path = MRCircularProgressView; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -455,19 +503,26 @@ buildActionMask = 2147483647; files = ( A9AF6C43199498C40076C0EE /* MyViewController.xib in Resources */, + A9EAA04719986DC3001A872A /* fund_cell_label_bg_green@2x.png in Resources */, A9AF6C731994B5890076C0EE /* icon_bar_share@2x.png in Resources */, + A9EAA04019985EDE001A872A /* HomeMainView.xib in Resources */, A9AF6C6919949CD30076C0EE /* icon_dock_session@2x.png in Resources */, A9AF6C5C19949CD30076C0EE /* icon_dock_forum_actived@2x.png in Resources */, A9AF6CA61994D0660076C0EE /* ad4@2x.png in Resources */, A9AF6C48199498D10076C0EE /* MoreViewController.xib in Resources */, + A9EAA04A19986E8C001A872A /* pull_arrow_down_black@2x.png in Resources */, A9AF6C6119949CD30076C0EE /* icon_dock_mine@2x.png in Resources */, A9AF6CA51994D0660076C0EE /* ad3@2x.png in Resources */, + A9EAA04819986DC3001A872A /* fund_cell_label_bg_red@2x.png in Resources */, A9AF6C5E19949CD30076C0EE /* icon_dock_home_actived@2x.png in Resources */, + A9EAA04519986DC3001A872A /* fund_cell_label_bg_blue@2x.png in Resources */, A9AF6C6219949CD30076C0EE /* icon_dock_rt_actived@2x.png in Resources */, A9AF6C781994B5890076C0EE /* icon_share_default.png in Resources */, A9AF6C741994B5890076C0EE /* icon_indicate_add_module@2x.png in Resources */, A9AF6C751994B5890076C0EE /* icon_indicate_arrow_don@2x.png in Resources */, A9AF6C5D19949CD30076C0EE /* icon_dock_forum@2x.png in Resources */, + A9EAA04E1998787B001A872A /* hk_home_center__cycle@2x.png in Resources */, + A9EAA0501998787B001A872A /* hk_home_center_cover@2x.png in Resources */, A9AF6C6719949CD30076C0EE /* icon_dock_session_actived@2x.png in Resources */, A9AF6C771994B5890076C0EE /* icon_indicate_more@2x.png in Resources */, A9AA325A199702DB000BE4FB /* Images.xcassets in Resources */, @@ -479,11 +534,14 @@ A9AF6C791994B5890076C0EE /* tabbarShadowImage@2x.png in Resources */, A9AF6BF719947DD00076C0EE /* InfoPlist.strings in Resources */, A9AF6C761994B5890076C0EE /* icon_indicate_more_down@2x.png in Resources */, + A9EAA04619986DC3001A872A /* fund_cell_label_bg_gray@2x.png in Resources */, + A9EAA052199879CC001A872A /* pie_chart_center.png in Resources */, A9AF6CA41994D0660076C0EE /* ad2@2x.png in Resources */, A9AF6C34199484200076C0EE /* HomeViewController.xib in Resources */, A9AF6C0019947DD00076C0EE /* Main.storyboard in Resources */, A9AF6C3E199486CA0076C0EE /* ProductListViewController.xib in Resources */, A9AF6C2F199483520076C0EE /* MainViewController.xib in Resources */, + A9EAA04F1998787B001A872A /* hk_home_center_bg@2x.png in Resources */, A9AF6C6319949CD30076C0EE /* icon_dock_rt@2x.png in Resources */, A9AF6C721994B5890076C0EE /* icon_bar_card@2x.png in Resources */, A9AF6C6819949CD30076C0EE /* icon_dock_session_msg@2x.png in Resources */, @@ -540,12 +598,14 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + A9EAA05619988C55001A872A /* MRCircularProgressView.m in Sources */, A9AF6C961994C5700076C0EE /* UIView+Extension.m in Sources */, A9AF6C921994C5700076C0EE /* MJRefreshFooterView.m in Sources */, A9AA326019970335000BE4FB /* HomeAdView.m in Sources */, A9AF6C3D199486CA0076C0EE /* ProductListViewController.m in Sources */, A9AF6C941994C5700076C0EE /* UIScrollView+Extension.m in Sources */, A9AF6C47199498D10076C0EE /* MoreViewController.m in Sources */, + A9EAA035199857F5001A872A /* HomeMainView.m in Sources */, A9AF6C951994C5700076C0EE /* UIScrollView+MJRefresh.m in Sources */, A9AA326119970335000BE4FB /* ImagePlayerView.m in Sources */, A9AF6C0319947DD00076C0EE /* ViewController.m in Sources */, diff --git a/ManagerDemo/Common/MJRefresh/MJRefresh.bundle/pull_arrow_down_black@2x.png b/ManagerDemo/Common/MJRefresh/MJRefresh.bundle/pull_arrow_down_black@2x.png new file mode 100644 index 0000000..1982566 Binary files /dev/null and b/ManagerDemo/Common/MJRefresh/MJRefresh.bundle/pull_arrow_down_black@2x.png differ diff --git a/ManagerDemo/Common/MJRefresh/MJRefreshBaseView.m b/ManagerDemo/Common/MJRefresh/MJRefreshBaseView.m index 21bd599..2c7538b 100755 --- a/ManagerDemo/Common/MJRefresh/MJRefreshBaseView.m +++ b/ManagerDemo/Common/MJRefresh/MJRefreshBaseView.m @@ -45,7 +45,7 @@ - (UIImageView *)arrowImage { if (!_arrowImage) { - UIImageView *arrowImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:MJRefreshSrcName(@"arrow.png")]]; + UIImageView *arrowImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:MJRefreshSrcName(@"pull_arrow_down_black.png")]]; arrowImage.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; [self addSubview:_arrowImage = arrowImage]; } diff --git a/ManagerDemo/Common/MRCircularProgressView/MRCircularProgressView.h b/ManagerDemo/Common/MRCircularProgressView/MRCircularProgressView.h new file mode 100755 index 0000000..624bd02 --- /dev/null +++ b/ManagerDemo/Common/MRCircularProgressView/MRCircularProgressView.h @@ -0,0 +1,56 @@ +// +// MRCircularProgressView.h +// MRCircularProgressView +// +// Created by Jose Luis Martinez de la Riva on 30/01/14. +// +// Copyright (c) 2014 http://martinezdelariva.com +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE +// + +#import + +@interface MRCircularProgressView : UIView + +// Set delegate to allow callbacks (animataionDidFinish, etc) +@property (weak, nonatomic) id delegate; + +// Color of the progress arc +@property (strong, nonatomic) UIColor *progressColor; + +// Width of progress arc +@property (assign, nonatomic) CGFloat progressArcWidth; + +// Width of wrapper arc +@property (assign, nonatomic) CGFloat wrapperArcWidth; + +// Color of wrapper arc +@property (strong, nonatomic) UIColor *wrapperColor; + +// Set new progress (0.0f - 1.0f) with animation option +- (void)setProgress:(CGFloat)progress animated:(BOOL)animate; + +// Set new progress (0.0f - 1.0f) animated with custom duration +- (void)setProgress:(CGFloat)progress duration:(CFTimeInterval)duration; + +-(void)pause; + +-(void)resume; +@end diff --git a/ManagerDemo/Common/MRCircularProgressView/MRCircularProgressView.m b/ManagerDemo/Common/MRCircularProgressView/MRCircularProgressView.m new file mode 100755 index 0000000..e51a023 --- /dev/null +++ b/ManagerDemo/Common/MRCircularProgressView/MRCircularProgressView.m @@ -0,0 +1,209 @@ +// +// MRCircularProgressView.m +// MRCircularProgressView +// +// Created by Jose Luis Martinez de la Riva on 30/01/14. +// +// Copyright (c) 2014 http://martinezdelariva.com +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE +// + +#import "MRCircularProgressView.h" + +@interface MRCircularProgressView() +@property (strong, nonatomic) CAShapeLayer *shapeLayer; +@property (assign, nonatomic) CGFloat currentProgress; +@property (assign, nonatomic) CGFloat lastProgress; +@property (assign, nonatomic) BOOL animated; +@property (assign, nonatomic) CFTimeInterval duration; +@end + +@implementation MRCircularProgressView + +- (void)awakeFromNib +{ + [self setUp]; +} + +- (id)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + // Initialization code + [self setUp]; + } + return self; +} + +- (void)setUp +{ + // Init variables + self.delegate = nil; + self.currentProgress = 0.0f; + self.lastProgress = 0.0f; + self.animated = YES; + self.progressColor = [UIColor blueColor]; + self.wrapperColor = self.progressColor; + self.duration = 0.5; + self.progressArcWidth = 3.0f; + self.wrapperArcWidth = 1.f; +} + +- (void)drawRect:(CGRect)rect +{ + // Outer circle + CGRect newRect = ({ + CGRect insetRect = CGRectInset(rect, self.wrapperArcWidth + 0.5f, self.wrapperArcWidth + 0.5f); + CGRect newRect = insetRect; + newRect.size.width = MIN(CGRectGetMaxX(insetRect), CGRectGetMaxY(insetRect)); + newRect.size.height = newRect.size.width; + newRect.origin.x = insetRect.origin.x + (CGRectGetWidth(insetRect) - CGRectGetWidth(newRect)) / 2; + newRect.origin.y = insetRect.origin.y + (CGRectGetHeight(insetRect) - CGRectGetHeight(newRect)) / 2; + newRect; + }); + UIBezierPath *outerCircle = [UIBezierPath bezierPathWithOvalInRect:newRect]; + [self.wrapperColor setStroke]; + outerCircle.lineWidth = self.wrapperArcWidth; + [outerCircle stroke]; +} + +- (CGPathRef)progressPath +{ + // Offset + CGFloat offset = - M_PI_2; + + // EndAngle + CGFloat endAngle = self.currentProgress * 2 * M_PI + offset; + + // Center + CGRect rect = self.bounds; + CGPoint center = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect)); + + // Radius + CGFloat radius = MIN(center.x, center.y) - self.progressArcWidth / 2; + + // Inner arc + UIBezierPath *arcPath = [UIBezierPath bezierPathWithArcCenter:center + radius:radius + startAngle:offset + endAngle:endAngle + clockwise:1]; + + return arcPath.CGPath; +} + +- (void)layoutSubviews +{ + [super layoutSubviews]; + [self refreshShapeLayer]; +} + +#pragma mark - Getters methods + +- (CAShapeLayer *)shapeLayer +{ + if (!_shapeLayer) { + _shapeLayer = [CAShapeLayer layer]; + _shapeLayer.lineWidth = self.progressArcWidth; + _shapeLayer.fillColor = nil; + _shapeLayer.lineJoin = kCALineJoinBevel; + _shapeLayer.speed=1.0f; + [self.layer addSublayer:_shapeLayer]; + } + + // This will allow the color to be change in the middle of the duration period + _shapeLayer.strokeColor = self.progressColor.CGColor; + + return _shapeLayer; +} + +#pragma mark - Private methods + +- (void)refreshShapeLayer +{ + // Update path + self.shapeLayer.path = [self progressPath]; + + // Animation + if (self.currentProgress != self.lastProgress && self.animated) { + // From value + CGFloat fromValue = (1 * self.lastProgress) / self.currentProgress; + + // Animation + CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; + pathAnimation.delegate = self.delegate; + pathAnimation.duration = self.duration; + pathAnimation.fromValue = @(fromValue); + pathAnimation.toValue = @(1.0f); + [self.shapeLayer addAnimation:pathAnimation forKey:@"strokeEnd"]; + } + + // Update lastProgress + self.lastProgress = self.currentProgress; +} + +#pragma mark - Public methods + +- (void)setProgress:(CGFloat)progress animated:(BOOL)animate +{ + self.currentProgress = MAX(MIN(progress, 1.0f), 0.0f); + self.animated = animate; + if (progress==0.0) { + //means reset been tapped + self.shapeLayer.speed=1; + + } + [self setNeedsLayout]; +} + +- (void)setProgress:(CGFloat)progress duration:(CFTimeInterval)duration +{ + + self.duration = duration; + [self setProgress:progress animated:YES]; +} + +#pragma mark pause/resume +-(void)pause +{ + + + if (self.currentProgress !=0) { + CFTimeInterval pausedTime = [self.shapeLayer convertTime:CACurrentMediaTime() fromLayer:nil]; + self.shapeLayer.speed = 0.0; + self.shapeLayer.timeOffset = pausedTime; + } + +} + +-(void)resume +{ + if (self.shapeLayer.speed==0) { + CFTimeInterval pausedTime = [self.shapeLayer timeOffset]; + self.shapeLayer.speed = 1.0; + self.shapeLayer.timeOffset = 0.0; + self.shapeLayer.beginTime = 0.0; + CFTimeInterval timeSincePause = [self.shapeLayer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime; + self.shapeLayer.beginTime = timeSincePause; + } + +} + +@end diff --git a/ManagerDemo/MainView/HomeView/HomeMainView.h b/ManagerDemo/MainView/HomeView/HomeMainView.h new file mode 100644 index 0000000..a2315aa --- /dev/null +++ b/ManagerDemo/MainView/HomeView/HomeMainView.h @@ -0,0 +1,22 @@ +// +// HomeMainView.h +// ManagerDemo +// +// Created by xmfish on 14-8-11. +// Copyright (c) 2014年 ash. All rights reserved. +// + +#import +#import "MRCircularProgressView.h" +@interface HomeMainView : UIView +@property (weak, nonatomic) IBOutlet UILabel *typeLabel; +@property (weak, nonatomic) IBOutlet UILabel *nameLabel; +@property (weak, nonatomic) IBOutlet MRCircularProgressView *percentView; +- (IBAction)percentBtnClick:(id)sender; +@property (weak, nonatomic) IBOutlet DTAttributedLabel *percentLabel; +@property (weak, nonatomic) IBOutlet DTAttributedLabel *expectLabel; +@property (weak, nonatomic) IBOutlet DTAttributedLabel *timeLabel; +@property (weak, nonatomic) IBOutlet UILabel *infoLabel; +- (IBAction)sureBtnClick:(id)sender; + +@end diff --git a/ManagerDemo/MainView/HomeView/HomeMainView.m b/ManagerDemo/MainView/HomeView/HomeMainView.m new file mode 100644 index 0000000..405c408 --- /dev/null +++ b/ManagerDemo/MainView/HomeView/HomeMainView.m @@ -0,0 +1,88 @@ +// +// HomeMainView.m +// ManagerDemo +// +// Created by xmfish on 14-8-11. +// Copyright (c) 2014年 ash. All rights reserved. +// + +#import "HomeMainView.h" + +@implementation HomeMainView +{ + CGFloat progressPercent; +} +- (id)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + // Initialization code + + } + return self; +} +-(void)awakeFromNib{ + [super awakeFromNib]; +} + +// Only override drawRect: if you perform custom drawing. +// An empty implementation adversely affects performance during animation. +- (void)drawRect:(CGRect)rect +{ + // Drawing code + + progressPercent = 0.33; + //进度条 + _percentView.delegate = self; + _percentView.wrapperColor = [UIColor clearColor]; + _percentView.progressColor = [UIColor redColor]; + _percentView.progressArcWidth = 10.0f; + [_percentView setProgress:progressPercent duration:1.0]; + // + _typeLabel.transform = CGAffineTransformMakeRotation( M_PI/4 ); + + //中间文字 + NSString* htmlStr = @"9%"; + NSData *data = [htmlStr dataUsingEncoding:NSUTF8StringEncoding]; + NSDictionary* optionsDic = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:kCTTextAlignmentCenter],DTDefaultTextAlignment, nil]; + NSAttributedString *percentString = [[NSAttributedString alloc] initWithHTMLData:data options:optionsDic documentAttributes:nil]; + _percentLabel.attributedString = percentString; + //预期 + htmlStr = @"四个大字10.20%"; + data = [htmlStr dataUsingEncoding:NSUTF8StringEncoding]; + percentString = [[NSAttributedString alloc] initWithHTMLData:data documentAttributes:NULL]; + _expectLabel.attributedString = percentString; + //时间 + htmlStr = [NSString stringWithFormat:@"%d个月%d",15,50]; + data = [htmlStr dataUsingEncoding:NSUTF8StringEncoding]; + percentString = [[NSAttributedString alloc] initWithHTMLData:data documentAttributes:NULL]; + _timeLabel.attributedString = percentString; +} + + +- (IBAction)percentBtnClick:(id)sender { + DLog("首页点击"); + [_percentView setProgress:0.00 animated:YES]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC*0.2), + dispatch_get_main_queue(), ^(){ + [_percentView setProgress:progressPercent duration:1.0]; + + }); + +} +- (IBAction)sureBtnClick:(id)sender { + DLog(@"确认"); +} + +#pragma mark - CABasicAnimationDelegate + +- (void)animationDidStart:(CAAnimation *)theAnimation +{ + DLog(@"Animation started"); +} + +- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag +{ + DLog(@"Animation stopped"); +} +@end diff --git a/ManagerDemo/MainView/HomeView/HomeMainView.xib b/ManagerDemo/MainView/HomeView/HomeMainView.xib new file mode 100644 index 0000000..251bdac --- /dev/null +++ b/ManagerDemo/MainView/HomeView/HomeMainView.xib @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ManagerDemo/MainViewControll/HomeViewController.m b/ManagerDemo/MainViewControll/HomeViewController.m index 46a6b10..e768023 100644 --- a/ManagerDemo/MainViewControll/HomeViewController.m +++ b/ManagerDemo/MainViewControll/HomeViewController.m @@ -9,6 +9,7 @@ #import "HomeViewController.h" #import "MJRefresh.h" #import "HomeAdView.h" +#import "HomeMainView.h" @interface HomeViewController () @end @@ -77,11 +78,23 @@ return 1; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ - return 1; + return 2; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - return 120; + CGFloat height = 0.0; + switch (indexPath.row) { + case 0: + height = 160.0; + break; + case 1: + height = 280.0; + break; + default: + break; + } + return height; + } -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { @@ -89,8 +102,25 @@ UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:homeViewCell]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:homeViewCell]; - HomeAdView* homeAdView = [[HomeAdView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 120)]; - [cell addSubview:homeAdView]; + cell.selectionStyle = UITableViewCellSelectionStyleNone; + switch (indexPath.row) { + case 0:{ + HomeAdView* homeAdView = [[HomeAdView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 140)]; + [cell addSubview:homeAdView]; + } + break; + case 1:{ + NSArray *nib=[[NSBundle mainBundle]loadNibNamed:@"HomeMainView" owner:self options:nil]; + + HomeMainView* homeMainView = (HomeMainView*)[nib objectAtIndex:0]; + CGRect frame = homeMainView.frame; + frame.origin.x = 20; + homeMainView.frame = frame; + [cell addSubview:homeMainView]; + } + default: + break; + } } return cell; diff --git a/ManagerDemo/ManagerDemo-Prefix.pch b/ManagerDemo/ManagerDemo-Prefix.pch index 69bda6a..f7b6a7b 100644 --- a/ManagerDemo/ManagerDemo-Prefix.pch +++ b/ManagerDemo/ManagerDemo-Prefix.pch @@ -15,5 +15,6 @@ #import #import "ManagerConstants.h" #import "MKNetworkKit.h" + #import "DTCoreText.h" #import "STableViewController.h" #endif diff --git a/ManagerDemo/Resource/fund_cell_label_bg_blue@2x.png b/ManagerDemo/Resource/fund_cell_label_bg_blue@2x.png new file mode 100644 index 0000000..e888410 Binary files /dev/null and b/ManagerDemo/Resource/fund_cell_label_bg_blue@2x.png differ diff --git a/ManagerDemo/Resource/fund_cell_label_bg_gray@2x.png b/ManagerDemo/Resource/fund_cell_label_bg_gray@2x.png new file mode 100644 index 0000000..d057b87 Binary files /dev/null and b/ManagerDemo/Resource/fund_cell_label_bg_gray@2x.png differ diff --git a/ManagerDemo/Resource/fund_cell_label_bg_green@2x.png b/ManagerDemo/Resource/fund_cell_label_bg_green@2x.png new file mode 100644 index 0000000..f75f4d6 Binary files /dev/null and b/ManagerDemo/Resource/fund_cell_label_bg_green@2x.png differ diff --git a/ManagerDemo/Resource/fund_cell_label_bg_red@2x.png b/ManagerDemo/Resource/fund_cell_label_bg_red@2x.png new file mode 100644 index 0000000..b613ed1 Binary files /dev/null and b/ManagerDemo/Resource/fund_cell_label_bg_red@2x.png differ diff --git a/ManagerDemo/Resource/hk_home_center__cycle@2x.png b/ManagerDemo/Resource/hk_home_center__cycle@2x.png new file mode 100644 index 0000000..202dbe4 Binary files /dev/null and b/ManagerDemo/Resource/hk_home_center__cycle@2x.png differ diff --git a/ManagerDemo/Resource/hk_home_center_bg@2x.png b/ManagerDemo/Resource/hk_home_center_bg@2x.png new file mode 100644 index 0000000..109ec0b Binary files /dev/null and b/ManagerDemo/Resource/hk_home_center_bg@2x.png differ diff --git a/ManagerDemo/Resource/hk_home_center_cover@2x.png b/ManagerDemo/Resource/hk_home_center_cover@2x.png new file mode 100644 index 0000000..11f9ef3 Binary files /dev/null and b/ManagerDemo/Resource/hk_home_center_cover@2x.png differ diff --git a/ManagerDemo/Resource/pie_chart_center.png b/ManagerDemo/Resource/pie_chart_center.png new file mode 100644 index 0000000..044c09c Binary files /dev/null and b/ManagerDemo/Resource/pie_chart_center.png differ diff --git a/ManagerDemo/Resource/pull_arrow_down_black@2x.png b/ManagerDemo/Resource/pull_arrow_down_black@2x.png new file mode 100644 index 0000000..1982566 Binary files /dev/null and b/ManagerDemo/Resource/pull_arrow_down_black@2x.png differ