Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions WMPageController/WMMenuView/WMMenuView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<WMMenuViewDelegate> delegate;
@property (nonatomic, weak) id<WMMenuViewDataSource> dataSource;
Expand Down
6 changes: 4 additions & 2 deletions WMPageController/WMMenuView/WMMenuView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions WMPageController/WMMenuView/WMProgressView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 10 additions & 3 deletions WMPageController/WMMenuView/WMProgressView.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,23 @@ - (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) {
CGContextSetStrokeColorWithColor(ctx, self.color);
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) {
// 计算点
Expand Down
6 changes: 6 additions & 0 deletions WMPageController/WMPageController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 下的宽度
*/
Expand Down
3 changes: 3 additions & 0 deletions WMPageController/WMPageController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down