美文网首页
LCMenuView简介

LCMenuView简介

作者: HolyCat_猫 | 来源:发表于2014-11-05 16:43 被阅读62次

简介

筛选功能在慧驾项目中用的比较多,所以抽取出来,以便简化代码,便于维护

类与方法说明

LCMenuView
菜单标题相关,与此次迭代UI相同,以后根据UI的变更进行修改,提供方法和属性如下:
<pre><code>

  • (id)initWithFrame:(CGRect)frame //
    segmentWidths:(NSArray *)widths // 每个segment的宽度,类型NSNumber
    segmentTitles:(NSArray *)titles // 标题,类型NSString
    popups:(NSArray *)popups // 弹出菜单,类型LCMenuPopupView
    parentView:(UIView *)parent; // menu的parentView

  • (void)setSegmentTitle:(NSString *)title index:(NSInteger)index; // 设置标题

  • (NSString *)segmentTitleAtIndex:(NSInteger)index; // 标题

  • (BOOL)showPopup:(BOOL)show index:(NSInteger)index animate:(BOOL)animate; // 显示或隐藏菜单

  • (void)hideAllPopup:(BOOL)animate; //隐藏所有菜单

@property (nonatomic, weak, readonly) UIView *parent;
@property (nonatomic, strong, readonly) UIView *maskView;

@property (nonatomic, assign, readonly) NSInteger popedIndex; // 当前显示菜单index
</code></pre>

LCMenuPopupView
弹出菜单相关,主要封装了菜单的弹出收起动画,提供方法和属性如下:
<pre><code>
// 初始化方法 arrowBtmCenterX是箭头X轴位置

  • (id)initWithFrame:(CGRect)frame
    ContentView:(UIView *)contentView
    arrowPosition:(CGFloat)arrowBtmCenterX;

@property (nonatomic, strong, readwrite) UIView *contentView;

@property (nonatomic, assign, readonly) CGFloat arrowBtmCenterX;

// 显示或隐藏内容
@property (nonatomic, assign, getter=isShow) BOOL show;

  • (void)show:(BOOL)show animate:(BOOL)animate;
    </code></pre>

使用方法

创建UIView子类,封装弹出菜单的内容,本次封装的是LCMenuContentView
<pre><code>
LCMenuContentView *t0 = [[LCMenuContentView alloc] initWithFrame:CGRectMake(0, 0, 320, 40 * arrayPopInfoMile.count) titles:arrayPopInfoMile selectRow:0];
t0.shopPopViewDelegate = self;
LCMenuPopupView *p0 = [[LCMenuPopupView alloc] initWithFrame:CGRectMake(0, 0, 320, 40 * arrayPopInfoMile.count) ContentView:t0 arrowPosition:53];

NSInteger index = -1;
index = [arrayPopInfoKind indexOfObject:self.stringTitle];
LCMenuContentView *t1 = [[LCMenuContentView alloc] initWithFrame:CGRectMake(0, 0, 320, 40 * arrayPopInfoKind.count) titles:arrayPopInfoKind selectRow:index];
t1.shopPopViewDelegate = self;
LCMenuPopupView *p1 = [[LCMenuPopupView alloc] initWithFrame:CGRectMake(0, 0, 320, 40 * arrayPopInfoKind.count) ContentView:t1 arrowPosition:160];


LCMenuContentView *t2 = [[LCMenuContentView alloc] initWithFrame:CGRectMake(0, 0, 320, 40 * arrayPopInfoComment.count) titles:arrayPopInfoComment selectRow:-1];
t2.shopPopViewDelegate = self;
LCMenuPopupView *p2 = [[LCMenuPopupView alloc] initWithFrame:CGRectMake(0, 0, 320, 40 * arrayPopInfoComment.count) ContentView:t2 arrowPosition:320 - 53];

LCMenuView *view = [[LCMenuView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)
                                       segmentWidths:@[@(106), @(108), @(106)]
                                       segmentTitles:@[arrayPopInfoMile[0], self.stringTitle, @"智能"]
                                              popups:@[p0, p1, p2]
                                          parentView:self.view];
[self.view addSubview:view];

</code></pre>

相关文章

  • LCMenuView简介

    简介 筛选功能在慧驾项目中用的比较多,所以抽取出来,以便简化代码,便于维护 类与方法说明 LCMenuView菜单...

  • 18旅游二班各组自我简介汇总

    一组简介 二组简介 三组简介 四组简介 五组简介 六组简介 七组简介 八组简介

  • 简介

    上辈子,洛幽喜欢了东凡一辈子,没有结果,之后她死了,她不后悔,只是为什么她一睁眼,嗯?捏了捏自己的脸,她这是回到了...

  • 简介

    1.主动地去阅读。 2.阅读目的:获得资讯,获得理解 前者为了增进资讯,获得信息,不能增加理解力。后者为了理解更多...

  • 简介

    姓名:赵金星 电话:13903984903 坐标:河南三门峡市陕州区。 三个标签的自我介绍: 1.时间管理践行者 ...

  • 简介

    朱凝不过打错个字,便被天打雷劈回古代。 为毛别人穿个废柴嫡女,她穿个废柴庶女?地位更低了哎 哇喔,别人嫁王爷,她嫁...

  • 简介

    凌波网络考试系统,是一套运行于Windows系统之上的无纸化网络考试软件。包括试卷编辑、分发试卷、学生答卷、自动阅...

  • 简介

    名字:笨小孩 不是富二代的笨小孩为了生活选择了编程。在大多数人眼里可能感觉编程是很无聊很辛苦经常加班的事情,其实人...

  • 简介

    A Native Client web application consists of JavaScript, H...

  • 简介

    选择django作为毕设项目,和日后工作内容。故在简单得做了一个blog和毕设系统之间,想深入了解django,会...

网友评论

      本文标题:LCMenuView简介

      本文链接:https://www.haomeiwen.com/subject/pokbtttx.html