| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- //
- // YCXMenu+Extension.m
- // powerone
- //
- // Created by clouder on 2019/9/17.
- // Copyright © 2019 onecloud.ltd. All rights reserved.
- //
- #import "YCXMenu+Extension.h"
- @implementation YCXMenu (Extension)
- + (void)po_showMenuWithTarget:(id)target array:(NSArray *)array
- {
- [self po_showMenuWithTarget:target array:array location:CGRectMake(SCREENWIDTH - 75, NAV_BAR_HEIGHT - 40, 90, 30)];
- }
- + (void)po_showMenuWithTarget:(id)target array:(NSArray *)array location:(CGRect)loc
- {
- if (array.count == 0)
- return;
-
- NSMutableArray *menuItemArray = [NSMutableArray array];
- id firstObjt = array.firstObject;
- if ([firstObjt isKindOfClass:[YCXMenuItem class]])
- {
- menuItemArray = [array mutableCopy];;
- }
- else
- {
- for (NSInteger i = 0; i<array.count; i++)
- {
- NSDictionary *dic = array[i];
- UIImage *image = dic[@"image"];
- if ([image isKindOfClass:[NSString class]])
- {
- image = [UIImage imageNamed:dic[@"image"]];
- }
-
- YCXMenuItem *item = [YCXMenuItem menuItem:dic[@"name"] image:image target:target action:NSSelectorFromString(dic[@"sel"])];
- item.tag = i;
- item.showBadge = NO;
- item.alignment = NSTextAlignmentLeft;
- item.foreColor = [UIColor whiteColor];
- [menuItemArray addObject:item];
- }
- }
-
- [YCXMenu setTintColor:[UIColor whiteColor]];
- [YCXMenu setSelectedColor:[UIColor whiteColor]];
- [YCXMenu setHasShadow:YES];
- [YCXMenu setTitleFont:[MOTextTools getTheFontWithSize:14.0 AndFontName:kNormalContentFontStr]];
- [YCXMenu setCornerRadius:4.f];
- [YCXMenu setSeparatorColor:UIColorFromHex(0xf5f5f5)];
- [YCXMenu setMenuItemMarginY:15];
- [YCXMenu setArrowSize:5.0];
- UIWindow *window = kKeyWindow;
-
- [YCXMenu showMenuInView:window fromRect:loc menuItems:menuItemArray selected:^(NSInteger index, YCXMenuItem *item) {}];
-
- }
- + (void)po_showMenuWithTarget:(id)target arrayParam:(NSArray *)array location:(CGRect)loc
- {
- if (array.count == 0)
- return;
-
- NSMutableArray *menuItemArray = [NSMutableArray array];
- for (NSInteger i = 0; i<array.count; i++)
- {
- NSDictionary *dic = array[i];
- YCXMenuItem *item = [YCXMenuItem menuItem:dic[@"name"] image:[UIImage imageNamed:dic[@"image"]] target:target action:NSSelectorFromString(dic[@"sel"]) userInfo:dic[@"userInfo"]];
- item.tag = i;
- item.showBadge = NO;
- item.alignment = NSTextAlignmentLeft;
- item.foreColor = [UIColor whiteColor];
- [menuItemArray addObject:item];
- }
-
- [YCXMenu setTintColor:[UIColor whiteColor]];
- [YCXMenu setSelectedColor:[UIColor whiteColor]];
- [YCXMenu setHasShadow:YES];
- [YCXMenu setTitleFont:[MOTextTools getTheFontWithSize:14.0 AndFontName:kNormalContentFontStr]];
- [YCXMenu setCornerRadius:5.f];
- [YCXMenu setSeparatorColor:UIColorFromHex(0xf5f5f5)];
- [YCXMenu setMenuItemMarginY:10];
- [YCXMenu setArrowSize:5.0];
- UIWindow *window = kKeyWindow;
-
- [YCXMenu showMenuInView:window fromRect:loc menuItems:menuItemArray selected:^(NSInteger index, YCXMenuItem *item) {}];
- }
- + (void)po_showMenuWithTarget:(id)target arrayParam:(NSArray *)array location:(CGRect)loc itemWidth:(CGFloat)width
- {
- if (array.count == 0)
- return;
-
- NSMutableArray *menuItemArray = [NSMutableArray array];
- for (NSInteger i = 0; i<array.count; i++)
- {
- NSDictionary *dic = array[i];
- YCXMenuItem *item = [YCXMenuItem menuItem:dic[@"name"] image:[UIImage imageNamed:dic[@"image"]] target:target action:NSSelectorFromString(dic[@"sel"]) userInfo:dic[@"userInfo"]];
- item.tag = i;
- item.showBadge = NO;
- item.alignment = NSTextAlignmentLeft;
- item.foreColor = [UIColor whiteColor];
- [menuItemArray addObject:item];
- }
-
- [YCXMenu setTintColor:[UIColor whiteColor]];
- [YCXMenu setSelectedColor:[UIColor whiteColor]];
- [YCXMenu setHasShadow:YES];
- [YCXMenu setTitleFont:[MOTextTools getTheFontWithSize:14.0 AndFontName:kNormalContentFontStr]];
- [YCXMenu setCornerRadius:5.f];
- [YCXMenu setSeparatorColor:UIColorFromHex(0xf5f5f5)];
- [YCXMenu setMenuItemMarginY:10];
- [YCXMenu setArrowSize:5.0];
- UIWindow *window = kKeyWindow;
-
- [YCXMenu showMenuInView:window fromRect:loc menuItems:menuItemArray itemWidth:width selected:^(NSInteger index, YCXMenuItem *item) {}];
- }
- @end
|