From a9d8353277f775f79e07f57429e818f7bc489212 Mon Sep 17 00:00:00 2001 From: HK Date: Tue, 9 Jul 2019 18:18:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E5=88=92=E7=BA=BF=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E8=87=AA=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WMPageController/WMMenuView/WMMenuView.h | 2 ++ WMPageController/WMMenuView/WMMenuView.m | 6 +++-- WMPageController/WMMenuView/WMProgressView.h | 3 +++ WMPageController/WMMenuView/WMProgressView.m | 13 ++++++++--- WMPageController/WMPageController.h | 6 +++++ WMPageController/WMPageController.m | 3 +++ .../AppIcon.appiconset/Contents.json | 5 ++++ .../tab_selected.imageset/Contents.json | 22 ++++++++++++++++++ .../tab_selected.imageset/tab_selected@2x.png | Bin 0 -> 313 bytes .../tab_selected.imageset/tab_selected@3x.png | Bin 0 -> 493 bytes .../WMMainTableViewController.m | 5 ++++ 11 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 WMPageControllerDemo/WMPageControllerExample/WMPageControllerExample/Assets.xcassets/tab_selected.imageset/Contents.json create mode 100644 WMPageControllerDemo/WMPageControllerExample/WMPageControllerExample/Assets.xcassets/tab_selected.imageset/tab_selected@2x.png create mode 100644 WMPageControllerDemo/WMPageControllerExample/WMPageControllerExample/Assets.xcassets/tab_selected.imageset/tab_selected@3x.png diff --git a/WMPageController/WMMenuView/WMMenuView.h b/WMPageController/WMMenuView/WMMenuView.h index 13f57ce..806d5e9 100755 --- a/WMPageController/WMMenuView/WMMenuView.h +++ b/WMPageController/WMMenuView/WMMenuView.h @@ -81,6 +81,8 @@ typedef NS_ENUM(NSUInteger, WMMenuViewLayoutMode) { @property (nonatomic, assign) WMMenuViewLayoutMode layoutMode; @property (nonatomic, assign) CGFloat contentMargin; @property (nonatomic, strong) UIColor *lineColor; +/** lineImage优先于lineColor */ +@property (nonatomic, strong) UIImage *lineImage; @property (nonatomic, assign) CGFloat progressViewBottomSpace; @property (nonatomic, weak) id delegate; @property (nonatomic, weak) id dataSource; diff --git a/WMPageController/WMMenuView/WMMenuView.m b/WMPageController/WMMenuView/WMMenuView.m index ac5bc3e..9f8a6ff 100755 --- a/WMPageController/WMMenuView/WMMenuView.m +++ b/WMPageController/WMMenuView/WMMenuView.m @@ -447,7 +447,8 @@ - (void)makeStyle { isTriangle:(self.style == WMMenuViewStyleTriangle) hasBorder:(self.style == WMMenuViewStyleSegmented) hollow:(self.style == WMMenuViewStyleFloodHollow) - cornerRadius:self.progressViewCornerRadius]; + cornerRadius:self.progressViewCornerRadius + lineImage:self.lineImage]; } - (void)deselectedItemsIfNeeded { @@ -563,10 +564,11 @@ - (CGFloat)itemMarginAtIndex:(NSInteger)index { } // MARK:Progress View -- (void)addProgressViewWithFrame:(CGRect)frame isTriangle:(BOOL)isTriangle hasBorder:(BOOL)hasBorder hollow:(BOOL)isHollow cornerRadius:(CGFloat)cornerRadius { +- (void)addProgressViewWithFrame:(CGRect)frame isTriangle:(BOOL)isTriangle hasBorder:(BOOL)hasBorder hollow:(BOOL)isHollow cornerRadius:(CGFloat)cornerRadius lineImage:(UIImage *)lineImage { WMProgressView *pView = [[WMProgressView alloc] initWithFrame:frame]; pView.itemFrames = [self convertProgressWidthsToFrames]; pView.color = self.lineColor.CGColor; + pView.image = lineImage; pView.isTriangle = isTriangle; pView.hasBorder = hasBorder; pView.hollow = isHollow; diff --git a/WMPageController/WMMenuView/WMProgressView.h b/WMPageController/WMMenuView/WMProgressView.h index f406db6..df81fab 100755 --- a/WMPageController/WMMenuView/WMProgressView.h +++ b/WMPageController/WMMenuView/WMProgressView.h @@ -11,7 +11,10 @@ NS_ASSUME_NONNULL_BEGIN @interface WMProgressView : UIView @property (nonatomic, strong) NSArray *itemFrames; +/** 若image有值,优先使用image*/ @property (nonatomic, assign) CGColorRef color; +@property (nonatomic, strong) UIImage *image; // image优先于color + @property (nonatomic, assign) CGFloat progress; /** 进度条的速度因数,默认为 15,越小越快, 大于 0 */ @property (nonatomic, assign) CGFloat speedFactor; diff --git a/WMPageController/WMMenuView/WMProgressView.m b/WMPageController/WMMenuView/WMProgressView.m index 40923fa..ed67e98 100755 --- a/WMPageController/WMMenuView/WMProgressView.m +++ b/WMPageController/WMMenuView/WMProgressView.m @@ -117,7 +117,8 @@ - (void)drawRect:(CGRect)rect { return; } - UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(startX, lineWidth / 2.0, width, height - lineWidth) cornerRadius:self.cornerRadius]; + CGRect barframe = CGRectMake(startX, lineWidth / 2.0, width, height - lineWidth); + UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:barframe cornerRadius:self.cornerRadius]; CGContextAddPath(ctx, path.CGPath); if (self.hollow) { @@ -125,8 +126,14 @@ - (void)drawRect:(CGRect)rect { CGContextStrokePath(ctx); return; } - CGContextSetFillColorWithColor(ctx, self.color); - CGContextFillPath(ctx); + + if (self.image) { + CGContextDrawImage(ctx, barframe, self.image.CGImage); + } else { + CGContextSetFillColorWithColor(ctx, self.color); + CGContextFillPath(ctx); + } + if (self.hasBorder) { // 计算点 diff --git a/WMPageController/WMPageController.h b/WMPageController/WMPageController.h index 0836c95..b238860 100755 --- a/WMPageController/WMPageController.h +++ b/WMPageController/WMPageController.h @@ -232,6 +232,12 @@ extern NSString *const WMControllerDidFullyDisplayedNotification; */ @property (nonatomic, nullable, strong) UIColor *progressColor; +/** + * 进度条的填充图片,若该属性有值,progressColor属性将无效 + * The progress's image.if it's not empty,'progressColor' property will be ignored. + */ +@property (nonatomic, nullable, strong) UIImage *progressImage; + /** * 定制进度条在各个 item 下的宽度 */ diff --git a/WMPageController/WMPageController.m b/WMPageController/WMPageController.m index b72c62a..478f453 100755 --- a/WMPageController/WMPageController.m +++ b/WMPageController/WMPageController.m @@ -467,6 +467,9 @@ - (void)wm_addMenuView { if (self.progressColor) { menuView.lineColor = self.progressColor; } + if (self.progressImage) { + menuView.lineImage = self.progressImage; + } if (self.showOnNavigationBar && self.navigationController.navigationBar) { self.navigationItem.titleView = menuView; } else { diff --git a/WMPageControllerDemo/WMPageControllerExample/WMPageControllerExample/Assets.xcassets/AppIcon.appiconset/Contents.json b/WMPageControllerDemo/WMPageControllerExample/WMPageControllerExample/Assets.xcassets/AppIcon.appiconset/Contents.json index 1d060ed..d8db8d6 100644 --- a/WMPageControllerDemo/WMPageControllerExample/WMPageControllerExample/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/WMPageControllerDemo/WMPageControllerExample/WMPageControllerExample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -84,6 +84,11 @@ "idiom" : "ipad", "size" : "83.5x83.5", "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : { diff --git a/WMPageControllerDemo/WMPageControllerExample/WMPageControllerExample/Assets.xcassets/tab_selected.imageset/Contents.json b/WMPageControllerDemo/WMPageControllerExample/WMPageControllerExample/Assets.xcassets/tab_selected.imageset/Contents.json new file mode 100644 index 0000000..62022c9 --- /dev/null +++ b/WMPageControllerDemo/WMPageControllerExample/WMPageControllerExample/Assets.xcassets/tab_selected.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "tab_selected@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "tab_selected@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/WMPageControllerDemo/WMPageControllerExample/WMPageControllerExample/Assets.xcassets/tab_selected.imageset/tab_selected@2x.png b/WMPageControllerDemo/WMPageControllerExample/WMPageControllerExample/Assets.xcassets/tab_selected.imageset/tab_selected@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..c3b3fa74124daed07cbc36fb0ba5001c478edd82 GIT binary patch literal 313 zcmeAS@N?(olHy`uVBq!ia0vp^<{&l)Gmx};!nPks*$4Q9xc+bK{vX!ye_lNZ&9D0( z+VQ`z^?yw>hz%5<117Ut|F<^&k7@tk)9`At$W zR5Yf;DxO9BfTzUoJ^LNpb(jA>xgfsFSev)@*W9VvOLBMYo4@7nl=I*A`F?#}8_NFf zeqHl_o$s^%K7UhZwEKRg{{3HDt6zRQY5(hKZ5_jAO;t8_)uX3?PG#_P^>bP0l+XkK D0N<28 literal 0 HcmV?d00001 diff --git a/WMPageControllerDemo/WMPageControllerExample/WMPageControllerExample/Assets.xcassets/tab_selected.imageset/tab_selected@3x.png b/WMPageControllerDemo/WMPageControllerExample/WMPageControllerExample/Assets.xcassets/tab_selected.imageset/tab_selected@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..5fea6ea743535f2fe3008b4115e4fa1cf5db3002 GIT binary patch literal 493 zcmeAS@N?(olHy`uVBq!ia0vp^!9Xm+!3-pi8Gd{Qq`U)sLR|mX*8HDe2Ss5WAO?`k zYW?5Z1Y%5Rgo@0o`=8hHzpVLxdh7q%rvC|T|0mV|pIP_6x$%E=`~TjC{~e7V?@R!i z%D__+X ziH!)C>$ay1|EH@h6?k;y*~-Ur?AK12x*=+>nflA6z4zSo7vFtV5cO-@Ov%oqW>%+V z3>SEv^ixuzUKHts>GFn{6*jQgv3^?lb*}&NeUkpqTE7Hzh}?U|)z9BRnu;kybh+t;rD+}eC~O9?tf+f2gb7Z-r7jNyLU1F z_sp|?o28lVS?}{+`u(4io&3+Wr>peWE?;wRLdEMtzI>Hjt@nQGS8glu(fj+gTw{y( fg%#`m$*O;3_IjJVY1QgPqu6{1-oD!M<3T5?V literal 0 HcmV?d00001 diff --git a/WMPageControllerDemo/WMPageControllerExample/WMPageControllerExample/WMMainTableViewController.m b/WMPageControllerDemo/WMPageControllerExample/WMPageControllerExample/WMMainTableViewController.m index 60dd0ec..639f6da 100644 --- a/WMPageControllerDemo/WMPageControllerExample/WMPageControllerExample/WMMainTableViewController.m +++ b/WMPageControllerDemo/WMPageControllerExample/WMPageControllerExample/WMMainTableViewController.m @@ -122,6 +122,11 @@ - (void)customizePageController:(WMPageController *)vc { vc.titleSizeSelected = 16; } break; + case WMMenuViewStyleLine: { +// vc.progressColor = [UIColor redColor]; + vc.progressImage = [UIImage imageNamed:@"tab_selected"]; + } + break; default: break; }